# 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.