4
$\begingroup$

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

Discrete Wavelet Transform-Based Satellite Image Resolution Enhancement

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

enter image description here

But I'm getting a completely unexpected output as follows.

enter image description here Why this is happening?

$\endgroup$
6
  • 1
    $\begingroup$ Have you tried to debug your code, looking at intermediate results and checking if they are sensible? $\endgroup$
    – Jazzmaniac
    Commented Nov 6, 2014 at 13:02
  • $\begingroup$ @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. $\endgroup$
    – Celine
    Commented Nov 7, 2014 at 8:37
  • $\begingroup$ What you are displaying seems to be the gradient along both x and y $\endgroup$
    – A.Rashad
    Commented Oct 14, 2015 at 6:22
  • $\begingroup$ I am also suffering from same problem.. I think there is problem in difference of spatial domain and frequency domain signals.. $\endgroup$
    – user19982
    Commented Mar 11, 2016 at 4:56
  • $\begingroup$ 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 $\endgroup$ Commented Mar 11, 2016 at 6:46

1 Answer 1

0
$\begingroup$

First, this is not a good algorithm.
It is a native method to achieve upsampling.

I implemented the method:

clear();
close('all');

wavType = 'haar';

intMethod = 'bicubic';

mImgRef = imread('https://i.imgur.com/8jvEQJX.png'); % Reference image
mImgRef = mImgRef(:, :, 1); %<! Working on a single channel
mImgRef = im2double(mImgRef);
[numRows, numCols] = size(mImgRef);

% Low resolution image
mImg = imresize(mImgRef, 0.5, intMethod, 'Antialiasing', true);

[mLL, mLH, mHL ,mHH] = dwt2(mImg, wavType); % Forward DWT

% Interpolation by 2 factor
mLL1 = imresize(mLL, 2, intMethod);   
mLH1 = imresize(mLH, 2, intMethod);
mHL1 = imresize(mHL, 2, intMethod);
mHH1 = imresize(mHH, 2, intMethod);

mDiffImg = mImg - mLL1;

mLH2 = mLH1 + mDiffImg;
mHL2 = mHL1 + mDiffImg;
mHH2 = mHH1 + mDiffImg;

% alpha = 2 -> No need for resize
mLL3 = imresize(mImg, 1, intMethod);
mLH3 = imresize(mLH2, 1, intMethod);
mHL3 = imresize(mHL2, 1, intMethod);
mHH3 = imresize(mHH2, 1, intMethod);

% High resolution image
mImgHr = idwt2(mLL3, mLH3, mHL3, mHH3, wavType);

% Display high resolution image
figure()
imshow([mImgRef, mImgHr]);

This is the output:

enter image description here

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.