这就是我要做的:
N = 4;
img = imread('image.png');
img = im2double(img);
[C,S] = wavedec2(img,N,'haar');
for i = 1:N
lvl = ['Level ' num2str(i)];
A = appcoef2(C,S,'haar',i);
[H,V,D] = detcoef2('all',C,S,i);
figure('Name',['Images (' lvl ')']);
% Eventually, you can define a colormap for your images...
% colormap(pink(255));
subplot(2,2,1); imagesc(A);
title('Approximation')
subplot(2,2,2); imagesc(H);
title('Horizontal Detail');
subplot(2,2,3); imagesc(V);
title('Vertical Detail');
subplot(2,2,4); imagesc(D);
title('Diagonal Detail');
suptitle(lvl);
% tweak the histogram bins as you prefer
figure('Name',['Histograms (' lvl ')']);
subplot(2,2,1); hist(A(:),32);
subplot(2,2,2); hist(H(:),32);
subplot(2,2,3); hist(V(:),32);
subplot(2,2,4); hist(D(:),32);
suptitle(lvl);
end
实际上,由于我在数字图像处理方面不是很有经验,因此您可以调整我的示例并使其适合您的需求。