Digital Watermarking in Image Processing Using Python: Name Roll No. Registration No
Digital Watermarking in Image Processing Using Python: Name Roll No. Registration No
USING PYTHON
by
Bachelor of Technology
in
ELECTRONICS & COMMUNICATION ENGINEERING
......................................................... .........................................................
Shri Monirul Purkait Dr. Soham Sarkar
External Supervisor Professor , Dept. of ECE
Scientific Officer RCC Institute of Information Technology
VECC, Kolkata
for the partial fulfillment of the requirements for B.Tech degree in Electronics and
Technology, West Bengal is absolutely based on his own work under the
parts, have not been submitted to any other Institute or University for the award of
..........................................................
Dr. Abhishek Basu
Head of the Department (ECE)
RCC Institute of Information Technology
DECLARATION
We Do hereby declare that this submission is our own work conformed to
the norms and guidelines given in the Ethical Code of Conduct of the Institute and
that, to the best of our knowledge and belief, it contains no material previously
written by another neither person nor material (data, theoretical analysis, figures,
and text) which has been accepted for the award of any other degree or diploma of
.......................................................... ..........................................................
SINCHITA BANERJEE TRISHITA ROY
.......................................................... ..........................................................
T SRIYA AISHWARYA PRITI SINHA
Date: 10.05.2018
Place: Kolkata
CERTIFICATE of ACCEPTANCE
for B.Tech degree in Electronics and Communication Engineering from Maulana Abul
.……………………………………………………………………
.……………………………………..……………………………….
.……………………………………………………………………...
4. …………………………………….………………………………..
CONTENTS
ABSTRACT
LIST OF FIGURES
1.INTRODUCTION
1.3.WHAT IS AN IMAGE?.............................................................................................1.1
. .RELATIONSHIP BETWEEN A SIGNAL AND IMAGE………………………..…... .
. .HISTORY OF WATERMARKING……………………………………………………….. .
. .DIGITAL WATERMARKING…………………………………………………………..... .
2.4.SYSTEM DESIGN……………………………………..………………………………….... .
. .WATERMARKING RESULT……………………………………………………………..... .
. .DEWATERMARKING RESULT……………………………………………………………. .
5.CONCLUSIONS
6.REFERENCE
ABSTRACT
With the rapid growth and internet and networks techniques, multimedia data transforming
and sharing is common to many people. Multimedia data is easily copied and modified, so
Thus,digital watermarking has been used for copyright protection, finger protection,
watermark are images, music clips and digital video. The application of digital
watermarking to still images is concentrated here. The major technical challenge is to design
Introduction
Digital Image Processing (DIP) deals with manipulation of digital images through a digital
computer. It is a subfield of signals and systems but focuses particularly on images. DIP
The input of that system is a digital image and the system process that image using efficient
The digital image processing deals with developing a digital system that performs
An image is nothing more than a two dimensional signal. It is defined by the mathematical
function f(x,y) where x and y are the two coordinates horizontally and vertically. The value of
f(x,y) at any point is gives the pixel value at that point of an image.
Figure 1.2
The above figure is an example of digital image which is nothing but a two dimensional
Signal
In physical world, any quantity measurable through time over space or any higher
dimension can be taken as a signal. A signal is a mathematical function, and it conveys some
information.
A signal can be one dimensional or two dimensional or higher dimensional signal. One
dimensional signal is a signal that is measured over time. The common example is a voice
signal.
The two dimensional signals are those that are measured over some other physical
Relationship
Since anything that conveys information or broadcast a message in physical world between
two observers is a signal. That includes speech or (human voice) or an image as a signal.
Since when we speak , our voice is converted to a sound wave/signal and transformed with
respect to the time to person we are speaking to. Not only this , but the way a digital camera
works, as while acquiring an image from a digital camera involves transfer of a signal from
Since capturing an image from a camera is a physical process. The sunlight is used as a
source of energy. A sensor array is used for the acquisition of the image. So when the
sunlight falls upon the object, then the amount of light reflected by that object is sensed by
the sensors, and a continuous voltage signal is generated by the amount of sensed data. In
order to create a digital image, we need to convert this data into a digital form. This involves
sampling and quantization. The result of sampling and quantization results in an two
dimensional array or matrix of numbers which are nothing but a digital image.
before. The availability and efficiency of global computer networks for the communication
of digital information and data have enhanced the popularity of digital media. Hence,
unauthorized illegal access, diverse methods such as symmetric and asymmetric encryption
methods. However, encryption alone does not provide an adequate solution as it only
provides for robust delivery of the content. Once the content is decrypted, it is no longer
protected and the content may be illegally replicated or copied without any prevention.
Thus, piracy in the presence of internet and computers is a major concern.To deal with
piracy and counterfeiting of the multimedia data, digital watermarking technique has an
edge over the other available techniques. Thus, last decades gaining attention on
watermarking schemes.
CHAPTER 2
DIGITAL WATERMARKING
The term "Digital Watermark" was coined by Andrew Tirkel and Charles Osborne in
December 1992.
Two basic methods of information hiding are cryptography and steganography.The term
Cryptography is the study of methods of sending messages in distinct form so that only the
intended recipients can remove the disguise and read the message. The message we want to
send is called the plain text and disguised message is called ciphertext. The process of
converting a plain text to a cipher text is called enciphering or encryption, and the reverse
transmission of the data from the sender to receiver. However, after receipt and subsequent
decryption, the data is no longer protected and is in the clear.Watermarking techniques are
manufacturing.
Our ancients poured their half-stuff slurry of fiber and water on to mesh molds to collect the
fiber, then dispersed the slurry within deckle frames to add shape and uniformity, and
finally applied great pressure to expel the water and cohere the fiber. This process hasn’t
changed too much in 2000 years. One by-product of this process is the watermark ª the
technique of impressing into the paper a form of image, or text derived from the negative in
The digitization of our world has expanded our concept of watermarking to include
immaterial digital impressions for use in authenticating ownership claims and protecting
proprietary interests. However, in principle digital watermarks are like their paper
ancestors. They signify something about the token of a document or file in which they
inherit. Whether the product of paper press or discrete cosine transformations, watermarks
The digital watermarking or watermarking explains the ways and mechanisms to hide the
data and the data can be a number or text, in digital media, it may be a picture or video. The
watermarking is a message that can be embedded into the digital data like video, pictures,
and text and the embedded data can be extracted later. The steganography is also another
form of watermarking and in this, the messages are hidden in the content without making
the people to note its presence. The Indian currency is a good example of watermarking and
in the general watermarking procedure the genuine image undergoes the embedding
procedure along with the watermark and the output generated will be a watermarked
image.
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 extracted later to
make an assertion about the object. The object may be an image or audio or video.
● The watermark
Each owner has a unique watermark or an owner can also put different watermarks in
different objects the marking algorithm incorporates the watermark into the object. The
verification algorithm authenticates the object determining both the owner and the integrity
of the object.
ENCODING PROCESS:
Figure 2.1
Let us denote an image by I, a signature by S = { s , s , … } the watermarked image by I’. E is
an encoder function, it takes an image I and a signature S, and it generates a new image
DECODING PROCESS:
from the image. In this process, an additional image I can also be included which is often the
original and un-watermarked version of J. This is due to the fact that some encoding
schemes may make use of the original images in the watermarking process to provide extra
D (J, I) = S’
Extraction
Watermarke Image
Water
Figure 2.2
Depending on the way the watermark is inserted and depending on the nature of the
watermarking algorithm, the method used can involve very distinct approaches. In some
watermarking schemes, a watermark can be extracted in its exact form, a procedure we call
watermark extraction. In other cases, we can detect only whether a specific given
watermarking signal is present in an image, a procedure we call watermark detection. It
should be noted that watermark extraction can prove ownership whereas watermark
Visible watermark is a translucent overlaid into an image and is visible to the viewer. Visible
invisible watermark is embedded into the data in such a way that the changes made to the
pixel values are perceptually not noticed. Invisible watermark is used as evidence of
visible and invisible watermark. An invisible watermark is used as a backup for the visible
In spatial domain techniques, the watermark embedding is done on image pixels while in
frequency domain ater marking techniques the embedding is done after taking image
transforms. Generally frequency domain methods are more robust than spatial domain
● Non-blind
● Semi-blind
● Blind
Non-blind watermarking schemes require original image and secret key for watermark
detection whereas semi-blind schemes require secret key and watermark bit sequence for
have different concerns therefore, there is no set of properties that all watermarking systems
have to satisfy. This section highlights the common evaluation methods used for
Invisibility:
The best way to evaluate invisibility is to conduct subject tests where both original and
watermarked signals are presented to human subjects. However, due to the high volume of
test images, subject tests are usually impractical. The most common evaluation method is to
compute the peak signal-to-noise ratio (PSNR) between the host and watermarked signals.
and
where Im and Iw are the original and watermarked images, respectively, n is the total
number of pixels, and 255 refers to the highest possible image level in an 8-bit image. In
general, the higher the PSNR, the better the signal quality.
Effectiveness :
Digital watermarking systems have a dependence on the input signal. Effectiveness refers to
example, watermarking of a completely random signal is very difficult because of the lack of
redundancies.
Efficiency :
Efficiency refers to the embedding capacity. For images, it is usually expressed in bits of
information per pixel (bpp). A 512 x 512 image with 16 KB of embedded data has an
embedding capacity of 0.5 bpp. The desired size of the watermark is application dependent.
Robustness :
Robustness is one of the most commonly tested properties in digital watermarking systems.
before it reaches the detector. Robustness refers to the ability for the detector to detect the
Security One of the major goals of a digital watermarking system is to protect digital content
from illegal use and distribution. However, the protection is diminished if the attackers can
Watermarks and watermarking techniques can be divided into various categories in various
ways.
Watermarking techniques can be divided into four categories according to the type of
a) Image Watermarking
b) Video Watermarking
c) Audio Watermarking
d) Text Watermarking
According to Human Perception, the watermarking techniques can be divided into three
types
a) Visible Watermark
b) Invisible Watermark
c) Dual Watermark
Visible watermark is a translucent overlaid into an image and is visible to the viewer. Visible
invisible watermark is embedded into the data in such a way that the changes made to the
pixel values are perceptually not noticed. Invisible watermark is used as evidence of
visible and invisible watermark. An invisible watermark is used as a backup for the visible
watermark.
VISIBLE WATERMARK:
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 doesn’t prevent image being used for other purposes (e.g.
scholarly research).
2. 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
an individual who will make them available for free, this would deprive the owner
of licensing revenue.
digital images suspects one of his images has been edited and published without
payment of royalties. Here the detection of the seller’s watermark in the image is
captured with a digital camera for later inclusion in news articles. Here, it is the
desire of a news agency to verify that an image is true to the original capture and has
not been edited to falsify a scene. In this case, an invisible watermark is embedded at
capture time its presence at the time of publication is intended to indicate that the
this case, images (e.g. human fingerprints) have been scanned and stored in a digital
library the content owner desires the ability to detect any alteration of the images,
such as compression and transmission noise and some intentional such as cropping,
Many compression schemes like JPEG and MPEG can potentially degrade the data’s quality
● Geometric Distortions: Geometric distortions are specific to images and videos and
● D/A conversion
● A/D conversion
● Resampling
● Requantization
● Dithering distortion
● Recompression
● Color reduction
come together (collude) and like the differently watermarked copies to generate an
un-watermarked copy of the image (by averaging all the watermarked images).
collude to form a copy of watermarked image with the valid embedded watermark
● IBM attack: It should not be possible to produce a fake original that also performs as
well as the original and also results in the extraction of the watermark as claimed by
● Difficult to notice: The invisible watermarks should not be noticeable to the viewers
nor should the watermark degrade the quality of the content. Ideally, it should be
just noticeable difference (JND) is usually observed by comparing two signals, e.g.
common signal distortions as well as D/A and A/D conversions and loss
compression. Moreover, for images and video, it is important that the watermark
survive geometric distortions such as translation, scaling and cropping etc. It has
been argued that robustness can only be attained if watermark is placed perceptually
But it has been already mentioned that watermark should be imperceptible, which is
two conflicting requirements. It should be noted robustness actually comprises two separate
issues:
● whether or not the watermark is still present in the data after distortion and whether
It should also be noted that ability to embed robust watermarks in digital images does not
necessarily imply the ability to establish ownership, unless certain requirements are
resistant to such tampering. There are a number of possible ways this may be
achieved:
that constitutes the watermark is only known to sender and receiver, are inherently
more tamper resistant than public watermarks in which every body is free to decode
the watermark
the encoding, then it is highly desirable to make the encoder as complex as possible,
especially if the watermark is only to be applied once. However if decoders must run
in real time, then it is necessary for the decoding process to be simpler than
encoding.
the watermark after insertion. For example, in the case of digital video discs, a disc
may be watermarked to allow only a single copy. Once this copy has been made, it is
then necessary to alter the watermark on the original disc to prohibit further copies.
Changing a watermark can be accomplished either (a) removing the 1st watermark
and then adding a new one or (b) inserting a 2nd a watermark such that both are
● Scalability: It is well known that computer speeds are approximately doubling every
eighteen months, so that what looks computationally unreasonable today may very
decoder is scalable with each generation of computers. Thus for example, the first
reliable as next generation decoders that can afford to expend more computation to
The watermark should not need any interpretation as looking into the database of
● Universal: The same digital watermark should apply to all three media under
● Minimum alternation of pixels: While watermarking high quality image and art
3.1. INTRODUCTION
primary image such that the watermark is intentionally perceptible to a human observer
whereas in the case of invisible, the embedded image data that is not perceptible, but may be
Some of the desired characteristics of visible watermarks are listed below A visible
● The watermark should spread in a large and important area of the image in order to
● The watermark should be visible yet must not significantly obscure the image details
beneath it.
more costly and labor intensive than purchasing the image from the owner.
● The watermark should be applied automatically with little human intervention and
labor.
The steps for watermark insertion using Transparent Overlay using opencv are described
below.
1. Original image.
2. An image(watermark) containing what we want to overlay on top of the
first using some level of alpha transparency.
● This watermark is a PNG image with four channels: a Red channel, a Green channel,
a Blue channel, and an Alpha channel used to control the transparency of each of the
● Values in our alpha channel can range [0, 255], where a value of 255 is 100% opaque
● Once we actually overlay the watermark on our image, the watermark will be semi-
● Import required Python packages. We’ll be making use of the packages like
imutils,argparse,cv2,os,numpy.
● Parsing our required command line arguments we require three command line
● --watermark : Here we supply the path to the image we wish to use as the
watermark. We presume that (1) this image is a PNG image with alpha transparency
and (2) our watermark is smaller (in terms of both width and height) then all images
● --input : This is the path to our input directory of images we are going to watermark.
● --output : We then need to supply an output directory to store our watermarked
images.
● --alpha : The optional --alpha value controls the level of transparency of the
watermark. A value of 1.0 indicates that the watermark should be 100% opaque (i.e.,
not transparent). A value of 0.0 indicates that the watermark should be 100%
transparent.
● --correct : Finally, this switch is used to control whether or not we should preserve a
bug in how OpenCV handles alpha transparency.
● Now that we have parsed our command line arguments, we can load our watermark
image from disk
● The cv2.imread function loads our watermark image from disk using the
transparency channel of the PNG image (along with the standard Red, Green, and
Blue channels).
● The spatial dimensions (i.e., height and width) of the watermark image is taken.
● To ensure that each of the Red, Green, and Blue channels respected the alpha
● Start looping over each of the images in our --input directory. For each of these
images, we load it from disk and its width and height is taken.
● It’s important to understand that each image is represented as a NumPy array with
shape (h, w, 3), where the 3 is the number of channels in our image « one for each of
● However, since we are working with alpha transparency, we need to add a 4th
dimension to the image to store the alpha values. This alpha channel has the same
spatial dimensions as our original image and all values in the alpha channel are set to
255, indicating that the pixels are fully opaque and not transparent.
● Construct the overlay for our watermark. Again, the overlay has the exact same
function.
● The output image are taken and written to the --output directory.
# USAGE
#python watermark_dataset.py--watermark
import argparse
import cv2
import os
ap = argparse.ArgumentParser()
args = vars(ap.parse_args())
alpha=args["alpha"]
beta= 1-args["alpha"]
print("alpha" + str(alpha))
print("beta" + str(beta))
# load the watermark image, making sure we retain the 4th channel
# split the watermark into its respective Blue, Green, Red, and
# Alpha channels; then take the bitwise AND between all channels
if args["correct"] > 0:
(B, G, R, A) = cv2.split(watermark)
B = cv2.bitwise_and(B, B, mask=A)
G = cv2.bitwise_and(G, G, mask=A)
R = cv2.bitwise_and(R, R, mask=A)
image = cv2.imread(imagePath)
(h, w) = image.shape[:2]
# corner
overlay = np.zeros((h, w, 4), dtype="uint8")
output = image.copy()
p = os.path.sep.join((args["output"], filename))
cv2.imwrite(p, output)
3.5.
EXE
CUT
ION
AN
RES
ULT
Figure 3.1
● Import required Python packages. We’ll be making use of the packages like
imutils,numpy,argparse,cv2,os.
● Parsing our required command line arguments. We require three command line
● --watermark : Here we supply the path to the image we wish to use as the
watermark. We presume that (1) this image is a PNG image with alpha transparency
and (2) our watermark is smaller (in terms of both width and height) then all images
● --input : This is the path to our input directory of watermarked images we are going to
de watermark.
● --alpha : The optional --alpha value controls the level of transparency of the
watermark. A value of 1.0 indicates that the watermark should be 100% opaque (i.e.,
not transparent).
● --correct : Finally, this is used to control whether or not we should preserve a bug
in how OpenCV handles alpha transparency.
● The cv2.imread function loads our watermark image from disk using
transparency channel of the PNG image (along with the standard Red, Green, and
Blue channels).
● The spatial dimensions (i.e., height and width) of the watermark image is taken.
● To ensure that each of the Red, Green, and Blue channels respected the alpha
● Start looping over each of the images in our --input directory. For each of these
images, we load it from disk and its width and height is taken.
● It’s important to understand that each image is represented as a NumPy array with
shape (h, w, 3), where the 3 is the number of channels in our image « one for each of
● However, since we are working with alpha transparency, we need to add a 4th
dimension to the image to store the alpha values. This alpha channel has the same
spatial dimensions as our original image and all values in the alpha channel are set to
255, indicating that the pixels are fully opaque and not transparent.
● The overlay for our watermark is constructed. Again, the overlay has the exact same
● then take our output image and write it to the --output directory.
# USAGE
#python watermark_dataset.py --watermark
import numpy as np
import argparse
import cv2
import os
args = vars(ap.parse_args())
alpha= 1/(1-args["alpha"])
print("alpha" + str(alpha))
print("beta" + str(beta))
# load the watermark image, making sure we retain the 4th channel
# split the watermark into its respective Blue, Green, Red, and
# Alpha channels; then take the bitwise AND between all channels
if args["correct"] > 0:
(B, G, R, A) = cv2.split(watermark)
B = cv2.bitwise_and(B, B, mask=A)
G = cv2.bitwise_and(G, G, mask=A)
R = cv2.bitwise_and(R, R, mask=A)
image = cv2.imread(imagePath)
(h, w) = image.shape[:2]
# corner
output = image.copy()
cv2.addWeighted(output, alpha, overlay, beta, 0, output)
p = os.path.sep.join((args["output"], filename))
cv2.imwrite(p, output)
Figure 4.1
4.4. DEMARKING RESULT
CONCLUSIONS
algorithms for watermarking and dewater marking of image as part of the project. The
watermarking research is more exciting as it needs collective concepts from all the fields
along with Human Psychovisual analysis, Multimedia and Computer Graphics. The
watermark may be of visible or invisible type and each has got its own applications.
To maintain the security of the watermark, it should be embedded into randomly selected
regions in some domain of the watermark signal. By doing this, it is difficult to remove the
watermark.
REFERENCE
Techniques for Authentication, Security and Privacy Protection by Xin Cindy Guo
Chittaranjan Pradhan