Wavelet coefficient thresholding
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 simil开发者_JAVA百科ar 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.
精彩评论