From: nor on
Hi,
I am trying to understand how does the ddencmp function in the wavelet toolbox work. The explanation given in the documentation says that "The threshold value is set to median(abs(c)) or to 0.05*max(abs(c)) if median(abs(c)) = 0". But this is n the condition that "Let c denote the detail coefficients at level 1 obtained from the decomposition of the signal or the image to be compressed, using db1".

I have tried to calculate the value of my threshold using both "median(abs(c))" and "0.05*max(abs(c)) ", but the values are not equal to thr value obtained by applying ddencmp to my signal.

I really appreciate any insight to this matter.

Thank you.
From: Wayne King on
"nor " <nanadilla(a)yahoo.com> wrote in message <hmqu1a$3lj$1(a)fred.mathworks.com>...
> Hi,
> I am trying to understand how does the ddencmp function in the wavelet toolbox work. The explanation given in the documentation says that "The threshold value is set to median(abs(c)) or to 0.05*max(abs(c)) if median(abs(c)) = 0". But this is n the condition that "Let c denote the detail coefficients at level 1 obtained from the decomposition of the signal or the image to be compressed, using db1".
>
> I have tried to calculate the value of my threshold using both "median(abs(c))" and "0.05*max(abs(c)) ", but the values are not equal to thr value obtained by applying ddencmp to my signal.
>
> I really appreciate any insight to this matter.
>
> Thank you.

Hi Nor,

It's saying the following:

reset(RandStream.getDefaultStream)
x = randn(1024,1);
[thr,sorh,keepapp] = ddencmp('cmp','wv',x);
% thr is 0.6522
[C,L] = wavedec(x,1,'db1');
det = detcoef(C,L,1);
median(abs(det))
% returns 0.6522

Note the threshold is equal to median(abs(det)) as the documentation suggests

If the median(abs(det)) had been zero, thr would have been set to

0.05*max(abs(det))

Hope that helps,
Wayne
From: nor on
"Wayne King" <wmkingty(a)gmail.com> wrote in message <hmqv7b$guu$1(a)fred.mathworks.com>...
> "nor " <nanadilla(a)yahoo.com> wrote in message <hmqu1a$3lj$1(a)fred.mathworks.com>...
> > Hi,
> > I am trying to understand how does the ddencmp function in the wavelet toolbox work. The explanation given in the documentation says that "The threshold value is set to median(abs(c)) or to 0.05*max(abs(c)) if median(abs(c)) = 0". But this is n the condition that "Let c denote the detail coefficients at level 1 obtained from the decomposition of the signal or the image to be compressed, using db1".
> >
> > I have tried to calculate the value of my threshold using both "median(abs(c))" and "0.05*max(abs(c)) ", but the values are not equal to thr value obtained by applying ddencmp to my signal.
> >
> > I really appreciate any insight to this matter.
> >
> > Thank you.
>
> Hi Nor,
>
> It's saying the following:
>
> reset(RandStream.getDefaultStream)
> x = randn(1024,1);
> [thr,sorh,keepapp] = ddencmp('cmp','wv',x);
> % thr is 0.6522
> [C,L] = wavedec(x,1,'db1');
> det = detcoef(C,L,1);
> median(abs(det))
> % returns 0.6522
>
> Note the threshold is equal to median(abs(det)) as the documentation suggests
>
> If the median(abs(det)) had been zero, thr would have been set to
>
> 0.05*max(abs(det))
>
> Hope that helps,
> Wayne

Hello Wayne,
Thank you for your help.
However, if I replace 'den' for 'cmp' in the ddencmp function, it does not give me the

same thr value as median(abs(det)) yield. The value given by 0.05*max(abs(det)) also

is not the same with thr generated by ddencmp('den','wv',x).

Does this mean the thr value here is calculated using (sqrt(2*log(n)) * s) ?

Where s=wnoisest(C,L,x). The noise in my signal is not white noise, thus I believe I

cannot use wnoisest.

One other thing, does the function ddencmp can only works for level 1

decomposition detail coefficients?

Thank you.

