按照百度弄来的代码直接运行的 不知道问题出在哪里 请各位大神指出错误 并改正 感激不尽 代码如下
clc;clear;close all
I = imread('C:\Users\cui\Desktop\lena1.bmp');
%subplot(221);
subplot(221),imshow(I,[],'InitialMagnification',100);
title('原始载体图像')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%图像的一级小波分解
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[c1,s1]=wavedec2(double(I),1,'db1');
ca88 = appcoef2(c1,s1,'db1',1);
ch88 = detcoef2('h',c1,s1,1);
cv88 = detcoef2('v',c1,s1,1);
cd88 = detcoef2('d',c1,s1,1);
A88 = [ca88,ch88;cv88,cd88];
%subplot(222);
subplot(222),imshow(A88,[],'InitialMagnification',100);
title('图像的一级小波分解');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%图像的二级小波分解
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[c,s]=wavedec2(double(I),2,'db1');
ca2 = appcoef2(c,s,'db1',2);
ch2 = detcoef2('h',c,s,2);
cv2 = detcoef2('v',c,s,2);
cd2 = detcoef2('d',c,s,2);
%ca1 = appcoef2(c,s,'db2',1);
ch1 = detcoef2('h',c,s,1);
cv1 = detcoef2('v',c,s,1);
cd1 = detcoef2('d',c,s,1);
A1 = [ca2*4,ch2*4;cv2*4,cd2*4];
k=s(2,1)*2-s(3,1);
ch1 = padarray(ch1,[k k],1,'post');
cv1 = padarray(cv1,[k k],1,'post');
cd1 = padarray(cd1,[k k],1,'post');
%A = [A1,ch1*4; cv1*4,cd1*4];
A = [A1,ch1*10; cv1*10,cd1*10];
% min = min(A(:));
% max = max(A(:));
%subplot(223);
subplot(223),imshow(A,[],'InitialMagnification',100);
title('图像的二级小波分解');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%图像的三级小波分解
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[c,s]=wavedec2(double(I),3,'db1');
ca3 = appcoef2(c,s,'db1',3);
ch3 = detcoef2('h',c,s,3);
cv3 = detcoef2('v',c,s,3);
cd3 = detcoef2('d',c,s,3);
ch2 = detcoef2('h',c,s,2);
cv2 = detcoef2('v',c,s,2);
cd2 = detcoef2('d',c,s,2);
ch1 = detcoef2('h',c,s,1);
cv1 = detcoef2('v',c,s,1);
cd1 = detcoef2('d',c,s,1);
A2 = [ca3*4,ch3*4;cv3*4,cd3*4];
k=s(2,1)*2-s(3,1);
ch2 = padarray(ch2,[k k],1,'post');
cv2 = padarray(cv2,[k k],1,'post');
cd2 = padarray(cd2,[k k],1,'post');
A1= [A2,ch2*4; cv2*4,cd2*4];
k=s(2,1)*4-s(4,1);
ch1 = padarray(ch1,[k k],1,'post');
cv1 = padarray(cv1,[k k],1,'post');
cd1 = padarray(cd1,[k k],1,'post');
AA = [A1,ch1*4; cv1*4,cd1*4];
% min = min(A(:));
% max = max(A(:));
%subplot(224);
subplot(224),imshow(AA,[],'InitialMagnification',100);
title('图像的三级小波分解');
clc;clear;close all
I = imread('C:\Users\cui\Desktop\lena1.bmp');
%subplot(221);
subplot(221),imshow(I,[],'InitialMagnification',100);
title('原始载体图像')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%图像的一级小波分解
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[c1,s1]=wavedec2(double(I),1,'db1');
ca88 = appcoef2(c1,s1,'db1',1);
ch88 = detcoef2('h',c1,s1,1);
cv88 = detcoef2('v',c1,s1,1);
cd88 = detcoef2('d',c1,s1,1);
A88 = [ca88,ch88;cv88,cd88];
%subplot(222);
subplot(222),imshow(A88,[],'InitialMagnification',100);
title('图像的一级小波分解');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%图像的二级小波分解
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[c,s]=wavedec2(double(I),2,'db1');
ca2 = appcoef2(c,s,'db1',2);
ch2 = detcoef2('h',c,s,2);
cv2 = detcoef2('v',c,s,2);
cd2 = detcoef2('d',c,s,2);
%ca1 = appcoef2(c,s,'db2',1);
ch1 = detcoef2('h',c,s,1);
cv1 = detcoef2('v',c,s,1);
cd1 = detcoef2('d',c,s,1);
A1 = [ca2*4,ch2*4;cv2*4,cd2*4];
k=s(2,1)*2-s(3,1);
ch1 = padarray(ch1,[k k],1,'post');
cv1 = padarray(cv1,[k k],1,'post');
cd1 = padarray(cd1,[k k],1,'post');
%A = [A1,ch1*4; cv1*4,cd1*4];
A = [A1,ch1*10; cv1*10,cd1*10];
% min = min(A(:));
% max = max(A(:));
%subplot(223);
subplot(223),imshow(A,[],'InitialMagnification',100);
title('图像的二级小波分解');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%图像的三级小波分解
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[c,s]=wavedec2(double(I),3,'db1');
ca3 = appcoef2(c,s,'db1',3);
ch3 = detcoef2('h',c,s,3);
cv3 = detcoef2('v',c,s,3);
cd3 = detcoef2('d',c,s,3);
ch2 = detcoef2('h',c,s,2);
cv2 = detcoef2('v',c,s,2);
cd2 = detcoef2('d',c,s,2);
ch1 = detcoef2('h',c,s,1);
cv1 = detcoef2('v',c,s,1);
cd1 = detcoef2('d',c,s,1);
A2 = [ca3*4,ch3*4;cv3*4,cd3*4];
k=s(2,1)*2-s(3,1);
ch2 = padarray(ch2,[k k],1,'post');
cv2 = padarray(cv2,[k k],1,'post');
cd2 = padarray(cd2,[k k],1,'post');
A1= [A2,ch2*4; cv2*4,cd2*4];
k=s(2,1)*4-s(4,1);
ch1 = padarray(ch1,[k k],1,'post');
cv1 = padarray(cv1,[k k],1,'post');
cd1 = padarray(cd1,[k k],1,'post');
AA = [A1,ch1*4; cv1*4,cd1*4];
% min = min(A(:));
% max = max(A(:));
%subplot(224);
subplot(224),imshow(AA,[],'InitialMagnification',100);
title('图像的三级小波分解');