小波系数阈值化
我一直在 Mathematica 和 Matlab 中对图像数据使用小波进行一些实验。我已经在 Mathematica 中找到了一些代码,它们似乎基本上做了我想要的事情,如下所示:
dwd = DiscreteWaveletTransform[imagedata, HaarWavelet[]];
thr = WaveletThreshold[dwd, {"LargestCoefficients", 100}, Automatic];
out = InverseWaveletTransform[thr];
上面的代码通过仅保留 100 个最大系数来执行小波阈值处理。然而,我更喜欢的是做同样的事情(或者或多或少相同的事情)的 Matlab 代码。
我一直在尝试使用小波工具箱,但到目前为止还没有取得多大成功。到目前为止,我似乎最接近的是使用wavedec2
。我一直在对这样的事情进行一些修改:
[c,s] = wavedec2(imagedata, level, 'haar');
c1 = threshold(c, 100) % a function that zeros everything but the 100 biggest coefficients in c.
out = waverec2(c1, s, 'haar');
结果有点相似,但似乎这不是正确的方法。我想让我困惑的是这里使用的不同种类的系数(细节和近似),并且我不确定在哪里(以及如何)进行阈值处理是合适的。
我应该指出,小波对我来说是非常新的东西,因此任何指导将不胜感激。
编辑:应该注意的是,上面代码片段中的 threshold(c,100)
没有做更多的事情,只是将 c
视为单维向量,并且简单地将除前 100 个之外的所有内容归零一百个最大(绝对)值。
I have been doing some experimentations using wavelets on image data in both Mathematica and Matlab. I have identified some piece of code in Mathematica that seems do basically do what I want which looks as follows :
dwd = DiscreteWaveletTransform[imagedata, HaarWavelet[]];
thr = WaveletThreshold[dwd, {"LargestCoefficients", 100}, Automatic];
out = InverseWaveletTransform[thr];
The above performs wavelet thresholding by keeping only the 100 largest coefficients. What I would prefer however is Matlab code that does the same thing (or more or less the same thing).
I have been experimenting a bit with the Wavelet toolbox but without much success so far. The closest I seem to have come so far is by using wavedec2
. I have been tinkering a bit with something like this:
[c,s] = wavedec2(imagedata, level, 'haar');
c1 = threshold(c, 100) % a function that zeros everything but the 100 biggest coefficients in c.
out = waverec2(c1, s, 'haar');
The result is sort of similar but it doesn't seem like this is the right way to do it. I guess what confuses me are the different kinds of coefficients (detail and approximation) in play here and I'm not sure where (and how) it's appropriate to do the thresholding.
I should point out that wavelets are something very new to me and therefore any guidance would be greatly appreciated.
EDIT: It should be noted that threshold(c,100)
in the snippet above does nothing more then treat c
as a single dimensional vector and simply zeros everything but the top 100 hundred largest (absolute) values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论