//Digital Watermarking Using DWT and DCT In MATLAB

Digital Watermarking Using DWT and DCT In MATLAB

Abstract :

Now days due to advancement of technology it is difficult to protect creative  content and intellectual property. It is very easy to copy and modify digital media resulting in great loss in business. So the viable solution for this problem is  gital watermarking. Digital watermarking is a technique by which we embed copyright mark into digital content which is used to identify the  riginal creator and owner of  digital media. It is prominently used for tracing copyright infringements. In this paper technique based on 1-level discrete wavelet transform and discrete cosine transform are used for insertion and extraction of watermark in original image.

The digital watermarking is a technique of embedding any watermark image into cover image using some known algorithm depending upon the requirement in multimedia data to identify the owner of the document There are two common methods for watermarking: spatial domain and transform domain. In spatial domain pixels of an image are modified depending upon perceptual analysis of an image. But in transform domain some frequencies are selected and modified from their original values according to certain rules. The transform domain methods are more popular because watermark embedding is more robust in this domain as compared to spatial domain. It also provides more security and imperceptibility. In this project we propose the watermarking scheme based on DWT (discrete wavelet transform) which works in transform domain and DCT (discrete cosine transform) which works in spatial domain.

Introduction :

Watermarking process is a sub-discipline of information hiding. Internet is the biggest network now days. This demanded maintenance of security and privacy of data available on internet. Watermarking approach is used to make sure of the    rotection of the data. Watermarking is the pattern of bits inserted into a digital image, audio or video file, specifying the copyright information of data, such as author, owner etc. The actual bits representing watermark are scattered in data file in such a manner they cannot be detected or tampered by unauthorized person. Perceptual transparency, security, capacity, robustness, verifiability and payload of watermark are the important aspects or requirements for design of watermarking systems.

Digital watermarking technology is an emerging field in computer science, cryptography, signal processing and  ommunications. Digital watermarking is intended by its developers as the solution to the need to provide value added protection on top of data
encryption and scrambling for content protection. In general, a digital watermark is a technique which allows an individual to add hidden copyright information or other verification message to digital media. Watermarking is the process that embeds data called a watermark or digital signature or tag or label into a multimedia object such that watermark can be detected or  tracted later to make an assertion about the object. Digital watermark is a sequence of information containing the owners copyright for the multimedia data. It is inserted visibly or invisibly into another image so that it can be extracted later as an evidence of authentic owner. Usage of digital image watermarking technique has grown significantly to protect the copyright ownership of digital multimedia data as it is very much prone to unlawful and unauthorized replication, reproduction and manipulation. The watermark may be a logo, label or a random sequence. A typical good watermarking scheme should aim at keeping the embedded watermark very robust under malicious attack in real and spectral domain. Incorporation of the watermark in the image could be performed in various ways.

Discrete Wavelet Transform (DWT) :

Wavelet Transform is a modern technique frequently used in digital image processing, compression, watermarking etc. The transforms are based on small waves, called wavelet, of varying frequency and limited duration. Wavelet transform is a time domain localized analysis method with the windows size fixed and form convertible. There is quite good time differentiated rate in high frequency part of signals DWT transformed. Also there is quite good frequency differentiated rate in its  low frequency part. It can distill the information from signal effectively. The basic idea of discrete wavelet transform(DWT) in image process is to multi-differentiated decompose the image into sub-image of different spatial domain and independent frequency district. Then transform the coefficient of sub-image. After the original image has been DWT transformed, it is decomposed into 4 frequency districts which is one low-frequency district(LL) and three high-frequency districts(LH,HL,HH).

Discrete Cosine Transform (DCT) :

Discrete Cosine Transform is related to DFT in a sense that it transforms a time domain signal into its frequency components. The DCT however only uses the real parts of the DFT coefficients. In terms of property, the DCT has a strong energy compaction property and most of the signal in formation tends to be concentrated in a few low-frequency components of the DCT. The JPEG compression technique utilizes this property to separate and remove in significant high frequency components in images.

Algorithm to embed watermark using (DWT) :

The algorithm to embed a watermark in the original image is summarized as follows:1. Decompose the original image into four levels (thirteen sub-bands).
2. Any binary image with approximately equal number of 0s and 1s is utilized as a watermark image.
3. Map 0– 1 and 1– +1 to generate a pseudo-random binary sequence containing either 1 or +1.
4. The sub-band pairs (LH3, LH2), (HL3, HL2), and (HH3,HH2) at level 3 and level 2 are selected to calculate the changes made in these middle frequency sub-bands.
5. The pseudo-random binary sequence generated from the binary image is rearranged in three different ways to be embedded in the LH3, HL3, HH3, LH2, HL2, and HH2 using the pixel-wise computation.
6. Apply the IDWT (Inverse Discrete Wavelet Transform)using the newly updated sub- band values at the level 3 and level 2 to obtain the watermarked image.

Algorithm to embed a watermark using (DCT) :

The algorithm consists of the following steps:
1. The first step is the conversion of the scaled input image from the RGB color model to the grayscale color model.
2. An original gray-level image of size (NxN ) is divided in to n = (NxN) /(8×8) non-overlapped blocks (8×8) which are transformed to frequency domain by the DCT.The watermark bit stream is embedded into eight coefficients in lower band of
each block.
3. For the purpose of scattering watermark into the host image and prompting security, we use pseudo random system to generate a random position in watermarking algorithm. Obtain a random number, generated by pseudo random
system, which points to one of n blocks of host image.
4. Embed extracted the 8-bit watermarking data into the 8lower-band coefficients in the block pointed by previous step.
5. Apply inverse DCT (IDCT) into the 8 lower-band coefficients in the block to
obtain the watermarked image.

