Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Wavelet based watermarking

Subject: Wavelet based watermarking

From: Muhammad Awais

Date: 3 Oct, 2010 22:42:06

Message: 1 of 6

Hi!
It is first time I am working with wavelet based image processing and in particular with image watermarking. Say I take single level decomposition and I have HH HL LH and LL bands. In order to perform watermarking I have to add the watermark say Gaussian noise, to the coefficients of all bands except LL.
So is it right? that I will add Gaussian noise to the detailed coefficients obtained from
detcoef2();
and I should leave the approximate coefficients ----appcoef2(); ??
My Code is as follows

I = imread('lena.pgm');
alpha = 0.01;
[Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('db1');
[C,S]=wavedec2(I,1,Lo_D,Hi_D);
det_coff = C(65537:end);%% Detailed Coefficients
N = randn(1,length(det_coff));
coff_noise = det_coff + ((det_coff.^2).*N)*alpha;
C_new = [C(1:65536),coff_noise]; %% New Set of Coefficients
I_new = uint8(waverec2(C_new,S,Lo_D,Hi_D));%% Reconstructing
imshow(I_new);

Thank you for your help,
regards,
Muhammad Awais

Subject: Wavelet based watermarking

From: Wayne King

Date: 4 Oct, 2010 10:59:05

Message: 2 of 6

"Muhammad Awais" <innocent_awais222@yahoo.com> wrote in message <i8b0ru$sho$1@fred.mathworks.com>...
> Hi!
> It is first time I am working with wavelet based image processing and in particular with image watermarking. Say I take single level decomposition and I have HH HL LH and LL bands. In order to perform watermarking I have to add the watermark say Gaussian noise, to the coefficients of all bands except LL.
> So is it right? that I will add Gaussian noise to the detailed coefficients obtained from
> detcoef2();
> and I should leave the approximate coefficients ----appcoef2(); ??
> My Code is as follows
>
> I = imread('lena.pgm');
> alpha = 0.01;
> [Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('db1');
> [C,S]=wavedec2(I,1,Lo_D,Hi_D);
> det_coff = C(65537:end);%% Detailed Coefficients
> N = randn(1,length(det_coff));
> coff_noise = det_coff + ((det_coff.^2).*N)*alpha;
> C_new = [C(1:65536),coff_noise]; %% New Set of Coefficients
> I_new = uint8(waverec2(C_new,S,Lo_D,Hi_D));%% Reconstructing
> imshow(I_new);
>
> Thank you for your help,
> regards,
> Muhammad Awais

Hi Muhammad, There are many digital watermarking techniques with wavelets so I'm not sure which one you are trying to reproduce. I would caution you to look at a few things:

1.) Make sure your result is not perceptible.
2.) Are you sure you want to add noise to all the details? and also do you want to add the same noise (and not independent sources) to all details?
3.) You don't give us anyway of ascertaining how you determined the variance of the noise to add, or why you are only doing a level-1 decomposition and adding noise at that level. Again, if you are reproducing somebody's algorithm then point us to that algorithm.
4.) I believe you are correct to not mess with the approximation coefficients.

As far as your code goes, the only thing I see is that you want to use reconstruction (synthesis) filters in waverec2, not the analysis filters as you have used.

Wayne

Subject: Wavelet based watermarking

From: Muhammad Awais

Date: 4 Oct, 2010 14:09:05

Message: 3 of 6

Thank you very much Wayne.
Well I am trying to reproduce the algorithm in
Xiang Gen Xia, Charles G., 'Wavelet transform based watermark for digital images', OPTICS EXPRESS, Vol. 3, No. 12,7 December 1998.
it says:
"In the encoding part, we first decompose an image into several bands with a pyramid
structure as shown in Figs. 3-4 and then add a pseudo-random sequence (Gaussian
noise) to the largest coefficients which are not located in the lowest resolution, i.e., the corner at the left and top as follows. Let y[m; n] denote the DWT coecients, which are not located at the lowest frequency band, of an image x[n;m]. We add a Gaussian noise sequence N[m; n] with mean 0 and variance 1 to y[m; n]:
~y[m; n] = y[m; n] + y2[m; n]N[m; n];"
"We do not change the DWT coecients at the lowest resolution. Then, we take the two dimensional IDWT of the modified DWT coefficients ~y and the unchanged DWT coefficients at the lowest resolution"
This means whatever level of decomposition I select, I need to add noise as watermark (or any other watermark) to all the details i.e. all sub-bands accept those at the upper left corner (approx. coeff.)
In the paper it never says something that different noise or watermark should be added to different details (h,v,d).
A quite similar concept is found in
http://www.mathworks.com/matlabcentral/fx_files/3508/1/digital%20watermarking.pdf
Thank you,
regards
Awais.
> Hi Muhammad, There are many digital watermarking techniques with wavelets so I'm not sure which one you are trying to reproduce. I would caution you to look at a few things:
>
> 1.) Make sure your result is not perceptible.
> 2.) Are you sure you want to add noise to all the details? and also do you want to add the same noise (and not independent sources) to all details?
> 3.) You don't give us anyway of ascertaining how you determined the variance of the noise to add, or why you are only doing a level-1 decomposition and adding noise at that level. Again, if you are reproducing somebody's algorithm then point us to that algorithm.
> 4.) I believe you are correct to not mess with the approximation coefficients.
>
> As far as your code goes, the only thing I see is that you want to use reconstruction (synthesis) filters in waverec2, not the analysis filters as you have used.
>
> Wayne

