离散小波变换Matlab [英] Discrete Wavelet Transform Matlab

查看:359
本文介绍了离散小波变换Matlab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Matlab小波工具箱中提供的功能来创建图像的多级离散小波分解,提取系数,对其进行处理,然后将其重新组合回图像中.

我尝试使用许多功能,但是似乎没有一个功能可以满足我的需求.这些是执行此操作的步骤.

  1. 使用wavedec2将图像分解为[C,S]. [C,S] = wavedec2(X,N,Lo_D,Hi_D)

  2. 然后,我必须使用detcoef2从[C,S]中提取细节系数. [C,S]是小波分解结构",它不代表实际系数,例如cD,cH,cV. [H,V,D] = detcoef2('all',C,S,N)

  3. 处理数据

  4. 重构[C,S] ????没有功能.

  5. 使用waverec2重新合成原始图像. X = waverec2(C,S,Lo_R,Hi_R)

问题出在第4步.没有函数可以重新创建[C,S],我不能调用函数waverec2,因为它需要C和S的可操纵版本.

我不需要wavedec2和waverec2吗?也许我应该只使用detcoef2和upcoef2?

具有DWT经验的人可以在一分钟内解决此问题,我还很陌生.

谢谢

解决方案

我很好奇为什么不能使用 im2double 将图像转换为双精度以确保准确性.我们得到这张图片:

请注意,图像会被2二次采样,以产生LL, LH, HLHH的分解.

一旦拥有了这些组件,就可以肯定地操纵它们.操作完它们之后,您可以像下面这样简单地使用 idwt2 :

Y = idwt2(LL,LH,HL,HH,Lo_R,Hi_R); %//or
Y = idwt2(LL,LH,HL,HH,'wname');

假定这四个成分为double,因此您可以将图像转换回代表图像的任何类型.假设您的图片是uint8,则可以执行以下操作:Y = im2uint8(Y);进行转换.

希望这就是您要寻找的东西!

I am trying to use the functions provided in the Matlab Wavelet Toolbox to create a multi-level discrete wavelet decomposition of an image, extracting the coefficients, manipulating them, and recomposing them back into the image.

I tried using a number of functions but none of them seem to do what I need. These are the steps to do this.

  1. Use wavedec2 to decompose the image into [C,S]. [C,S] = wavedec2(X,N,Lo_D,Hi_D)

  2. I then must use detcoef2 to extract the detail coefficients from [C,S]. [C,S] is the 'wavelet decomposition structure', it does not represent the actual coefficients such as cD, cH, cV. [H,V,D] = detcoef2('all',C,S,N)

  3. Manipulate the data

  4. Reconstruct [C,S] ???? no function does this.

  5. Use waverec2 to recompose the original image. X = waverec2(C,S,Lo_R,Hi_R)

The problem is with step 4. There is no function that recreates the [C,S] and I can't call the function waverec2 because it needs the manipulated version of C and S.

Do I not need wavedec2 and waverec2? Perhaps should I just use detcoef2 and upcoef2?

Someone with some experience with DWT could solve this in a minute, I am fairly new to it.

Thanks

解决方案

I'm curious as to why you can't use dwt2 for computing the 2D DWT of images. What you have there is a lot more work than what you should be doing. dwt2 is much more suitable to do what you want. You'd call dwt2 like so:

[LL,LH,HL,HH] = dwt2(X,Lo_D,Hi_D);

X is your image, and Lo_D and Hi_D are your low-pass and high-pass filters you want to apply to the image. LL is the low-passed version of the image, where the horizontal and vertical directions are low-passed, LH is where the vertical direction is low-passed and the horizontal direction is high-passed, HL is the vertical direction is high-passed and the horizontal direction is low-passed, and HH is where both directions are high-passed. As such LH, HL and HH are the detail coefficients while LL contains the structure.

You can also specify the filter you want with a string as the second parameter:

[LL,LH,HL,HH] = dwt2(X,'wname');

'wname' is a string that specifies what filter you want. You can type in help wfilters to see what filters are available.

For example, by doing using cameraman.tif from MATLAB's system path, we can do a one level 2D DWT (using the Haar wavelet) and show all of the components like so:

im = imread('cameraman.tif');
[LL, LH, HL, HH] = dwt2(im2double(im), 'haar');
imshow([LL LH; HL HH], []);

I use im2double to convert the image to double precision to ensure accuracy. We get this image:

Note that the image is subsampled by 2 in order to produce the decompositions of LL, LH, HL and HH.

Once you have these components, you can certainly manipulate them to your heart's content. Once you manipulate them, you can simply use idwt2 like so:

Y = idwt2(LL,LH,HL,HH,Lo_R,Hi_R); %//or
Y = idwt2(LL,LH,HL,HH,'wname');

The four components are assumed to be double, and so you can convert the images back to whatever type that was representing the image. Assuming your image was uint8, you can do: Y = im2uint8(Y); to convert back.

This should hopefully be what you're looking for!

这篇关于离散小波变换Matlab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