Alpha Blending Technique :

Alpha blending is the process of combining an image with a background to create the appearance of partial or full transparency. The formula of alpha blending used for watermarking embedding is:
Watermarked image= A*(LL1) + B*(WM1)
A, B= scaling factors for cover and watermark image respectively.
LL1=low frequency approximation of cover image
WM1= watermark image

The alpha blending formula used for watermark extraction is:
Recovered watermark = (WM – A*LL1)
WM=Watermarked image
A= scaling factor for cover image
LL1= Low frequency approximation component of cover image

MATLAB CODE : (DWT)

clc;
clear all;
close all;
%[fnamepname]=uigetfile('*.jpg','select the Cover Image');
%eval('imageinput=imread(fname)');
imageinput = imread('cameraman.tif');
%A=rgb2gray(imageinput);
A = imageinput;
P1=im2double(A);
P=imresize(P1,[2048 2048]);
Figure(1);
imshow(P);
title('cover image');
[LL,LH,HL,HH] = dwt2(P,'haar','d');
[LL1,LH1,HL1,HH1] = dwt2(LL,'haar','d');
[LL2,LH2,HL2,HH2] = dwt2(LL1,'haar','d');
imw2 = imread('Watermark.PNG');
imw=rgb2gray(imw2);
watermark=im2double(imw);
watermark=imresize(watermark,[2048 2048]);
Figure(3)
imshow(watermark);title('watermark image')
[L_L,L_H,H_L,H_H] = dwt2(watermark,'haar','d');
[L_L1,L_H1,H_L1,H_H1] = dwt2(L_L,'haar','d');
[L_L2,L_H2,H_L2,H_H2] = dwt2(L_L1,'haar','d');
Watermarkedimage=LL2+0.1*L_L2;
Watermarkedimage_level1= idwt2(Watermarkedimage,LH2,HL2,HH2,'haar');
Watermarkedimage_level2=idwt2(Watermarkedimage_level1,LH1,HL1,HH1,'haar');
Watermarkedimage_final=idwt2(Watermarkedimage_level2,LH,HL,HH,'haar');
Figure(5)
imshow(Watermarkedimage_final,'DisplayRange',[]), title('Watermarkedimage final')
[a b c d]=dwt2(Watermarkedimage_final,'haar','d');
[aa bb cc dd]=dwt2(a,'haar','d');
[aaabbb ccc ddd]=dwt2(aa,'haar','d');
recovered_image=aaa-LL2;
Figure(6)
imshow(recovered_image,[]);
title('extracted watermark')

pic1= P;
pic2= Watermarkedimage_final;
mse_cover=mse(pic1,pic2)
psnr_cover=psnr(pic1,pic2)

Watermarking Using DCT:

clc;clearall;closeall;
M=960;
N=120;
K=8;
I=zeros(M,M);
J=zeros(N,N);
Block=zeros(K,K);
I=imread('cameraman.tif');
%I=rgb2gray(I);
I=imresize(I,[960,960],'bicubic');
b=I;
Figure(1);
imshow(I);
title('original image');
J=imread('Watermark.PNG');
J=im2bw(J,0.4);
J=imresize(J,[120,120],'bicubic');
Figure(2);
imshow(J);
title('the original image');
for p=1:N
for q=1:N
x=(p-1)*K+1;
y=(q-1)*K+1;
Block=I(x:x+K-1,y:y+K- 1);
Block=dct2(Block);
if J(p,q)==0
a=-1;
else
a=1;
end
Block=Block*(1+a*0.3);
Block=idct2(Block);
I(x:x+K-1,y:y+K- 1)=Block;
end

end
Figure(3);W=J;
imshow(I);
title('watermark image');
A = I;
for p=1:N
for q=1:N
x=(p-1)*K+1;
y=(q-1)*K+1;
Block1=A(x:x+K-1,y:y+K- 1);
Block2=b(x:x+K-1,y:y+K- 1);
Block1=idct2(Block1);
Block2=idct2(Block2);
if Block1(1,1)==0
if Block1(1,1)~=0
a=(Block2(1,1)/Block1(1,1))-1;
if a<0
W(p,q)=0;
else
W(p,q)=1;
end
end
end
end
end
Figure(4);
imshow(W);
title('the extracted watermark image');
pic1= b;
pic2= I;
mse_cover=mse(pic1,pic2)
psnr_cover=psnr(pic1,pic2)

Outputs :

                     

Conclusion :

In this project, a digital image watermarking technique based on discrete wavelet transform and discrete cosine transform has been presented, where the method operates in the frequency domain embedding a pseudo-random sequence of real numbers in a selected set of DCT coefficients. And the watermark is added in select coefficients with significant image energy in the discrete wavelet transform domain in order to ensure non- erasability of the watermark. Experimental results demonstrate that the watermark is robust to most of the signal processing techniques and geometric distortions. Result suggest that the proposed scheme can be used to extract a good quality watermark for various image processing attacks like JPEG compression, average filtering, median filtering and cropping.