After computing the 4-level discrete wavelet transform of an image, how do I display this multi-level transformation in matlab? And how do I plot the histogram of the corresponding DWT coefficients?
Here is what I did so far:
I = imread('image.png');
N = 4;
[C,S] = wavedec2(im2double(I),N,'haar');
A = appcoef2(C,S,'haar',1);
[H1,V1,D1] = detcoef2('all',C,S,1);
[H2,V2,D2] = detcoef2('all',C,S,2);
[H3,V3,D3] = detcoef2('all',C,S,3);
[H4,V4,D4] = detcoef2('all',C,S,4);
This is what I would do it:
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
Actually, since I'm not very esperienced in digital image processing, it's up to you to tweak my example and make it fits your needs.