I am quite lost at the moment i had a supervisor who was working on this project but he left unexpected and now im left without any support or someone who really understands what im trying to do and that i can ask questions to so these may seem very trivial:
I start off with a 512x512 image and down sample to a 64x64 pixel image. The code i have done below the main thing i want to achieve is for 64x64 bit image with the missing pixels i want to use the conv2 (or another method) to find the smallest difference in intensity surrounding the missing pixels and have this smallest difference to know which direction to interpolate. How would i word the coding the for for loop to do this?
Thanks!
function FYPDCT_Image()
lena=imread('lena.bmp');
size(lena)
[m n p]=size(lena)
a=rgb2gray(lena);
imshow(a);
title('Original Grayscale Image');
lena_c=zeros(m,n,p);
lenad=a;
for i=1:16:512
for j=1:16:512
lenad(i:i+7,j:j+7)=0;
end
end
%% DCT
subplot(2,2,1);
imshow(lenad)
[m n] = size(lenad)
title([num2str(m) ' X ' num2str(n)]);
subplot(2,2,2);
lenad_ds1=DS_DCT(lenad,8);
imshow(uint8(lenad_ds1));
[m n] = size(lenad_ds1)
title([num2str(m) ' X ' num2str(n)]);
subplot(2,2,3);
lenad_ds2=DS_DCT(lenad_ds1,4);
imshow(uint8(255*lenad_ds2/max(max(lenad_ds2))));
[m n] = size(lenad_ds2)
title([num2str(m) ' X ' num2str(n)]);
subplot(2,2,4);
lenad_ds3=DS_DCT(lenad_ds2,2);
imshow(uint8(255*lenad_ds3/max(max(lenad_ds3))));
[m n] = size(lenad_ds3)
title([num2str(m) ' X ' num2str(n)]);
kernel = [-1 -1 -1;-1 8 -1; -1 -1 -1]/8;
differenceImage = conv2(double(lenad_ds3), kernel, 'same');
differenceImage
%% Downsample by a factor of square(2) using DCT
function ImageOut=DS_DCT(ImageIn,MBsize)
[m n]=size(ImageIn);
k=1;
for i=1:MBsize:m-MBsize+1
l=1;
for j=1:MBsize:m-MBsize+1
temp=ImageIn(i:i+MBsize-1,j:j+MBsize-1);
tempDCT=dct2(temp);
temp=idct2(tempDCT(1:MBsize/2,1:MBsize/2));
ImageOut(k:k+MBsize/2-1,l:l+MBsize/2-1)=temp;
l=l+MBsize/2;
end
k=k+MBsize/2;
end