Reversible Watermarking using DCT algorithm ABSTRACT A watermark embeds an imperceptible signal into data such as audio, video and image for variety of purposes like captioning and copyright control. We first outline the desired characteristics of watermarks. Previous work in digital watermarking is then reviewed. A reversible watermarking approach recovers the watermarked image to source image after extracting the embedded watermarks. This report represents a reversible image watermarking approach that works on quantized DCT coefficients. We also show visible watermarking that helps in protection of publicly available images. This report introduces basic concepts of digital watermarking. We also discuss about invisible watermarking technique where watermarked image is produces that is no different than the original image. We also discuss about DCT algorithm and various types of DCT. By adjusting the block DCT coefficients of image watermark is hidden. The report also discusses about the advantages and disadvantages of this watermarking technique with respect to other technique. Various applications of this reversible watermarking technique is also stated in the report. 1 Department of EXTC, BVCOE, Navi Mumbai
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Reversible Watermarking using DCT algorithm
ABSTRACT
A watermark embeds an imperceptible signal into data such as audio, video and image for variety of purposes like captioning and copyright control. We first outline the desired characteristics of watermarks. Previous work in digital watermarking is then reviewed. A reversible watermarking approach recovers the watermarked image to source image after extracting the embedded watermarks. This report represents a reversible image watermarking approach that works on quantized DCT coefficients. We also show visible watermarking that helps in protection of publicly available images. This report introduces basic concepts of digital watermarking. We also discuss about invisible watermarking technique where watermarked image is produces that is no different than the original image. We also discuss about DCT algorithm and various types of DCT. By adjusting the block DCT coefficients of image watermark is hidden. The report also discusses about the advantages and disadvantages of this watermarking technique with respect to other technique. Various applications of this reversible watermarking technique is also stated in the report.
1 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
CHAPTER 1
INTRODUCTION
Digital images are easily transmitted, modified and reproduced now days. Thus, how to protect an important image from malicious attack or from unauthorized usage is a very important issue. Recently watermarking is an important issue to overcome this image authentication problem for keeping important images safely. A watermarking image modifies an image by embedding some information in it. But this kind of watermarking is irreversible and the original image is lost and cannot be acquired back after extracting the watermark. However, some application needs to reconsider the original image from the watermarked image. Thus, reversible watermarking approaches are represented. In visible watermarking of images, the secondary image (watermarked image) is embedded in primary (host) image in such a way that the watermark is intentionally perceptible to human eye. Whereas in the case of invisible watermarking the embedded data is not visible but can be extracted or detected by the computer program. Currently digital watermarking techniques can be divided into two categories by embedding position- spatial domain and transform domain watermark. Spatial domain techniques were developed earlier and are easier to implement, but are limited in robustness, while transform domain techniques, which embed watermark in hosts transform domain, is more sophisticated and robust. With the development of digital watermarking, spatial techniques due to their weakness in robustness, are generally abandoned and frequency algorithm based on DCT and DWT are used.. To check the fragility of DCT watermark we embed the watermark in the high frequency domain. A fragile watermark is said to be fragile if it is not detected after slightest of modification. After watermarking the original image can be produced by using IDCT technique.
2 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
CHAPTER 2
LITERATURE REVIEW
2.1 BACKGROUND AND RELATED WORK
Digital watermarking is an extension of this concept in the digital world. It is a technique that
provides a solution to the longstanding problems faced with copyrighting digital data. Digital
watermarks are pieces of information added to digital data (audio, video, or still images) that can
be detected or extracted later to make an assertion about the data. This information can be textual
data about the author, its copyright, etc; or it can be an image itself.
Current main applications of watermarking include the following:
Copyright protection: The objective is to embed information about the
Source /owner of the digital media in order to prevent other parties from claiming the
ownership of the media.
Fingerprinting: The objective of fingerprinting is to convey information about the
recipient of the digital media (rather than the owner) in order to identify every single
distributed copy of the media. This concept is very similar to serial numbers of software
products.
Copy protection: Watermarking can be used to control data copying devices and
prevent them from copying the digital media in case the watermark embedded in the
media indicates that media is copy-protected.
Image authentication: The objective is to check the authenticity of the digital media.
This requires the detection of modifications to the data.
3 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
Following is a list of attacks against which watermarking system could be judged.
JPEG compression: JPEG is currently one of the most widely used compression
algorithms for images and any watermarking system should be resilient to some degree of
compression.
Geometric transformations:
Horizontal flip: Many images can be flipped without losing any value. Although
resilience to flipping is usually straightforward to implement only very few systems do
survive it.
Rotation: Small angle rotation, often in combination with cropping, does not usually
change the commercial value of the image but can make the watermark undetectable.
Rotations are used to realign horizontal features of an image and it is certainly the first
modification applied to an image after it has been scanned.
Cropping: In some cases, infringers are just interested by the “central" part of the
copyrighted material, moreover more and more Web sites use image segmentation, which
is the basis of the “Mosaic" attack. This is of course an extreme case of cropping.
Scaling: This happens when a printed image is scanned or when a high resolution digital
image is used for electronic applications such as Web publishing. This should not be
neglected as we move more and more toward Web publishing. Scaling can be divided
into two groups, uniform and non-uniform scaling. Under uniform scaling we understand
scaling which is the same in horizontal and vertical direction. Non-uniform scaling uses
different scaling factors in horizontal and vertical direction (change of aspect ratio). Very
often digital watermarking methods are resilient only to uniform scaling.
Deletion of lines or columns: This attack is very efficient against any straightforward
implementation of spread-spectrum techniques in the spatial Domain. Removing k
samples at regular intervals in a pseudo random sequence (hence shifting the next ones)
typically divides by k the amplitude of the cross correlation peak with the original
sequence.
4 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
Generalized geometrical transformations: A generalized geometrical transformation is
a combination of non-uniform scaling, rotation, and shearing.
Random geometric distortions (Stir Mark): Image-watermarking tools, which do not
survive them, should be considered unacceptably easy to break.
Geometric distortions with JPEG: Rotation and scaling alone are not enough they
should be also tested in combination with JPEG compression. Since most artists will first
apply the geometric transformation and then save the image in a compressed format. It
makes sense to test robustness of watermarking system to geometric transformation
followed by compression.. However experience from professionals shows that “quality
factors" down to 70% are reasonable. Artists seem to use JPEG extensively as well as
resizing.
2.2 EXISTING SYSTEM
Generally, larger amounts of data can be embedded in the spatial domain than in the frequency
domain. But hiding information in the frequency domain is more robust than in the spatial
domain. By using the Least Significant Bit (LSB) embedding method large amount of data can
be stored. The security system is very low in existing system, by using LSB embedding method
large data loss will occur.
LSB method is type of spatial domain. Spatial domain requires large amount of memory to store
image information than frequency domain.
So, existing system is not resist to attacks such as addition of noise, JPEG compression etc.
2.3 PROPOSED SYSTEM
In this system, Frequency Domain is used to embed a secret image into the cover image. The
fractal image compression is used to compress a secret image. The main advantage of this fractal
image compression is resolution independent. When zooming process is performed in the
original image, the quality of the original image has slight changes. After the compression is
over, the compressed image is encrypted by using DES method. Then the encrypted secret image
5 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
is hided into the cover image by using DCT process. The secret image is hidden behind the cover
image by using frequency domain. Because of this DCT based embedding method, no one can
steal the secret image. DCT system is used to provide good robustness.
DCT Process for Embedding :
In this system the encrypted file is given as the input for the embedding process. In the
embedding process, a cover image is taken for hiding the secret image. First the cover image is
segmented by using the Region based Segmentation method. In this Region merging the picture
is divided into 4/8 parts, if the resulting picture doesn’t meet a homogeneity criteria, it is further
divided. The next process is converting of the image signals into elementary frequency
coefficients by applying the DCT formula.
The DCT formula is applied in each row and column.
DCT Extraction Process:
The received image is divided into blocks of 8×8 pixels each and each block is transformed
independently. After each block is transformed independently and for each block a 64 DCT
coefficients is received. Following the embedding order is the embedding procedure, the
embedded DCT coefficients are selected out. In order to get the 3 hidden bits, an AND operation
is done on one of the selected DCT coefficients with the bit stream”00011100”.
2.4 EXISTING SYSTEM VS PROPOSED SYSTEM
1. Proposed system uses DCT which is in the frequency domain which ensures robustness
against JPEG compression.
2. As proposed system uses frequency domain compared with existing system ensures less
memory is required to store image information.
6 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
CHAPTER 3
Motivation
We are using reversible watermarking technique using DCT algorithm. This technique helps to get the image after the extraction of watermark which is exactly same as the original image before watermark was added to it. This technique restores the original image and also helps us to identify, if any tampering was done to the original image. This is a very simple and efficient technique done to protect digital data from external attack and to protect its copyright.
Why DCT is preferred over other techniques?
When watermarked image is affected with scaling and translation attack, individual high frequency coefficients and middle frequency coefficients of DCT domain image changes, but overall addition sum (Si) do not change. Hence we got 100% similar watermark and recovered image. This method gives less PSNR than any other method as well as it gives less embedding capacity. But no any other method is suitable for geometric attack. Mean Squared Error (MSE) is defines as the square of difference in the pixel values between corresponding pixels of the two images. For DCT the MSE increases with increase in pixel size whereas for DWT the MSE first decreases with increase in window size and then increases. Compression increases with increase in window size in DCT and in DWT the compression decreases with increase in window size.
DCT is used in transformation for JPEG standard. DCT performs efficiently at medium bit rates. DWT is used as basis of transformation in JPEG 2000 standard; it provides high quality compression at lower bit rates .DWT provides lower quality than JPEG at low compression rate. It requires longer compression time as compared to DCT. The use of larger DWT basis functions or wavelet filters produces blurring near the edges in the images.
7 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
CHAPTER 4
Problem Definition
Since the rise in digitalization there have been rise in copyright infringement and various kind of attacks on data. We require digital techniques to protect our data from such attacks and to protect its copyright. Our aim is to provide an easy and efficient technique to serve this purpose. The technique we are using is called reversible watermarking using DCT algorithm.
Objectives
1) The primary objective is to convert an image into frequency domain.2) The watermark is then inserted in the image using DCT algorithm.3) The watermark inserted can be visible or invisible as per the choice.4) Then the watermarked image is compared with the original image.5) Watermark is again extracted from the image using IDCT.6) Image recovered after extraction of watermark is compared with the original image.
8 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
CHAPTER 5
REQUIREMENT ANALYSIS
The working of watermarking system can be showed to the user with the help of interfaces. So,
system have some graphical user interfaces to interact with the user.
5.1 FUNCTIONAL REQUIREMENTS :
Insertion module: This module insert digital watermark in cover image.
Extraction module: This module allow to extract inserted watermark from secret image.
5.2 NON FUNCTIONAL REQUIREMENTS :
Accessibility: Since the system would be developed as PC client application, this will
able to access only single user at a time.
Availability: User can access the system by using executable file or shortcut.
Accuracy: It is required to have over 90% accuracy rate.
Response Time: Response Time will depend upon insertion and extraction module.
5.3 RESOURCE REQUIREMENTS:
HARDWARE DETAILS
Processor: PC with minimum requirement of Pentium 2 processor
Disk Space: Minimum 20MB
RAM: Minimum 512 MB of RAM
SOFTWARE DETAILS
Operating System: Windows XP, VISTA, 7, 8.
Developing Tool: MATLAB 7.0, 8.0, 9.0, 11a, 13b
9 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
Why MATLAB?
MATLAB provides a comprehensive set of reference-standard algorithms and graphical tools for
image processing, analysis, visualization, and algorithm development. You can restore noisy or
3) The use of larger DWT basis function or wavelet filters produces blurring and ringing noise
near edge regions in images or video frames.
2) Cost of computing is less than DWT.
7.3 DCT Based Watermarking:
In this method we are going to perform DCT operation on original image. After applying DCT
and watermark will be embed into the DCT applied image. This method is also known as blind
watermarking as we can retrieve back original image from watermarked image.
Advantages:
1) It has higher compression efficiency than DFT.
2) Cost of computing is less than DWT.
16 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
CHAPTER 8
DISCRETE COSINE TRANSFORM (DCT)
A discrete cosine transform (DCT) expresses a sequence of finitely many data points in terms
of a sum of cosine functions oscillating at different frequencies.
DCTs are important to numerous applications in science and engineering, from lossy
compression of audio (e.g. MP3) and Images (e.g. IPEG) (where small high-frequency
components can be discarded), to spectral methods for the numerical solution of partial
differential equations.
In the last decade, Discrete Cosine Transform (DCT) has emerged as the de-facto image transformation in most visual systems. DCT has been widely deployed by modern video coding standards, for example, MPEG, JVT etc.
8.1 Types of DCT:
There are four types of DCT viz DCT-I, DCT-II, DCT-III & DCT-IV.
1. DCT-I : DCT-I is equivalent to DFT 2N-2 real numbers with even symmetry, however it should be noted that DCT-I is not defined for N less than 2 whereas all other DCT forms are defined for every positive value of N
2. DCT-II : DCT-II is the most commonly used transform, and is often simply referred to as the Discrete Cosine Transform
3. DCT-III : because it is the inverse of the DCT-II, it is simply referred as Inverse DCT
4. DCT-IV : DCT-IV is called Modified DCT where the data from different transforms are overlapped
In principle, there are actually four additional types of discrete cosine transform (Mariucci, 1994), corresponding essentially to real-even DFTs of logically odd order, which have factors of N =±½ in the denominators of the cosine arguments.
Equivalently, DCTs of type’s I-IV imply boundaries that are even/odd around either a data point for both boundaries or halfway between two data points for both boundaries. DCTs of types V-VIII imply boundaries that even/odd around a data point for one boundary and halfway between
17 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
two data points for the other boundary. However, these variants seem to be rarely used in practice. One reason, perhaps, is that FFT algorithms for odd-length DFTs are generally more complicated than FFT algorithms for even-length DFTs
8.2 The DCT EQUATION:
The DCT equation (Eq.1) computes the i, jth entry of the DCT of an image
p (x, y) is the x ,yth element of the image represented by the matrix p. N is the size of the block
that the DCT is done on. The equation calculates one entry (i, j th) of the transformed image
from the pixel values of the original image matrix. For the standard 8x8 block that JPEG
compression uses, N equals 8 and x and y range from 0 to 7.
Some properties of the DCT which are of particular value to image processing applications
a) Decorrelation:The principle advantage of image transformation is the removal of redundancy between neighboring pixels. This leads to uncorrelated transform coefficients which can be coded independently. It can be inferred that DCT exhibits excellent decorrelation properties.
b) Energy Compaction:Efficacy of a transformation scheme can be directly gauged by its ability to pack input data into as few coefficients as possible. This allows the quantizer to discard coefficients with relatively small amplitudes without introducing visual distortion in the reconstructed image. DCT exhibits excellent energy compaction for highly correlated images c) Symmetry:This is an extremely useful property since it implies that the transformation matrix can be recomputed offline and then applied to the image thereby providing orders of magnitude improvement in computation efficiency.
19 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
8.4 DCT Implementation on an image
(Fig 8.4.a-Implementation of DCT)[1]
20 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
CHAPTER 9
PROJECT DESIGN
9.1 METHODOLOGY:
We are using the waterfall model.
Sometimes called the classic life cycle or the waterfall model, the linear sequential model
suggests a systematic, sequential approach to software development that begins at the system
level and progresses through analysis, design, coding, testing, and support. After a conventional
engineering cycle, the linear sequential model encompasses the following activities:
Fig 9.1.A: Waterfall Model
21 Department of EXTC, BVCOE, Navi Mumbai
Preliminary Investigation
Requirement Analysis
System Design
Code Generation
Testing
Reversible Watermarking using DCT algorithm
System/information engineering and modelling:
Because software is always part of a larger system, work begins by establishing requirements for
all system elements and then allocating some subset of these requirements to software. This
system view is essential when software must interact with other elements such as hardware,
people, and databases. System engineering and analysis encompass requirements gathering at the
system level with a small amount of top level design and analysis. Phases included are described
below.
Software requirements analysis:
The requirements gathering process is intensified and focused specifically on software.
To understand the nature of the program(s) to be built, the software engineer ("analyst")
must understand the information domain for the software, as well as required function,
behaviour, performance and interface. Requirements for both the system and the software
are documented and reviewed with the customer. In this phase, various ideas and
concepts related to watermarking techniques are reviewed
Design:
Software design is actually a multistep process that focuses on four distinct attributes of a
program: data structure, software architecture, interface representations, and procedural
(algorithmic) detail. The design process translates requirements into a representation of
the software that can be assessed for quality before coding begins. Like requirements, the
design is documented and becomes part of the software configuration. In design phase,
overall watermarking system is described with the help of data flow diagrams as show
below.
22 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
DATA FLOW DIAGRAM:
LEVEL 0 DFD:
DFD just gives the idea about the how the system will look likes.
LEVEL 1 DFD:
Cover Image
Secret Image
Secret Image
23 Department of EXTC, BVCOE, Navi Mumbai
Original Image Display
Stage 1
Embedding
Watermarked Image (W’)
Stage 2
Extraction
Watermarking System
Reversible Watermarking using DCT algorithm
Level 1 DFD gives the overall working of system. First the cover image and secret
image are given to embedding system to produce watermarked image. This watermarked
image is then displayed,
From This watermarked image, watermark is extracted which compared with the inserted
watermark.
9.2 PROCESS DESCRIPTION:
1) ORIGINAL IMAGE:
Suppose that an image with the size of M×N (suppose that M and N both are the integral times of
eight) we want to watermarked. Then we first divide this image into blocks of 8×8 pixels, and
then the total number of blocks is defined as L, which equals (M×N) /64. Suppose that Dire
presents the ith (i=1, 2… L) block.
2) DCT TRANSFORM:
Using the DCT equation, DCT coefficient of each block is calculated and are represented by Di
Visible watermarks can be used in following cases:
* Visible watermarking for enhanced copyright protection.
In such situations, where images are made available through Internet and the content owner is concerned that the images will be used commercially (e.g. imprinting coffee mugs) without payment of royalties. Here the content owner desires an ownership mark, that is visually apparent, but which does not prevent image being used for other purposes (e.g. scholarly research).
* Visible watermarking used to indicate ownership originals.
In this case images are made available through the Internet and the content owner desires to indicate the ownership of the underlying materials (library manuscript), so an observer might be encouraged to patronize the institutions that own the material.
26 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
CHAPTER 10
IMPLEMENTATION PLAN
In Digital Image watermarking project, test will be performed to see if the watermark satisfies
the desired properties explained in chapter 1.
Since a watermark is merely a sequence of pseudo-random numbers, error free detection may be
possible by using linear block codes. With the exception of most watermarking schemes do not
employ error-correction. This project will attempt to implement a new watermarking method
using error-correction techniques.
In implementing this, we will have to learn and create the processes to add a watermark and
extract a watermark from digital images.
Image processing and other computations will be handled by MATLAB. Furthermore,
this project seeks to determine if the error-correcting watermark scheme will hold any
advantages over traditional watermarking methods.
Architectural Design
Data Design
Coding
Testing
Report Generation
Maintenance
Architectural Design
Architectural design represents the structure of data and program components that are required to
build a mobile-based system. It considers the architectural style that the system will take, the
structure and properties of the components that comprise the system, and the interrelationships
that occur among all architectural components of a system.
27 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
Data Design
This stage will include the basic design as well as the flow of information .The DFDs that have
been implemented in the earlier stage needs to be materialized within this stage. This stage will
also include good user interface design that would enable the customer to use multiple tags
which will increase user friendliness of the software.
Coding
A comprehensive coding standard encompasses all aspects of code construction using
MATLAB. Complete source code should enable us to get desired results.
Testing
This phase should accomplish a variety of things such as testing of various modules within the
project. This is a high priority task as we may come across certain error that needs to be resolved
in time.
Report Generation
This stage will include various reports that need to be generated which will be utilized for
documentation purpose.
Maintenance
Maintenance plan will enable us to check the compatibility of the application with various
operating systems. Once the application deployed on the PC if there exists any error that needs to
be sorted out.
CHAPTER 11
28 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
ALGORITHM
Watermark Embedding
1) Original images are divided into blocks of 8×8 Pixels.
2) On each block DCT is applied.
3) Set of high frequency coefficients called GPi is calculated.
4) Intervals called [T1, T2] of Si are obtained, and define V= (T1+T2)/2.
5) Binary sequence of watermark is produced i.e. WI=1/0.
6) If Wi =0, keep GPi as it is.
7) If Wi≠0 A] If V≤Si≤T2, then each element of GPiis added by val1, which equals (T2-V)/Num, so we have T2≤Si≤2T2-V.
B] If T1≤Si<V, then each element in GPi is subtracted by val2, which equals (V-T1)/Num, so we have 2T1-V≤Si<T1.
8) All the blocks are applied IDCT to get watermarked image.
Watermark Extracting
1) Watermarked image is divided into blocks of 8x8 pixels, and then each block is applied DCT.
2) Achieve Si of each block.
3) IfT2 ≤Si≤2T2-V, then we have Wi*=1. Each element in GPi is subtracted by val1, by which the watermarks are reversed.
4) If 2T1-V≤Si<T1, then we still have Wi*=1. Each element in GPi is added by val2, by which the watermarks are reversed.
5) Otherwise, we have Wi*=0.
6) All the blocks are applied IDCT to get original image.
INVISIBLE WATERMARK EMBEDDING CODES:
29 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
function varargout = GUI1(varargin)global wimg;global oimg;global watermarked_image_int; gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @GUI1_OpeningFcn, ... 'gui_OutputFcn', @GUI1_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:});end% End initialization code function GUI1_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to GUI1 (see VARARGIN) % Choose default command line output for GUI1handles.output = hObject; % Update handles structureguidata(hObject, handles); % UIWAIT makes GUI1 wait for user response (see UIRESUME)% uiwait(handles.figure1); % --- Outputs from this function are returned to the command line.function varargout = GUI1_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structurevarargout{1} = handles.output; % --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global wimg;global oimg;
30 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
[ans,pathname]=uigetfile( ...{'*.*'... }, ... 'Select an IMAGE'); if isequal(ans,0);warndlg('ACTION CANCELLED',' ');end tryoimg=imread([pathname ans]); oimg=imresize(oimg,[256 256]); save aa oimg;handles.currentdata=oimg;axes(handles.axes1)imshow(oimg)guidata(hObject,handles);catchwarndlg('INCORRECT FILE FORMAT',' ') end % --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global wimg;global oimg; [ans,pathname]=uigetfile( ...{'*.bmp'... }, ... 'Select an WATERMARK'); if isequal(ans,0);warndlg('ACTION CANCELLED',' ');end trywimg=imread([pathname ans]); wimg=imresize(wimg,[32 32]);handles.currentdata=wimg;axes(handles.axes2)imshow(wimg)guidata(hObject,handles);catchwarndlg('INCORRECT FILE FORMAT',' ') end % --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
31 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
global wimg; global oimg; global watermarked_image_int;
k=50; % set minimum coeff difference blocksize=8;% set the size of the block in cover to be used for each bit in watermark % read in the cover objectfile_name=oimg; cover_object=double(oimg); % determine size of cover imageMc=size(cover_object,1); %HeightNc=size(cover_object,2); %Width % determine maximum message size based on cover object, and blocksizemax_message=Mc*Nc/(blocksize^2);message=double(wimg); Mm=size(message,1); %HeightNm=size(message,2); %Width % reshape the message to a vectormessage=reshape(message,Mm*Nm,1);message=message(1:max_message);message_pad(1:length(message))=message; % generate shell of watermarked imagewatermarked_image=cover_object; % process the image in blocks% encodes such that (5,2) > (4,3) when message(kk)=0% and that (5,2) < (4,3) when message(kk)=1x=1;y=1;for (kk = 1:length(message_pad)) % transform block using DCT dct_block=dct2(cover_object(y:y+blocksize-1,x:x+blocksize-1)); % if message bit is black, (5,2) > (4,3) if (message_pad(kk) == 0) % if (5,2) < (4,3) then we need to swap them if (dct_block(5,2) < dct_block(4,3)) temp=dct_block(4,3); dct_block(4,3)=dct_block(5,2); dct_block(5,2)=temp; end % if message bit is white, (5,2) < (4,3) elseif (message_pad(kk) == 1)
32 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
% if (5,2) > (4,3) then we need to swap them if (dct_block(5,2) >= dct_block(4,3)) temp=dct_block(4,3); dct_block(4,3)=dct_block(5,2); dct_block(5,2)=temp; end end % now we adjust the two values such that their difference >= k if dct_block(5,2) > dct_block(4,3) if dct_block(5,2) - dct_block(4,3) < k dct_block(5,2)=dct_block(5,2)+(k/2); dct_block(4,3)=dct_block(4,3)-(k/2); end else if dct_block(4,3) - dct_block(5,2) < k dct_block(4,3)=dct_block(4,3)+(k/2); dct_block(5,2)=dct_block(5,2)-(k/2); end end % transform block back into spatial domain watermarked_image(y:y+blocksize-1,x:x+blocksize-1)=idct2(dct_block); % move on to next block. if (x+blocksize) >= Nc x=1; y=y+blocksize; else x=x+blocksize; endend % convert to uint8 and write the watermarked image out to a filewatermarked_image_int=uint8(watermarked_image); axes(handles.axes3)imshow(watermarked_image_int)guidata(hObject,handles); GUI2;
INVISIBLE WATERMARK RECOVERY CODES:
function varargout = GUI2(varargin)global wimg;global oimg;global watermarked_image_int;% GUI2 M-file for GUI2.fig% GUI2, by itself, creates a new GUI2 or raises the existing% singleton*.
33 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
%% H = GUI2 returns the handle to a new GUI2 or the handle to% the existing singleton*.%% GUI2('CALLBACK',hObject,eventData,handles,...) calls the local% function named CALLBACK in GUI2.M with the given input arguments.%% GUI2('Property','Value',...) creates a new GUI2 or raises the% existing singleton*. Starting from the left, property value pairs are% applied to the GUI before GUI2_OpeningFcn gets called. An% unrecognized property name or invalid value makes property application% stop. All inputs are passed to GUI2_OpeningFcn via varargin.%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one% instance to run (singleton)".%% See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help GUI2 % Last Modified by GUIDE v2.5 09-Apr-2014 14:10:43 % Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @GUI2_OpeningFcn, ... 'gui_OutputFcn', @GUI2_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT % --- Executes just before GUI2 is made visible.function GUI2_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% varargin command line arguments to GUI2 (see VARARGIN) % Choose default command line output for GUI2handles.output = hObject; % Update handles structureguidata(hObject, handles); % UIWAIT makes GUI2 wait for user response (see UIRESUME)
34 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
% uiwait(handles.figure1); % --- Outputs from this function are returned to the command line.function varargout = GUI2_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structurevarargout{1} = handles.output; % --- Executes on button press in pushbutton1.function pushbutton1_Callback(hObject, eventdata, handles)% hObject handle to pushbutton1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global watermarked_image_int;axes(handles.axes1)imshow(watermarked_image_int)guidata(hObject,handles);% --- Executes on button press in pushbutton2.function pushbutton2_Callback(hObject, eventdata, handles)% hObject handle to pushbutton2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)
global watermarked_image_int;blocksize=8; % set the size of the block in cover to be used for each bit in watermarkwatermarked_image=watermarked_image_int;% read in the watermarked object % determine size of watermarked imageMw=size(watermarked_image,1); %HeightNw=size(watermarked_image,2); %Width % determine maximum message size based on cover object, and blocksizemax_message=Mw*Nw/(blocksize^2); % process the image in blocksx=1;y=1;for (kk = 1:max_message) % transform block using DCT dct_block=dct2(watermarked_image(y:y+blocksize-1,x:x+blocksize-1)); % if dct_block(5,2) > dct_block(4,3) then message(kk)=0 % otherwise message(kk)=1 if dct_block(5,2) > dct_block(4,3) message_vector(kk)=0; else
35 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
message_vector(kk)=1; end % move on to next block. if (x+blocksize) >= Nw x=1; y=y+blocksize; else x=x+blocksize; endend % reshape the embeded messagemessage=reshape(message_vector(1:1024),32,32);axes(handles.axes2)imshow(message)guidata(hObject,handles); % --- Executes on button press in pushbutton3.function pushbutton3_Callback(hObject, eventdata, handles)% hObject handle to pushbutton3 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)close(gcbf); % --- Executes on button press in pushbutton4.function pushbutton4_Callback(hObject, eventdata, handles)% hObject handle to pushbutton4 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)global watermarked_image_int;load aa oimg; [psnr mse]=psnrr(oimg,watermarked_image_int);set(handles.edit1,'String',mse);set(handles.edit2,'String',psnr); function edit1_Callback(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit1 as text% str2double(get(hObject,'String')) returns contents of edit1 as a double % --- Executes during object creation, after setting all properties.function edit1_CreateFcn(hObject, eventdata, handles)% hObject handle to edit1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.
36 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end function edit2_Callback(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA) % Hints: get(hObject,'String') returns contents of edit2 as text% str2double(get(hObject,'String')) returns contents of edit2 as a double % --- Executes during object creation, after setting all properties.function edit2_CreateFcn(hObject, eventdata, handles)% hObject handle to edit2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called % Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end
Using the Invisible Watermarking codes we also get the PSNR and the MSE value of the images used for the watermarking .Now in order to get the efficiency and accuracy of invisible watermarking technique, we implement the visible watermarking codes and compare the results of both. So below given codes are implementing the visible watermarking technique on the same images which were taken in the previous technique.
save a file_name;% file_name='beach.jpg';cover_object=double(imread(file_name));Mc=size(cover_object,1);Nc=size(cover_object,2);[f p]=uigetfile('*.*','Select watermark');file_name=strcat(p,f);%file_name='watermark.bmp';message=double(imread(file_name));Mm=size(message,1);Nm=size(message,2);[ca,ch,cv,cd]=dwt2(cover_object,'haar');cal=ca; for i=1:Mm for j=1:Nm if(message(i,j)==0) cal(i,j)=ca(i,j)+50; end end endwatermarked_image=idwt2(cal,ch,cv,cd,'haar');watermarked_image_round=round(watermarked_image);watermarked_image_uint8=uint8(watermarked_image_round);imshow(watermarked_image_uint8,[]);figure;imshow(watermarked_image_uint8,[]);title('watermarked image');imwrite(watermarked_image_uint8,'dwt_watermarked.bmp','bmp');
if(watermarkR(k,h)~=0) watermark(k,h)=0; end end end figure(2)imshow(watermark,[]);title('Recovered watermark');imwrite(watermark,'watermark_R.bmp','bmp');[psnr mse]=psnrr(imread(file_name),imread('dwt_watermarked.bmp'))
PSNR CODES:
function [psn mse] = psnrr(x,p)si=size(x);m=si(1);n=si(2);x=double(x);p=double(p);mse=0;for i=1:m for j=1:n mse=mse+(x(i,j)-p(i,j))^2; endendmse=mse/(m*n);psn=10*log10((255^2)/mse);
CHAPTER 12
RESULTS
39 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
Fig 12.a Lena
Fig 12.b Beach
40 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
Fig 12.c baboon
Fig 12.d Jersey
Fig 12.e Sample
41 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
INVISIBLE WATERMARKING RESULTS IN TERMS OF PSNR AND MSE:
IMAGE WATERMARK MSE PSNR
Lena W 28.1652 33.6337
Beach W 28.074 33.6478
Baboon W 46.3062 31.4744
Jersey W 25.8055 34.0137
Sample W 25.4328 34.0769
VISIBLE WATERMARKING RESULTS IN TERMS OF PSNR AND MSE:
IMAGE WATERMARK MSE PSNR
Lena W 41.7413 31.9251
Beach W 68.2267 29.7912
Baboon W 41.7413 31.9251
Jersey W 55.6546 30.6758
Sample W 36.5599 32.5008
42 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
CHAPTER 13
APPLICATIONS
1) Copyright Protection:-
Through this we can prevent copying of digital images. In this use, a copy device
retrieves the watermark from the signal before making a copy; the device makes a
decision whether to copy or not, depending on the contents of the watermark.
2) Identity Cards:-
. The identity number "123456789" is written in clear text on the card and hidden as a
digital watermark in the identity photo. Therefore switching or manipulating the identity
photo will be detected.
(Fig 12.1-Example of hidden digital watermark)
3) In medical and military fields:-
Important Images can be send using digital watermarks.
43 Department of EXTC, BVCOE, Navi Mumbai
Reversible Watermarking using DCT algorithm
BIBLIOGRAPHY
1) A Reversible and Fragile Watermarking Algorithm Based on DCT, 2009 International Conference on Artificial Intelligence and Computational Intelligence.
Yi Du, School of Computer and Information, Shanghai Second Polytechnic University, Shanghai, China.
Vidyasagar M. Potdar, Song Han, Elizabeth Chang A Survey of Digital Image Watermarking Techniques School of Information Systems, Curtin University of Technology, Perth, Western Australia
4) International Journal of Engineering and Scientific Research Volume 2
Anitha S
5)Ingemar J. Cox, Matthew L. Miller, Jeffrey A. Bloom, Jessica Fridrich and TonKalker, “Digital Watermarking and Steganography" (Second Edition), Morgan Kaufmann, 2008
6) Digital Image Processing, 3rd edition, Rafael C .Gonzalez and Richard E. Woods.
7) Image compression and DCT, Ken Cabeen and Peter Gent.