Nor.
From: Wayne King on
"nor " <nanadilla(a)yahoo.com> wrote in message <hna47v$3ji$1(a)fred.mathworks.com>...
> "Wayne King" <wmkingty(a)gmail.com> wrote in message <hmqv7b$guu$1(a)fred.mathworks.com>...
> > "nor " <nanadilla(a)yahoo.com> wrote in message <hmqu1a$3lj$1(a)fred.mathworks.com>...
> > > Hi,
> > > I am trying to understand how does the ddencmp function in the wavelet toolbox work. The explanation given in the documentation says that "The threshold value is set to median(abs(c)) or to 0.05*max(abs(c)) if median(abs(c)) = 0". But this is n the condition that "Let c denote the detail coefficients at level 1 obtained from the decomposition of the signal or the image to be compressed, using db1".
> > >
> > > I have tried to calculate the value of my threshold using both "median(abs(c))" and "0.05*max(abs(c)) ", but the values are not equal to thr value obtained by applying ddencmp to my signal.
> > >
> > > I really appreciate any insight to this matter.
> > >
> > > Thank you.
> >
> > Hi Nor,
> >
> > It's saying the following:
> >
> > reset(RandStream.getDefaultStream)
> > x = randn(1024,1);
> > [thr,sorh,keepapp] = ddencmp('cmp','wv',x);
> > % thr is 0.6522
> > [C,L] = wavedec(x,1,'db1');
> > det = detcoef(C,L,1);
> > median(abs(det))
> > % returns 0.6522
> >
> > Note the threshold is equal to median(abs(det)) as the documentation suggests
> >
> > If the median(abs(det)) had been zero, thr would have been set to
> >
> > 0.05*max(abs(det))
> >
> > Hope that helps,
> > Wayne
>
> Hello Wayne,
> Thank you for your help.
> However, if I replace 'den' for 'cmp' in the ddencmp function, it does not give me the
>
> same thr value as median(abs(det)) yield. The value given by 0.05*max(abs(det)) also
>
> is not the same with thr generated by ddencmp('den','wv',x).
>
> Does this mean the thr value here is calculated using (sqrt(2*log(n)) * s) ?
>
> Where s=wnoisest(C,L,x). The noise in my signal is not white noise, thus I believe I
>
> cannot use wnoisest.
>
> One other thing, does the function ddencmp can only works for level 1
>
> decomposition detail coefficients?
>
> Thank you.
>
> Nor.

Hi Nor, if you use the 'den' string, then the threshold is

median(abs(det1))*sqrt(2*log(N))/0.6745

For a wavelet decomposition

For example:

reset(RandStream.getDefaultStream)
x=randn(1024,1);
N=length(x);
[C,L]=wavedec(x,1,'db1');
d=detcoef(C,L,1);
[thr,sorh,keepapp] = ddencmp('den','wv',x);
Thresh=median(abs(d))*sqrt(2*log(N))/0.6745;

Compare Thresh and thr

Yes, it uses the universal threshold approach and it is obtaining a noise estimate based only the finest scale detail coefficients. If you wish to use different thresholding procedures (other than the universal threshold), and employ a level-dependent estimation of the noise, how about using wden

>>doc wden


Wayne
From: nor on

> Hi Nor, if you use the 'den' string, then the threshold is
>
> median(abs(det1))*sqrt(2*log(N))/0.6745
>
> For a wavelet decomposition
>
> For example:
>
> reset(RandStream.getDefaultStream)
> x=randn(1024,1);
> N=length(x);
> [C,L]=wavedec(x,1,'db1');
> d=detcoef(C,L,1);
> [thr,sorh,keepapp] = ddencmp('den','wv',x);
> Thresh=median(abs(d))*sqrt(2*log(N))/0.6745;
>
> Compare Thresh and thr
>
> Yes, it uses the universal threshold approach and it is obtaining a noise estimate based only the finest scale detail coefficients. If you wish to use different thresholding procedures (other than the universal threshold), and employ a level-dependent estimation of the noise, how about using wden
>
> >>doc wden
>
>
> Wayne

Hi Wayne,
Just to clarify, do you mean wden or wdencmp ?

I believe wden is for automatic denosing, in which I cannot specify it to do a level-dependent threshold. Am I right?