2

我正在尝试在以下论文中实现一个简单的图像超分辨率算法(基于 DWT 的分辨率增强)

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

我尝试使用 Matlab 实现本文图 3 中的算法。代码如下。

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;

但是我得到了一个完全出乎意料的输出图像。为什么会这样。请帮助。提前致谢。

输入图像:

莉娜1

输出图像:

输出

4

1 回答 1

4

我看了一下论文中的框图。您正在使用错误的图像进行重建。在最后一步,您应该使用原始的下采样图像作为 IDWT 的一部分,而不是差异图像。下面是自控示意图:

在此处输入图像描述

看看算法的最后一步。您将使用低分辨率图像,并结合上一步中的 LH、HL 和 HH 组件。在上一步中,您通过将上一步中的 DWT 分量(没有 LL 分量)与差异图像相加来获得这些子带中的每一个,因此您得到了正确的结果。

我建议的其他一些评论是更改您的图像,使其动态范围从[0,1]. 您可以使用im2double. 您还使用for循环来低效地计算矢量化操作时的差异。1最后,您将在代码末尾执行插值。这是一个无用的操作,因为您只会得到相同的图像。我从您的代码中删除了它以加快速度。因此,这是我拥有的代码。请记住,您没有包含您的莉娜图像,所以我从互联网上提取了一张。

事不宜迟,这是您修改后的代码:

clear all;
close all;
img1 = imread('http://www.ece.rice.edu/~wakin/images/lenaTest3.jpg'); %original High resolution image
[height, width, dim] = size(img1);

%// Change - convert to [0,1]
img1 = im2double(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');

% // Change - Vectorized operations
img3 = img - LL1;
LH13 = img3 + LH1;
HL13 = img3 + HL1;
HH13 = img3 + HH1;

%bicubic interpolation(Here alpha = 2;Hence alpha/2 = 1) 
%// Change - commented out
%// Also, used ORIGINAL downsampled image, not the difference image
 %img31 = imresize(img,1,'bicubic');
 %LH131 = imresize(LH13,1,'bicubic');
 %HL131 = imresize(HL13,1,'bicubic');
 %HH131 = imresize(HH13,1,'bicubic');

%// Change - used original downsampled image
img4 = idwt2(img,LH13,HL13,HH13,'haar'); %IDWT
t = im2uint8(img4); %// Change - Convert back to uint8 when finished
imshow(t,[]);

这是我得到的图像:

在此处输入图像描述


我没有得到任何接近原始莉娜形象的东西。因此,我怀疑要么你必须调整一些参数,要么算法有缺陷。鉴于该方法发表在无名期刊上,我怀疑是后者。

这应该让你开始。祝你好运!

于 2014-11-07T15:41:42.147 回答