Subject: Wavelet based watermarking

From: Wayne King

Date: 4 Oct, 2010 14:37:04

Message: 4 of 6

"Muhammad Awais" <innocent_awais222@yahoo.com> wrote in message <i8cn61$ma2$1@fred.mathworks.com>...
> Thank you very much Wayne.
> Well I am trying to reproduce the algorithm in
> Xiang Gen Xia, Charles G., 'Wavelet transform based watermark for digital images', OPTICS EXPRESS, Vol. 3, No. 12,7 December 1998.
> it says:
> "In the encoding part, we first decompose an image into several bands with a pyramid
> structure as shown in Figs. 3-4 and then add a pseudo-random sequence (Gaussian
> noise) to the largest coefficients which are not located in the lowest resolution, i.e., the corner at the left and top as follows. Let y[m; n] denote the DWT coecients, which are not located at the lowest frequency band, of an image x[n;m]. We add a Gaussian noise sequence N[m; n] with mean 0 and variance 1 to y[m; n]:
> ~y[m; n] = y[m; n] + y2[m; n]N[m; n];"
> "We do not change the DWT coecients at the lowest resolution. Then, we take the two dimensional IDWT of the modified DWT coefficients ~y and the unchanged DWT coefficients at the lowest resolution"
> This means whatever level of decomposition I select, I need to add noise as watermark (or any other watermark) to all the details i.e. all sub-bands accept those at the upper left corner (approx. coeff.)
> In the paper it never says something that different noise or watermark should be added to different details (h,v,d).
> A quite similar concept is found in
> http://www.mathworks.com/matlabcentral/fx_files/3508/1/digital%20watermarking.pdf
> Thank you,
> regards
> Awais.
> > Hi Muhammad, There are many digital watermarking techniques with wavelets so I'm not sure which one you are trying to reproduce. I would caution you to look at a few things:
> >
> > 1.) Make sure your result is not perceptible.
> > 2.) Are you sure you want to add noise to all the details? and also do you want to add the same noise (and not independent sources) to all details?
> > 3.) You don't give us anyway of ascertaining how you determined the variance of the noise to add, or why you are only doing a level-1 decomposition and adding noise at that level. Again, if you are reproducing somebody's algorithm then point us to that algorithm.
> > 4.) I believe you are correct to not mess with the approximation coefficients.
> >
> > As far as your code goes, the only thing I see is that you want to use reconstruction (synthesis) filters in waverec2, not the analysis filters as you have used.
> >
> > Wayne

Hi Muhammed, I looked at the paper at the mathworks.com link you included and I agree that you are implementing it as presented there. Just remember to use the synthesis filters at the reconstruction.

Wayne

Subject: Wavelet based watermarking

From: Muhammad Awais

Date: 4 Oct, 2010 15:35:08

Message: 5 of 6

Hi Wayne,
Thanks again, yes I have observed that I have made a mistake I should use the
 Lo_R and Hi_R filters for reconstruction as folllows. But I am worried about the results now as I can see clear distortion at the edges while the noise is not spread all over the image. If I increase the value of alpha this gets worse and only the edges get distorted. Is this because I am adding noise only to the directional (detailed coeff.). Any idea?
Thanks again,
regards,
Awais.

[Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('db1');
I_new = uint8(waverec2(C_new,S,Lo_R,Hi_R));
> Hi Muhammed, I looked at the paper at the mathworks.com link you included and I agree that you are implementing it as presented there. Just remember to use the synthesis filters at the reconstruction.
>
> Wayne

Subject: Wavelet based watermarking

From: Wayne King

Date: 5 Oct, 2010 07:27:04

Message: 6 of 6

"Muhammad Awais" <innocent_awais222@yahoo.com> wrote in message <i8cs7c$442$1@fred.mathworks.com>...
> Hi Wayne,
> Thanks again, yes I have observed that I have made a mistake I should use the
> Lo_R and Hi_R filters for reconstruction as folllows. But I am worried about the results now as I can see clear distortion at the edges while the noise is not spread all over the image. If I increase the value of alpha this gets worse and only the edges get distorted. Is this because I am adding noise only to the directional (detailed coeff.). Any idea?
> Thanks again,
> regards,
> Awais.
>
> [Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('db1');
> I_new = uint8(waverec2(C_new,S,Lo_R,Hi_R));
> > Hi Muhammed, I looked at the paper at the mathworks.com link you included and I agree that you are implementing it as presented there. Just remember to use the synthesis filters at the reconstruction.
> >
> > Wayne

Hi Awais, if you set the dwtmode() to 'per', or dwtmode('zpd') do you still see this problem?

Try:
dwtmode('per')

and then run your code.

Wayne

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us