如何在matlab中对图像进行三级哈尔变换

时间:2018-04-02 08:29:47

标签: matlab image-processing haar-wavelet

我有问题如何在Matlab中为图像制作第三级。我使用这段代码:

image=imread('image.jpeg');
wavename = 'haar';
[cA,cH,cV,cD] = dwt2(im2double(image),wavename); %first level 
[cAA,cAH,cAV,cAD] = dwt2(cA,wavename); % Recompute Wavelet of Approximation Coefs.
Level2=[cAA,cAH; cAV,cAD]; %contacinat and second level
imshow([Level2,cH; cV,cD],'Colormap',gray);

[cAAA,cAAH,cAAV,cAAD] = dwt2(cAA,wavename); % Recompute Wavelet of Approximation Coefs.
Level3=[cAAA,cAAH;cAAV,cAAD]; %contacinat
imshow([Level3, cAH; cAV,cAD],'Colormap',gray); %3 level

但程序说最后一行有错误。错误是" CAT参数维度不一致。"所以问题是如何让这段代码起作用?

1 个答案:

答案 0 :(得分:0)

这是由你的形象造成的,我想。

以下代码正常运行,但未对图像进行任何更改

image=imread('cameraman.tif');
wavename = 'haar';
[cA,cH,cV,cD] = dwt2(im2double(image),wavename); %first level 
[cAA,cAH,cAV,cAD] = dwt2(cA,wavename); % Recompute Wavelet of Approximation Coefs.
Level2=[cAA,cAH; cAV,cAD]; %contacinat and second level
imshow([Level2,cH; cV,cD],'Colormap',gray);
figure
[cAAA,cAAH,cAAV,cAAD] = dwt2(cAA,wavename); % Recompute Wavelet of Approximation Coefs.
Level3=[cAAA,cAAH;cAAV,cAAD]; %contacinat
imshow([Level3, cAH; cAV,cAD],'Colormap',gray); %3 level