1

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
user3005733
  • 11
  • 1
  • 2
  • Have a look at the interpolation tutorial given in this post: http://stackoverflow.com/a/20009314/2777181 – Cape Code Nov 18 '13 at 18:12

1 Answers1

0

You can initialize a pixel by averaging neighboring pixels by the window size 3*3. Then interpolate image as usual.

IMAGE1=load('img.jpg');
image_interpol = imresize(IMAGE1, 0.125, 'bicubic');

imresize returns image_interpol that is 0.125 times the size of IMAGE1. 'bicubic' is interpolation type.

Plo_Koon
  • 2,953
  • 3
  • 34
  • 41
  • How would I intitalise a pixel window of 3x3? How would the data be collected around the missing pixel for this information to be put into the 3x3 window and then interpolating? – user3005733 Nov 21 '13 at 21:48
  • 2
    You should average 8 neighboring pixels around of the missed pixel, and initialize missed pixel by calculated average. – Plo_Koon Nov 22 '13 at 12:29