# Image super resolution algorithm in Matlab

I'm trying to implement a simple Image super resolution algorithm (DWT-Based Resolution Enhancement ) in the following paper

http://www.ripublication.com/aeee/52_pp%20%20%20405-412.pdf

I tried to implement the algorithm in figure 3 of this paper using Matlab.Code is given below.

img1 = imread('lena1.jpg'); %original High resolution image
[height, width, dim] = size(img1);

%%Downsampling the image by averaging
avgfilter = fspecial('average', [2 2]);
avgimg = filter2(avgfilter, img1);
img = avgimg(1:2:end,1:2:end); %Input low resolution image

[LL,LH,HL,HH] = dwt2(img,'haar'); %Decomposing

%Bicubic interpolation by factor 2 on each subbands
LL1 = imresize(LL,2,'bicubic');
LH1 = imresize(LH,2,'bicubic');
HL1 = imresize(HL,2,'bicubic');
HH1 = imresize(HH,2,'bicubic');

%% Calculating Difference image
for i=1:256
for j=1:256
img3(i,j,:) = img(i,j,:) - LL1(i,j,:);
end
end

for i=1:256
for j=1:256
LH13(i,j,:) = img3(i,j,:) + LH1(i,j,:);
HL13(i,j,:) = img3(i,j,:) + HL1(i,j,:);
HH13(i,j,:) = img3(i,j,:) + HH1(i,j,:);
end
end

%bicubic interpolation(Here alpha = 2;Hence alpha/2 = 1)
img31 = imresize(img3,1,'bicubic');
LH131 = imresize(LH13,1,'bicubic');
HL131 = imresize(HL13,1,'bicubic');
HH131 = imresize(HH13,1,'bicubic');

img4 = idwt2(img31,LH131,HL131,HH131,'haar'); %IDWT
t = uint8(img4)
imshow(t);
imsave;


Input image that I used is given below But I'm getting a completely unexpected output as follows. Why this is happening.Please help.Thanks in advance.

• Have you tried to debug your code, looking at intermediate results and checking if they are sensible? – Jazzmaniac Nov 6 '14 at 13:02
• @Jazzmaniac Yes sir.I dont think that there is any mistake with the concept.May be due to some coding error.But couldn't find it out. – Celine Nov 7 '14 at 8:37
• What you are displaying seems to be the gradient along both x and y – A.Rashad Oct 14 '15 at 6:22
• I am also suffering from same problem.. I think there is problem in difference of spatial domain and frequency domain signals.. – user19982 Mar 11 '16 at 4:56
• This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation. - From Review – Laurent Duval Mar 11 '16 at 6:46