clear all;
close all;
I1=imread('car1.bmp');
h=ones(4,4)/16;
I2=imfilter(I1,h); %通过四邻域方法得到低分辨率的图像
figure(1);
imshow(I1),title('原始图像');
figure(2);
imshow(I2),title('低分辨率的图像');
%用双线性插值方法获得插值图像Y1
[Y1,map]=imresize(I2,2,'bilinear');
%用最近邻域插值得到邻域插值图像Y2
[Y2,map]=imresize(I2,2);
[c,s]=wavedec2(Y1,2,'haar');
sizey1=size(Y1);
%从小波分解的结构[c,s]中提取Y1第一层的尺度系数和小波系数
Xa1=appcoef2(c,s,'haar',1);
Xh1=detcoef2('h',c,s,1);
Xv1=detcoef2('v',c,s,1);
Xd1=detcoef2('d',c,s,1);
ded1=[Xa1,Xh1,Xv1,Xd1];
nbcol=size(map,1);
[c,s]=wavedec2(Y1,2,'haar');
sizey2=size(Y2);
%从小波分解的结构[c,s]中提取Y2第一层的尺度系数和小波系数
Xa2=appcoef2(c,s,'haar',1);
Xh2=detcoef2('h',c,s,1);
Xv2=detcoef2('v',c,s,1);
Xd2 =detcoef2('d',c,s,1);
ded1=[Xa2,Xh2,Xv2,Xd2];
nbcol=size(map,1);
Y=idwt2(Xa2,Xh1,Xv1,Xd1,'haar');
nbcol=size(map,1);
figure(3);
imshow(uint8(Y)),title('获得的超分辨率图像');
% err = Y - I2;
% err = err(:);
% PSNRdb = 20 * log10(256/sqrt(mean(err .^2)));
D135