我在wavedec2
上遵循了MathWorks教程,无法正确显示任何系数或近似子图。
有人可以建议我如何解决这个问题,以便正确显示近似和详细的子图吗?
这是我到目前为止所做的:
% Load image ‘Sample.tif’ and convert it into a grayscale image, denoted with ‘img1’
I = imread('Sample.tif');
img1 = rgb2gray(I);
% Decompose img1 with wavelet transform using function wavedec2
% Perform decomposition at level 2
% of X using haar.
[C,S] = wavedec2(I,2,'haar');
[H1,V1,D1] = detcoef2('all',C,S,1);
A1 = appcoef2(C,S,'haar',1);
V1img = wcodemat(V1,255,'mat',1);
H1img = wcodemat(H1,255,'mat',1);
D1img = wcodemat(D1,255,'mat',1);
A1img = wcodemat(A1,255,'mat',1);
[H2,V2,D2] = detcoef2('all',C,S,2);
A2 = appcoef2(C,S,'haar',2);
V2img = wcodemat(V2,255,'mat',1);
H2img = wcodemat(H2,255,'mat',1);
D2img = wcodemat(D2,255,'mat',1);
A2img = wcodemat(A2,255,'mat',1);
subplot(2,2,1);
imagesc(A1img);
colormap red(255);
title('Approximation Coef. of Level 1');
subplot(2,2,2);
imagesc(H1img);
title('Horizontal detail Coef. of Level 1');
subplot(2,2,3);
imagesc(V1img);
title('Vertical detail Coef. of Level 1');
subplot(2,2,4);
imagesc(D1img);
title('Diagonal detail Coef. of Level 1');
输出在这里,所有子图都是白色的:
Sample.tif在这里: