Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab中的图像超分辨率算法_Matlab_Image Processing_Interpolation_Dwt - Fatal编程技术网

Matlab中的图像超分辨率算法

Matlab中的图像超分辨率算法,matlab,image-processing,interpolation,dwt,Matlab,Image Processing,Interpolation,Dwt,我正在尝试实现一个简单的图像超分辨率算法(基于DWT的分辨率增强) )在下面的文章中 我尝试使用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 = f

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

我尝试使用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;
但我得到了一个完全出乎意料的输出图像。为什么会发生这种情况。请帮助。提前感谢

输入图像:

输出图像:


我看了一下报纸上的方框图。你正在用错误的图像重建。在最后一步,您应该使用原始降采样图像作为IDWT的一部分,而不是差分图像。以下是自我遏制的示意图:

看看算法的最后一步。您需要将低分辨率图像与上一步中的LH、HL和HH组件一起使用。在上一步中,通过将上一步中的DWT分量(不含LL分量)与差分图像相加,可以获得这些子带中的每一个子带,这样就得到了正确的结果

我还建议您修改图像,使其动态范围从
[0,1]
。你可以用它来做这件事。您还使用
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,[]);
这是我得到的图像:


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


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

“但我得到了一个完全出乎意料的输出图像”-那么你期待什么,你得到什么?你希望我们阅读报纸并检查你的代码吗?@RogerRowland我没有足够的声誉来添加图像。这就是我无法添加图像的原因。我得到的输出几乎是一个暗图像,不是一个清晰的图像。然后也许你只需要做一个拉伸(直方图均衡)显示前?几乎可以肯定,您的输出不是
imshow
所期望的数据类型和数据范围的组合。尝试
imshow(t,[])每当我读到“完全出乎意料”时,我都会想:他/她有没有得到一只迅猛龙作为输出?您不能放置图像,但可以删除图像链接!;)把它上传到imageshank什么的