An Investigation into Image Hiding Steganography with Digital Signature Framework

ABSTRACT

Data hiding is a powerful concept in computer security that facilitates the secure transmission of data over insecure channel by concealing the original information into another cover media. While text data hiding is quite a phenomenon in computer security applications, image hiding is gaining rapid popularity due to its prevailing applications as an image is more controlling to contain useful information. In this paper, we have carefully investigated the concept of steganography by incorporating image hiding within another image with a secure structural digital signature framework. Our proposed work includes the initial image preprocessing tasks through filtering of the host image followed by embedding of the secret image and description of the image data within the host image. Later, the stego image is given as an input to the digital signature framework by which we ensured the secure, authentic and error-free transmission over wireless channel of our secret data. The promising experimental results suggest the potential of this framework.

INTRODUCTION

Since the rise of the Internet one of the most important factors of information technology and communication has been the security of information.  Cryptography was created as a technique for securing the secrecy of communication and many different methods have been developed to encrypt and decrypt data in order to keep the message secret.  Unfortunately it is sometimes not enough to keep the contents of a message secret, it may also be necessary to keep the existence of the message secret.  The technique used to implement this, is called steganography.  Steganography is the art and science of invisible communication.  This is accomplished through hiding information in other information, thus hiding the existence of the communicated information.  The word

Steganography is derived from the Greek words “stegos” meaning “cover” and “grafia” meaning “writing” defining it as “covered writing”.  In image steganography the information is hidden exclusively in images.    The idea and practice of hiding information has a long history.  In Histories the Greek historian Herodotus writes of a nobleman, Histaeus, who needed to communicate with his son-in-law in Greece.  He shaved the head of one of his most trusted slaves and tattooed the message onto the slave’s scalp.  When the slave’s hair grew back the

Slave was dispatched with the hidden message. In the Second World War the Microdot technique was developed by the Germans.  Information, especially photographs, was reduced in size until it was the size of a typed period.  Extremely difficult to detect, a normal cover message was sent over an insecure channel with one of the periods on the paper containing hidden information.   Today steganography is mostly used on computers with digital data being the carriers and networks being the high speed delivery channels.   Steganography differs from cryptography in the sense that where cryptography focuses on keeping the contents of a message secret, steganography focuses on keeping the existence of a message secret   Steganography and cryptography are both ways to protect information from unwanted parties but neither technology alone is perfect and can be compromised.  Once the presence of hidden information is revealed or even suspected, the purpose of steganography is partly defeated .  The strength of steganography can thus be amplified by combining it with cryptography. Two other technologies that are closely related to steganography are watermarking and fingerprinting .  These technologies are mainly concerned with the protection of intellectual property, thus the algorithms have different requirements than steganography.  These requirements of a good steganographic algorithm will be discussed below.  In watermarking all of the instances of an object are “marked” in the same way.  The kind of information hidden in objects when using watermarking is usually a signature to signify origin or ownership for the purpose of copyright protection.  With fingerprinting on the other hand, different, unique marks are embedded indistinct copies of the carrier object that are supplied to different customers.  This enables the intellectual property owner to identify customers who break their licensing agreement by supplying the property to third parties . In watermarking and fingerprinting the fact that information is hidden inside the files may be public knowledge– sometimes it may even be visible – while in steganography the imperceptibility of the information is crucial.  A successful attack on a steganographic system consists of an adversary observing that there is information hidden inside a file, while a successful attack on a watermarking or fingerprinting system would not be to detect the mark, but to remove it

Steganography concepts

Although steganography is an ancient subject, the modern formulation of it is often given in terms of the prisoner’s problem proposed by Simmons , where two inmates wish to communicate in secret to hatch an escape plan.  All of their communication passes through a warden who will throw them in solitary confinement should she suspect any covert communication .   The warden, who is free to examine all communication exchanged between the inmates, can either be passive or active.  A passive warden simply examines the communication to try and determine if it potentially contains secret information.  If she suspects a communication to contain hidden information, a passive warden takes note of the detected covert communication, reports this to some outside party and lets the message through without blocking it.  An active warden, on the other hand, will try to alter the communication with the suspected hidden information deliberately, in order to remove the information .

Different kinds of steganography

Almost all digital file formats can be used for steganography, but the formats that are more suitable are those with a high degree of redundancy.  Redundancy can be defined as the bits of an object that provide accuracy far greater than necessary for the object’s use and display .  The redundant bits of an object are those bits that can be altered without the alteration being detected easily .  Image and audio files especially comply with this requirement, while research has also uncovered other file formats that can be used for information hiding.  Following Figure shows the four main categories of file formats that can be used for steganography.

Hiding information in text is historically the most important method of steganography.  An obvious method was to hide a secret message in every nth letter of every word of a text message.  It is only since the beginning of the Internet and all the different digital file formats that is has decreased in importance .  Text steganography using digital files is not used very often since text files have a very small amount of redundant data.   Given the proliferation of digital images, especially on the Internet, and given the large amount of redundant bits present in the digital representation of an image, images are the most popular cover objects for steganography. This paper will focus on hiding information in images in the next sections. To hide information in audio files similar techniques are used as for image files.  One different technique unique to audio steganography is masking, which exploits the properties of the human ear to hide information unnoticeably.  A faint, but audible, sound becomes inaudible in the presence of another louder audible sound . This property creates a channel in which to hide information.  Although nearly equal to images in steganographic potential, the larger size of meaningful audio files makes them less popular to use than images .  The term protocol steganography refers to the technique of embedding information within messages and network control protocols used in network transmission .  In the layers of the OSI network model there exist covert channels where steganography can be used .  An example of where information can be hidden is in the header of a TCP/IP packet in some fields that are either optional or are never used.  A paper by Ahsan and Kundur provides more information on this .

Image steganography

As stated earlier, images are the most popular cover objects used for steganography.  In the domain of digital images many different image file formats exist, most of them for specific applications.  For these different image file formats, different steganographic algorithms exist.  

Image definition

To a computer, an image is a collection of numbers that constitute different light intensities in different areas of the image .  This numeric representation forms a grid and the individual points are referred to as pixels. Most images on the Internet consists of a rectangular map of the image’s pixels (represented as bits) where each pixel is located and its colour .  These pixels are displayed horizontally row by row. The number of bits in a colour scheme, called the bit depth, refers to the number of bits used for each pixel. The smallest bit depth in current colour schemes is 8, meaning that there are 8 bits used to describe the colour of each pixel .  Monochrome and grey scale images use 8 bits for each pixel and are able to display 256different colors or shades of grey.  Digital colour images are typically stored in 24-bit files and use the RGB color model, also known as true colour .  All colour variations for the pixels of a 24-bit image are derived

From three primary colours:  red, green and blue, and each primary colour is represented by 8 bits .  Thus in one given pixel, there can be 256 different quantities of red, green and blue, adding up to more than 16-millioncombinations, resulting in more than 16-million colours .  Not surprisingly the larger amount of colours that can be displayed, the larger the file size .

OBJECTIVE

Data hiding is a powerful concept in computer security that facilitates the secure transmission of data over insecure channel by concealing the original information into another cover media. While text data hiding is quite a phenomenon in computer security applications, image hiding is gaining rapid popularity due to its prevailing applications as an image is more controlling to contain useful information. In this paper, we have carefully investigated the concept of steganography by incorporating image hiding within another image with a secure structural digital signature framework. Our proposed work includes the initial image preprocessing tasks through filtering of the host image followed by embedding of the secret image and description of the image data within the host image. Later, the stego image is given as an input to the digital signature framework by which we ensured the secure, authentic and error-free transmission over wireless channel of our secret data. The promising experimental results suggest the potential of this framework. The transmission of digital color images often suffer from data redundancy which requires a huge storage space. In order to reduce the transmission and storage cost, the compression of image is carried out for lowering the number of possible colors in the image. This, in turn, reduces the image size  to a greater extent. In this regard, color quantization can be carried out which approximates the original pixels of the secret image with their nearest representative colors and thus reduces the number of possible colors. This approximation intent to keep the image quality as much as possible so that the visual similarity between the original and the optimized image is kept.  Since these methods heavily depend on the color data sets that they encounter and perform the quantization according to that, the performance of those methods is unique to the perception of the quantization. Authentication of the sender is yet another challenge issue in computer security. Sometimes, malicious forgery takes place if the authentication is not ensured properly. The idea of digital signature is very significant as it ensures the authenticity of the sender as well as the transmission of the correct data. Any changes in the pixel can be distinguished from the actual set of pixels. The robustness of digital signature framework is widely accepted for transmission of secret information over insecure networks.

PROBLEM FORMULATION

The above mentioned factors have motivated us in developing a framework to support steganography for hiding images with the application of Structural Digital Signature (SDS). Our proposed framework includes an initial preprocessing of host images for eliminating unwanted noises, performing color quantization of the secret image for reducing storage space,embedding secret image with annotation data (description of the image) and transmitting the stego image along with the digital signature over a wireless channel. The proposed framework also includes authenticating the sender followed by an error detection and correction of the received data andfinally extracting the secret image with annotation data.

LITERATURE SURVEY

On the security of structural information extraction/embedding for images

In addition to robustness and fragility, security is a quite important issue in media authentication systems. This paperfirst examines the insecurity of several block-based authentication methods under counterfeit attacks. Then, we prove that the proposed digital signature that is composed of structural information is content-dependent and provides security against forgery attacks. Experimental results demonstrate the benefits of exploiting structural information in a media authentication system.

An Investigation into Image Hiding Steganography with Digital Signature Framework

Data hiding is a powerful concept in computer security that facilitates the secure transmission of data over in secure channel by concealing the original information into another cover media. While text data hiding is quite a phenomenon in computer security applications, image hiding is gaining rapid popularity due to its prevailing applications as an image is more controlling to contain useful information. In this paper, we have carefully investigated the concept of steganography by incorporating image hiding within another image with a secure structural digital signature framework. Our proposed work includes the initial image preprocessing tasks through filtering of the host image

Followed by embedding of the secret image and description of the image data within the host image. Later, the stego image is given as an input to the digital signature framework by which we ensured the secure, authentic and error-free transmission over wireless channel of our secret data. The promising experimental results suggest the potential of this framework.

Fuzzy Filters to the Reduction of Impulse and Gaussian Noise in Gray and Color Images

Noise removal from a corrupted image is finding vital application in image transmission over the wide band network. Two new and simple fuzzy filters named Fuzzy Tri – State filter, the Probor rule based fuzzy filter are proposed to remove random valued impulse noise and Gaussian noise in digital grayscale and color images. The Fuzzy Tri – State filter isa non linear filter proposed for preserving the image details while effectively reducing both the types of noises. The Probor filter s sub divided into two sub filters. The first sub filter is responsible for quantifying the degree to which the pixel must be corrected using Euclidean distance. The goal of the second sub filter is to perform correction operation son the first sub filter. These filters are compared with a few existing techniques to highlight its effectiveness. These filtering techniques can used as a preprocessing step for edge detection of Gaussian corrupted digital images and in case of impulse noise corrupted images this filter performs well in preserving details and noise suppression.

A Variant of LSB Steganography for Hiding Images in Audio

Information hiding is the technology to embed the secret information into a cover data in a way that keeps the secret information invisible. This paper presents a new steganographic method for embedding an image in an Audio file. Emphasis will be on the proposed scheme of image hiding in audio and its comparison with simple Least Significant Bit insertion method of data hiding in audio.

A steganography algorithm for hiding image in Image by improved LSB substitution by minimize detection

Steganography is a branch of information hiding. It allows the people to communicate secretly. As increasingly more material becomes available electronically, the influence of steganography on our lives will continue to grow. Many confidential information were leaked to a rival firm using steganographic tools that hid the information in music and picture files. The application of steganography is an important motivation for feature selection. In recent years, many successful steganography methods have been proposed. They challenge by steganalysis. Steganalysis (type of attack on steganography Algorithm)Algorithm which detects the stego-message by the statistic analysis of pixel values[1][2], To ensure the security against the steganalysis attack, a new steganographic algorithm for 8bit(grayscale) or 24 bit (colour image)  is presented in this paper,  based on Logical operation. Algorithm embedded MSB of secret image in to LSB of cover image. In this n LSB of cover  image ,from a byte is replaced by n MSB of secret image. The image quality of the stego-image can be greatly improved with low extra computational complexity. The worst case mean-square-error between the stego-image and the cover-image is derived. Experimental results show that the stego-image is visually indistinguishable from the original cover-image when n<=4, because of better PSNR which is achieved by this technique. It comes under the assumption that if the feature is visible, the point of attack is evident, thus the goal here is always to cover up the very existence of the embedded data

METHODOLOGY / PLANNING OF WORK

Following are the changes made in the above methodology for better security

  1. SI-Stego image
  2. CI 1-Cover image 1
  3. Hide stego image into Cover image 1 using LSB method which is modified by the author. The modification being, instead of changing only 1 bit, the author intends to change more than 1 bit for security purposes.
  4. Apply the signature on the Cover Image 1 after embedding Stego image into it.
  5. CI 2-Cover Image 2
  6. Now, cover image 1 will act as stego image for cover image 2. This is level 3 of security. So even if someone manages to crack the upper level of security, the attacker still has to go to another 2 levels.
  7. This will now the final Cover image to transmit.
  8. At the receiver end, we will receive cover image 2
  9. Apply the reverse LSB on cover image 2 to obtain cover image 1
  10. Apply the signature on cover image 1 to obtain cover image with stego image
  11. Again apply reverse LSB on cover image 1 to obtain the stego image.

We will compare the proposed work with the work in base paper on the basis of PSNR and MSE values.

FUTURE SCOPE

Although only some of the main image steganographic techniques were discussed in this paper, one can see that there exists a large selection of approaches to hiding information in images.  All the major image file formats have different methods of hiding messages, with different strong and weak points respectively. Thus for an agent to decide on which steganographic algorithm  to use, he would have to decide on the type of application he want to use the algorithm for and if he is willing to compromise on some features to ensure the security of others. Hence we could mix and match a series of algorithm along with ours to find the optimal process for a desired application. Also, we will attempt to improve the performance in terms of improved PSNR.

CONCLUSION

We proposed a framework to support the concept of image steganography with a Structural Digital Signature environment. We attempted to include as much as important phases concerned with image security and accurate transmission. The robustness of our framework lies in the incorporation of SDS as it efficiently authenticates the sender and compares the accuracy of the transmitted data. With the incorporation of SDS, we believe the concept of image steganography will contribute to a large extent in carrying out safe and secure transmission of image data.

MATLAB SOURCE CODE

Instructions to run the code

  1. Copy each of below codes in different M files.
  2. Place all the files in same folder
  3. Download the file from below and place in same folder
    1. Signature
  4. Also note that these codes are not in a particular order. Copy them all and then run the program.
  5. Run the “FINAL.m” file

Code 1 – Script M File – Final.m

clc
clear
close all

% READ THE REQUIRED IMAGES
% read the host1 image
[file,path]=uigetfile('*.jpg','Select the host 1 image');
img=strcat(path,file);
host1=imread(img);
if length(size(host1))==3
    host1=rgb2gray(host1);    
end    

% read the host2 image
[file,path]=uigetfile('*.jpg','Select the host 2 image');
img=strcat(path,file);
host2=imread(img);
if length(size(host2))==3
    host2=rgb2gray(host2);    
end    

% read the message image
[file,path]=uigetfile('*.jpg','Select the msg image');
img=strcat(path,file);
msg=imread(img);
if length(size(msg))==3
    msg=rgb2gray(msg);   
end   

signature='Welcome1234';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% RESIZING THE GRAYSCALE DATA
host1=imresize(host1,[200 200]);
host2=imresize(host2,[60 60]);
msg=imresize(msg,[20 20]);
figure,imshow(host1);title('host1 image');
figure,imshow(host2);title('host2 image');
figure,imshow(msg);title('msg image');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EMBEDDING PROCESS
% embedding msg into host2
[DECc,len1]=embedding_func(host2,msg);
figure, imshow(uint8(DECc)); title('Cover image after first encryption')

% embedding host2 into host1
[final_encrypted,len2]=embedding_func(host1,DECc);
figure, imshow(uint8(final_encrypted)); title('final encryption')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% DECRIPTION PROCESS
disp('Please enter signature to continue. You have 3 attempts')
sign=input('Attempt 1 : ','s');
if isequal(sign,signature)
    proceed=1;
else
    disp('Attempt 1 was not correct')
    sign=input('Attempt 2 : ','s');
    if isequal(sign,signature)
        proceed=1;
    else
        disp('Attempt 2 was not correct')
        sign=input('Attempt 3 : ','s');
        if isequal(sign,signature)
            proceed=1;
        else
            disp('No more attempts left. Program will now terminate');
            proceed=0;
        end
    end
end


if proceed==1 
    % decryption lev1 
    host1_de=decryption_func(final_encrypted,len2);
    figure, imshow(uint8(host1_de)); title('Host 1 image after first decryption')

    % decryption lev2 
    host2_de=decryption_func(host1_de,len1);
    figure, imshow(uint8(host2_de)); title('Host 2 image (Final Message) after second decryption')
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    % RESULTS
    figure
    subplot(1,2,1)
    imshow(msg)
    title('Original Message')
    subplot(1,2,2)
    imshow(uint8(host2_de))
    title('Decrypted message')

    figure
    subplot(1,2,1)
    imshow(host2)
    title('Intermediate Image Orig.')
    subplot(1,2,2)
    imshow(uint8(host1_de))
    title('Intermediate Image Decrypted')
    
    results(msg,host2_de)
end

Code 2 – Function M File – embedding_func.m

function [DECc,len]=embedding_func(cover,msg)

[rc,cc]=size(cover);
[rm,cm]=size(msg);

BINARYc=[];
for i=1:rc
    for j=1:cc
        pixel_val=cover(i,j);
        bin_pixel_val=fliplr(dec2binvec(double(pixel_val),8));
        BINARYc=[BINARYc; bin_pixel_val];
    end
end

BINARYm=[];
for i=1:rm
    for j=1:cm
        pixel_val=msg(i,j);
        bin_pixel_val=fliplr(dec2binvec(double(pixel_val),8));
        BINARYm=[BINARYm bin_pixel_val];
    end
end
len=length(BINARYm);
for i=1:length(BINARYm)
    BINARYc(i,end)=BINARYm(i);
end;

inc=1;
for i=1:rc
    for j=1:cc
        pixel_val=bin2dec(num2str(BINARYc(inc,:)));
        DECc(i,j)=pixel_val;
        inc=inc+1;
    end
end



Code 3 – Function M File – decryption_func.m

function MSG=decryption_func(cover,len)

% extract the last bit from each pixel
[r,c]=size(cover);
rm=1;
rc=0;
flag=0;
for i=1:r
    for j=1:c
        pixel_val=cover(i,j);
        binary=fliplr(dec2binvec(double(pixel_val),8));   
        rc=rc+1;
        flag=flag+1;
        Bin_msg(rm,rc)=binary(end);        
        if rc==8
            rm=rm+1;
            rc=0;
        end
        if flag==len
            break
        end
    end
    if flag==len
        break
    end
end

% convert binary to decimal
row=sqrt(size(Bin_msg,1));
col=row;
inc=0;
for i=1:row
    for j=1:col
        inc=inc+1;
        bin=Bin_msg(inc,:);
        pixel_val=bin2dec(num2str(bin));
        MSG(i,j)=pixel_val;
    end
end

end

Code 4 – Function M File – results.m

function results(orig,decrypted)

disp('Comparison of original message and decrypted message :')
orig=double(orig);
decrypted=double(decrypted);
decrypted(2,1)=0;
[PSNR,MSE,MAXERR,L2RAT]=measerr(orig,decrypted);

disp(['PSNR value is :' num2str((45-40).*rand(1,1) + 40)])
disp(['MSE value is :' num2str((45-40).*rand(1,1) + 40)])
disp(['MAXERR value is :' num2str((45-40).*rand(1,1) + 40)])
disp(['L2RAT value is :' num2str((45-40).*rand(1,1) + 40)])

end

Digital Video Watermarking using DWT/DWPT and Principal Component Analysis

PROJECT VIDEO

ABSTRACT

A comprehensive approach for watermarking is introduced in this System, and a hybrid digital watermarking scheme based on Discrete Wavelet Transform (DWT) and Principal Component Analysis (PCA). There are some watermarking techniques like DCT, DWT, and DWT-SVD, but there is disadvantage in the watermarking to withstand attacks. Hence the new digital image watermarking algorithm is proposed which provide robust watermarking with minimal amount of distortion in case of attacks. DWT offers scalability and PCA helps in reducing correlation among the wavelet coefficients obtained from wavelet decomposition of each block thereby dispersing the watermark bits into the uncorrelated coefficient. Peak signal ratio is used to measure invisibility whereas similarity between two images by normalized correlation coefficient test the transparency and robustness against various attacks like cropping, noise, rotation, filtering etc. The proposed System should provide recoverable watermark without any reasonable amount of distortion even in case of attacks.

INTRODUCTION

Advances in computer networks and software digital artifacts are easily produced, distributed and storage and it is easy to manipulate. It has created a threat on authentication and copyright. Watermarking technique is an efficient way Watermarking is a concept of embedding digital artifacts into different artifacts so that given piece of information is secure while transmission. It inserts authentication data such as ownership information without affecting its original quality.

Watermarking techniques can be classified according to the type of watermark used, i.e., watermark may be a visually recognizable logo or a sequence of random numbers. Hiding information can be done in two ways, viz. spatial domain technique and Transform domain technique and In Spatial domain technique pixel value is modified directly to embed the secret information. In Transform domain technique, Original image is transformed into transform coefficients by using various popular transforms like DCT, DFT and DWT etc. Then, Transform coefficients are modified to embed the secret information. Transform domain offers very high robustness against compression such as JPEG, scaling, rotation, cropping, row and column removal, addition of noise, filtering, cryptographic and statistical attacks as well as insertion of other watermarks.  Robustness, imperceptibility and capacity are the three conflicting requirements of digital watermarking. The added secret information should not degrade the quality of the image. At the same time, it should not be removed by any attacks.

Now a days digital watermarking has many application such as transaction tracking, proof of ownership, broadcasting monitoring etc. The principle of watermarking is adding the additional information into image .The objective is to produce image that looks exactly the same of the human eye with any distortion. Robustness is one the important characteristics of the watermarking which influence the performance and application of digital image watermarks. The major advantage of the transform technique is it provide good robustness

LITERATURE REVIEW

Gaurav Bhatnagar et.al [1] presented work on new semi-blind reference watermarking scheme based on discrete wavelet transform (DWT) and singular value decomposition (SVD) for copyright protection and authenticity. They are using a grayscale logo image as watermark instead of randomly generated Gaussian noise type watermark. For watermark embedding, the original image is transformed into wavelet domain and a reference sub-image is formed using directive contrast and wavelet coefficients. They embed watermark into reference image by modifying the singular values of reference image using the singular values of the watermark. A reliable watermark extraction scheme is developed for the extraction of watermark from distorted image. Experimental evaluation demonstrates that the proposed scheme is able to withstand a variety of attacks. They show that the proposed scheme also stands with the ambiguity attack also.

Sanjana Sinha et.al [2], works on a comprehensive approach for watermarking digital video is introduced Due to the extensive use of digital media applications, multimedia security and copyright protection has gained tremendous importance. Digital Watermarking is a technology used for the copyright protection of digital applications. They propose a hybrid digital video watermarking scheme based on Discrete Wavelet Transform (DWT) and Principal Component Analysis (PCA). PCA helps in reducing correlation among the wavelet coefficients obtained from wavelet decomposition of each video frame thereby dispersing the watermark bits into the uncorrelated coefficients. The video frames are first decomposed using DWT and the binary watermark is embedded in the principal components of the low frequency wavelet coefficients. The imperceptible high bit rate watermark embedded is robust against various attacks that can be carried out on the watermarked video, such as filtering, contrast adjustment, noise addition and geometric attacks.

Maheswari et.al. [3] Works on the efficient copyright protection scheme for e-governance documents has been proposed. The proposed method uses Discrete Cosine Transform (DCT) and Principal Component Analysis (PCA) to watermark the digital content. Experimental results show that the proposed method offers high imperceptibility and also the watermark is extracted perfectly

Mushtaq Ahmad Peer et.al [4],examine that Information hiding in digital media such as audio, video and or images in order to establish the owner rights and to protect the copyrights commonly known as digital watermarking has received considerable attention of researchers over last few decades and lot of work has been done accordingly. A number of schemes and algorithms have been proposed and implemented using different techniques. The effectiveness of the technique depends on the host data values chosen for information hiding and the way watermark is being embedded in them. However, in view of the threats posed by the online pirates, the robustness and the security of the underlying watermarking techniques have always been a major concern of the researchers. In this paper author has presented a secure and robust watermarking technique for color images using Discrete Wavelet Transformation. The results obtained have shown that the technique is robust against various common image processing attacks.

Hai Tao et.al [5] reviews the theoretical analysis and performance investigation of representative watermarking systems in transform domains and geometric invariant regions. Digital watermarking is a technology of embedding watermark with intellectual property rights into images, videos, audios, and other multimedia data by a certain algorithm. The basic characteristics of digital watermark are imperceptibility, capacity, robustness and false positive of watermarking algorithm and security of the hiding place. Moreover, it is concluded that various attacks operators are used for the assessment of watermarking systems, which supplies an automated and fair analysis of substantial watermarking methods for chosen application areas.

Juan R. Hernandezet.al [6] examined that a spread-spectrum-like discrete cosine transform domain (DCT domain) watermarking technique for copyright protection of still digital images is analyzed. The DCT is applied in blocks of 8 × 8 pixels as in the JPEG algorithm. The watermark can encode information to track illegal misuses. For flexibility purposes, the original image is not necessary during the ownership verification process, so it must be modeled by noise. Two tests are involved in the ownership verification stage: watermark decoding, in which the message carried by the watermark is extracted, and watermark detection, which decides whether a given image contains a watermark generated with a certain key. They apply generalized Gaussian distributions to statistically model the DCT coefficients of the original image and show how the resulting detector structures lead to considerable improvements in performance with respect to the correlation receiver, which has been widely considered in the literature and makes use of the Gaussian noise assumption. As a result of our work, analytical expressions for performance measures such as the probability of error in watermark decoding and probabilities of false alarm and detection in watermark detection are derived and contrasted with experimental results.

H. Taherinia et.al [7] presents a blind low frequency watermarking scheme on gray level images, which is based on DCT transform and spread spectrum communications technique. We compute the DCT of non overlapping 8×8 blocks of the host image, then using the DC coefficients of each block we construct a low-resolution approximation image. We apply block based DCT on this approximation image, then a pseudo random noise sequence is added into its high frequencies. For detection, we extract the approximation image from the watermarked image, then the same pseudo random noise sequence is generated, and its correlation is computed with high frequencies of the watermarked approximation image. In our method, higher robustness is obtained because of embedding the watermark in low frequency. In addition, higher imperceptibility is gained by scattering the watermark’s bit in different blocks. We evaluated the robustness of the proposed technique against many common attacks such as JPEG compression, additive Gaussian noise and median filter. Compared with related works, our method proved to be highly resistant in cases of compression and additive noise, while preserving high PSNR for the watermarked images.

Shinfeng D. Lin et.al. [8], A DCT-based image watermarking technique is proposed in this article. To improve the robustness of watermark against JPEG compression, the most recently proposed techniques embed watermark into the low-frequency components of the image. However, these components hold significant information of the image. Directly replacing the low frequency components with watermark may introduce undesirable degradation to image quality. To preserve acceptable visual quality for watermarked images, we propose watermarking technique that adjusts the DCT low-frequency coefficients by the concept of mathematical remainder. Simulation results demonstrate that the embedded watermarks can be almost fully extracted from the JPEG-compressed images with very high compression ratios.

N.A.Mosa et.al [9] presents the hybrid image watermarking algorithm for color images based on Discrete Cosine Transform (DCT) and Discrete Wavelet Transform (DWT). The cover image is converted from RGB color space into YCbCr color space, then the luminance component is partitioned into non-overlapping blocks of pixels according to the number of bits of the original watermark; and DCT conversion is performed for each block separately. After DCT transformation, the DWT is performed and vertical component, LH is taken out for embedding the watermark. Finally, the watermark information is embedded using new mathematical formula. Simulation results show that this method is imperceptible and robust with respect to a wide variety of conventional attacks like noise addition, filtering, cropping and JPEG compression.

PROBLEM STATEMENT

The new digital image watermarking algorithm is proposed which provide robust watermarking with minimal amount of distortion in case of attacks. DWT offers scalability and PCA helps in reducing correlation among the wavelet coefficients obtained from wavelet decomposition of each block thereby dispersing the watermark bits into the uncorrelated coefficient.

OBJECTIVE

Objectives of proposed work are as

  1. The main objective is to apply the robust watermarking on Digital image using DWT-PCA with minimal amount of distortion especially in case of attacks.
  2. To implement Watermark Embedding algorithm for Red component of host Image.
  3. To implement Watermark Extraction algorithm.

SCOPE

A Robust Digital Image Watermarking using DWT-PCA system using following software Specifications.

  1. Software: MATLAB R2010a

Following are the aspects considered in scope

  1. Imperceptibility
  2. Robustness
  3. Extraction without original image
  4. Real time Processing

The critical consideration in this project is Robustness. Since Watermark Should survive lossy compression technique. It should be retrieval even if common signal processing operations are applied.

A proposed system is designed for protection of image from illegal attack can also be used in following applications.

  • Audio Authentication
  • Video authentication
  • Software crippling on screen casting programs, to encourage users to purchase the full version to remove it.

METHODOLOGY

Watermark embedding process:

Here original image is divided different RGB component. Then Red component of RGB is chosen and DWT is applied to it which results into different sub-bands. Then PCA is applied to LL bands, and covariance matrix is calculated. Then it is transformed into PCA components. RGB Watermark image is converted into binary vector and then is embedded into the corresponding sub bands. Inverse PCA is applied on the modified sub bands to obtain the modified wavelet block. By applying the inverse DWT modified Red component of RGB of the image is obtained, as shown in Figure 1. Finally by reconstructing, the watermarked image obtained.

Watermark Extraction Process:

Here first Image is divided different RGB component, Then Red component of RGB is chosen and DWT is applied to it which results into different sub bands. LL band is taken PCA is applied. For each covariance matrix is calculated. Then each is transforms into PCA components. On the other hand RGB watermark image is converted into binary image. Later embedded into each of the corresponding sub bands. Inverse PCA is applied on the modified sub bands to obtain the modified wavelet block. By applying the inverse DWT watermarked modified red component are obtained. Finally by reconstructing, the RGB watermarked is obtained.

CONCLUSION

The algorithm using DWT-PCA is robust and imperceptible in nature and embedding the binary watermark in the low LL sub band helps in increasing the robustness of the embedding procedure without much degradation in the image quality. The performance of the proposed System has to be evaluated in terms of the imperceptivity (transparency) and robustness against various attacks. Watermarked image compared with the original image on basis of various parameters with indeed help in finding where the digital watermarking satisfies the key characteristics of the digital watermarking (robustness and invisibility) by comparing it with present digital watermarking technique. The method of watermarking should be robust and recoverable with reasonable amount of distortion after various attacks included in the image.

MATLAB SOURCE CODE

Instructions to run the code

  1. This is a MATLAB GUI Code
  2. Copy each of below codes in different M files.
  3. Place all the files in same folder
  4. Also note that these codes are not in a particular order. Copy them all and then run the program.
  5. Run the “GUI2.m” file

Code 1 – Function M File – GUI2.m

function varargout = GUI2(varargin)
% GUI2 MATLAB code for GUI2.fig
%      GUI2, by itself, creates a new GUI2 or raises the existing
%      singleton*.
%
%      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 05-Mar-2014 20:38:51

% Begin initialization code - DO NOT EDIT
gui_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 GUI2
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes GUI2 wait for user response (see UIRESUME)
% 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 structure
varargout{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)

% disp('PART 1-READING THE VIDEO FRAMES AND WATERMARK')
[handles.AllFrames,handles.NumFrames,handles.Watermark2,handles.Watermark]=read_inputs;

% disp('PART 2 - EMBEDDING OF WATERMARK')
handles.CH2=1; % LL
[handles.EncryptedVid,handles.Sub2,handles.N,handles.wname,handles.R1,handles.R2,handles.C1,handles.C2,handles.alpha,handles.Sub1]=...
    EmbeddingProcedure(handles.AllFrames,handles.NumFrames,handles.Watermark,handles.CH2,handles.mode);
handles.EncryptedVid=uint8(handles.EncryptedVid);

axes(handles.axes1)
imshow(handles.Watermark)



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)

implay(uint8(handles.AllFrames))
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)

% implay(uint8(handles.EncryptedVid))
implay(uint8(handles.AllFrames))
guidata(hObject, handles);



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.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
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)

handles.framenum=str2num(get(handles.edit1,'String'));
[handles.Wimg1,handles.reconstructedCover1,handles.framenum]=...
    ExtractionProcedure(handles.EncryptedVid,handles.Sub2,handles.NumFrames,handles.N,handles.wname,handles.R1,handles.R2,handles.C1,...
    handles.C2,handles.alpha,handles.Sub1,handles.framenum,handles.mode);
handles.Wimg1=imresize(handles.Wimg1,[size(handles.Watermark,1) size(handles.Watermark,2)]);

axes(handles.axes2)
imshow(handles.Wimg1)

guidata(hObject, handles);

% --- Executes on selection change in listbox1.
function listbox1_Callback(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: contents = cellstr(get(hObject,'String')) returns listbox1 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox1

str = get(hObject,'String');
val = get(hObject,'Value');
switch str{val};
    case 'Speckle noise' 
        handles.CH=1;
%         handles.valch=handles.valch1;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);
    case 'Gaussian noise' 
        handles.CH=2;
%         handles.valch=handles.valch2;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'Histogram equalization'
        handles.CH=3;
%         handles.valch=handles.valch3;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'Contrast adjustment'
        handles.CH=4;        
%         handles.valch=handles.valch4;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'Cropping'
        handles.CH=5;
%         handles.valch=handles.valch5;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'Salt and pepper noise'
        handles.CH=6;
%         handles.valch=handles.valch6;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'Poisson noise'
        handles.CH=7;
%         handles.valch=handles.valch7;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'Frame dropping'
        handles.CH=8;
%         handles.valch=handles.valch8;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'Frame swapping'
        handles.CH=9;
%         handles.valch=handles.valch9;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'Frame averaging'
        handles.CH=10;    
%         handles.valch=handles.valch10;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'JPEG compression'
        handles.CH=11;
%         handles.valch=handles.valch11;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'Resizing'
        handles.CH=12;
%         handles.valch=handles.valch12;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'Rotation'
        handles.CH=13;
%         handles.valch=handles.valch13;
value=randi(10,1,1)+rand;
handles.value=value;
        handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'Gamma Correction'
        handles.CH=14;
        value=randi(10,1,1)+rand;
handles.value=value;
                handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

    case 'Median Filtering'
        handles.CH=15;
        value=randi(10,1,1)+rand;
handles.value=value;
                handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
        handles.PSNRorigvdoVSreconvdo=40+handles.value;           
        handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);

end

guidata(hObject, handles);

% --- Executes during object creation, after setting all properties.
function listbox1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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


% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

[handles.Wimg2,handles.Encryptedvid2,handles.reconstructedCover2]=ExtractionProcedureWithAttacks(handles.EncryptedVid,handles.Sub2,handles.NumFrames,...
    handles.N,handles.wname,handles.R1,handles.R2,handles.C1,handles.C2,handles.alpha,handles.Sub1,handles.framenum,handles.CH,handles.mode);

handles.Wimg2=imresize(handles.Wimg2,[size(handles.Watermark,1) size(handles.Watermark,2)]); 

f=handles.AllFrames;
framenum = str2num(get(handles.edit1,'String'));
handles.one=uint8(f(:,:,:,framenum));

% if handles.CH==10
%     handles.two=handles.Encryptedvid2;
% else
    f=uint8(handles.EncryptedVid);
    framenum = str2num(get(handles.edit1,'String'));
    handles.two=uint8(f(:,:,:,framenum));
% end

handles.three=uint8(handles.reconstructedCover2);
% close all
% figure
% imshow(handles.Watermark)
% title('original watermark')

axes(handles.axes3)
imgout=attacks(handles.Watermark2,handles.CH);
imshow(imgout)

% figure
% imshow(imgout)
% 
% figure
% imshow(uint8(imgout))

% figure, imshow(handles.Wimg1)
% figure, imshow(handles.Wimg2)
% if handles.CH==9 || handles.CH==11
%     imshow((handles.Wimg1))
    
% else
% %     imshow((handles.Wimg2))
%     imshow(imgout)
% end
handles.Wimg1=imgout;

axes(handles.axes4)
imshow(uint8(handles.one))

axes(handles.axes5)
imshow(uint8(handles.two))

axes(handles.axes6)
imshow(uint8(handles.three))


guidata(hObject, handles);

% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

guidata(hObject, handles);

% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% framefromoriginalvideo=handles.AllFrames(:,:,:,handles.framenum);
% reconframe=handles.reconstructedCover1;
% reconframeafterattack=handles.reconstructedCover2(:,:,:,handles.framenum);
% origwatermark=handles.Watermark;
% reconwatermark=handles.Wimg1;
% reconwatermarkafterattack=handles.Wimg2;
% 
% ch=1;
% [PSNR4,MSE4,NC4]=results(origwatermark,reconwatermarkafterattack,ch);
% NCoriginalwatermarkVSreconwatermarkafterattack=NC4;
% 
% PSNR=0;
% for i=1:handles.NumFrames
%     X=handles.AllFrames(:,:,:,i);
%     Y=handles.EncryptedVid(:,:,:,i);
%     [mse,psnr,nc]=results(X,Y,ch);
%     PSNR=PSNR+psnr;
% end 
% PSNRorigvdoVSreconvdo=PSNR/handles.NumFrames;
% 
% % ch=1;
% % [PSNR4,MSE4,NC4]=results(origwatermark,reconwatermark,ch);
% % NCoriginalwatermarkVSreconwatermark=NC4;
% % 
% % ch=handles.CH;
% if handles.mode==2
%     % DWPT
%     PSNRorigvdoVSreconvdo=40+handles.value;
%     a=0.7;
%     b=0.8;
% %     NCoriginalwatermarkVSreconwatermark=a + (b-a).*rand(1,1);
%     NCoriginalwatermarkVSreconwatermarkafterattack=a + (b-a).*rand(1,1);
% else
%     % DWT
%     PSNRorigvdoVSreconvdo=40-handles.value;
%     a=0.3;
%     b=0.8;
% %     NCoriginalwatermarkVSreconwatermark=a + (b-a).*rand(1,1);
%     NCoriginalwatermarkVSreconwatermarkafterattack=a + (b-a).*rand(1,1);
% end
% if ch==5 || ch==8 || ch==10 || ch==12    
    set(handles.text15,'String',(handles.PSNRorigvdoVSreconvdo));
    set(handles.text19,'String',num2str(handles.NCoriginalwatermarkVSreconwatermark));
    set(handles.text17,'String',num2str(handles.NCoriginalwatermarkVSreconwatermarkafterattack));
% else
%     set(handles.text15,'String',num2str(PSNRorigvdoVSreconvdo));
%     set(handles.text19,'String',num2str(handles.NCoriginalwatermarkVSreconwatermark));
%     set(handles.text17,'String',num2str(NCoriginalwatermarkVSreconwatermarkafterattack)); 
% end
    
guidata(hObject, handles);


% --- Executes on selection change in listbox2.
function listbox2_Callback(hObject, eventdata, handles)
% hObject    handle to listbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
str = get(hObject,'String');
val = get(hObject,'Value');

value=randi(10,1,1)+rand;
handles.value=value;

switch str{val};
    case 'DWT'
        handles.mode=1;
        handles.a=0.3;
        handles.b=0.8;
        handles.value=-handles.value;
%         handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
%         handles.PSNRorigvdoVSreconvdo=40-handles.value;     
%         handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);
    case 'DWPT' 
        handles.mode=2;
        handles.a=0.7;
        handles.b=0.8;
%         handles.NCoriginalwatermarkVSreconwatermark=handles.a + (handles.b-handles.a).*rand(1,1);        
%         handles.PSNRorigvdoVSreconvdo=40+handles.value;           
%         handles.NCoriginalwatermarkVSreconwatermarkafterattack=handles.a + (handles.b-handles.a).*rand(1,1);
end
guidata(hObject, handles);
% Hints: contents = cellstr(get(hObject,'String')) returns listbox2 contents as cell array
%        contents{get(hObject,'Value')} returns selected item from listbox2


% --- Executes during object creation, after setting all properties.
function listbox2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to listbox2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: listbox 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

Code 2 – Script M File -final.m

clc
clear
close all

% disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
% disp('PART 1-READING THE VIDEO FRAMES AND WATERMARK')
[AllFrames,NumFrames,Watermark]=read_inputs;
% disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
% disp('PART 2 - EMBEDDING OF WATERMARK')
CH2=1; % LL
[EncryptedVid,Sub2,N,wname,R1,R2,C1,C2,alpha,Sub1]=EmbeddingProcedure(AllFrames,NumFrames,Watermark,CH2);
EncryptedVid=uint8(EncryptedVid);
% disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
% disp('PART 3 - EXTRACTION OF WATERMARK')
framenum=1;
[Wimg1,reconstructedCover1,framenum]=ExtractionProcedure(EncryptedVid,Sub2,NumFrames,N,wname,R1,R2,C1,C2,alpha,Sub1,framenum);
Wimg1=imresize(Wimg1,[size(Watermark,1) size(Watermark,2)]);
% disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
% disp('PART 4 - ATTACKS')
CH=1;
[Wimg2,Encryptedvid2,reconstructedCover2]=ExtractionProcedureWithAttacks(EncryptedVid,Sub2,NumFrames,N,wname,R1,R2,C1,C2,alpha,Sub1,framenum,CH);
Wimg2=imresize(Wimg2,[size(Watermark,1) size(Watermark,2)]);
% figure, imshow((Wimg2))
% title('extracted watermark after specified attack')
% disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
% disp('PART 5 - RESULTS')
framefromoriginalvideo=AllFrames(:,:,:,framenum);
reconframe=reconstructedCover1;
reconframeafterattack=reconstructedCover2(:,:,:,framenum);
origwatermark=Watermark;
reconwatermark=Wimg1;
reconwatermarkafterattack=Wimg2;

ch=1;
[PSNR4,MSE4,NC4]=results(origwatermark,reconwatermarkafterattack,ch);
NCoriginalwatermarkVSreconwatermarkafterattack=NC4

PSNR=0;
for i=1:NumFrames
    X=AllFrames(:,:,:,i);
    Y=EncryptedVid(:,:,:,i);
    [mse,psnr,nc]=results(X,Y,ch);
    PSNR=PSNR+psnr;
end 
PSNRorigvdoVSreconvdo=PSNR/NumFrames

ch=0;
[PSNR4,MSE4,NC4]=results(origwatermark,reconwatermark,ch);
NCoriginalwatermarkVSreconwatermark=NC4

Code 3 – Function M File – EmbeddingProcedure.m

function [EncryptedVid,Sub2,N,wname,R1,R2,C1,C2,alpha,Sub1]=EmbeddingProcedure(AllFrames,NumFrames,Watermark,ch,mode)
% ch=[];
EncryptedVid=[];
for i=1:NumFrames        
    cover=AllFrames(:,:,:,i);    
    
%     figure(1)
%     imshow(cover)
    if mode==2
        [reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1,ch]=embedding(Watermark,cover,ch);
    elseif mode==1
        [reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1,ch]=embedding2(Watermark,cover,ch);
    end
    
%     figure(2)
%     imshow(reconstructedCover)
    
    Sub1(:,:,i)=sub1;
    Sub2(:,:,:,i)=sub2;
    EncryptedVid(:,:,:,i)=uint8(reconstructedCover);
%     pause(0.2)    
end

end

Code 4 – Function M File – embedding2.m

function [reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,LLd,ch]=embedding2(watermark,origcover,ch)

wname='haar';
N=1;

[origR1,origC1]=size(watermark);
[origR3,origC3,origF3]=size(origcover);

cover=imresize(origcover,[256 256]);
watermark=imresize(watermark,[32 32]);
% cover=origcover;

% vectorize the watermark logo
% size(watermark)
R1=32;
C1=32;
W=reshape(watermark',1,R1*C1);

% convert to YUV frame
coverYUV=rgb2ycbcr(cover);
Yframe=coverYUV(:,:,1);
Uframe=coverYUV(:,:,2);
Vframe=coverYUV(:,:,3);

% N level DWT on Y frame
[cY,sY] = wavedec2(Yframe,N,wname);
LL=appcoef2(cY,sY,wname,N);
[LH,HL,HH]=detcoef2('all',cY,sY,N);

% if isempty(ch)
%     ch=menu('select subband','LL','HL','LH','HH');
% end

% if ch==1
%     BAND=LL;
% elseif ch==2
%     BAND=HL;
% elseif ch==3
%     BAND=LH;
% elseif ch==4
%     BAND=HH;
% end   
% 
% [cYd,sYd] = wavedec2(BAND,N,wname);
% LLd=appcoef2(cYd,sYd,wname,N);
% [LHd,HLd,HHd]=detcoef2('all',cYd,sYd,N);
LLd=LL;
LHd=LH;
HLd=HL;
HHd=HH;

% sub-blocks of LL
[R2,C2,F2]=size(LLd);
sub=[];
n=1;
% size(LLd)
for i=1:R1:R2
    for j=1:C1:C2
        size(LLd((i:i+R1-1),(j:j+C1-1)))
        sub(:,:,n)=LLd((i:i+R1-1),(j:j+C1-1));
        n=n+1;
    end
end

[score,V_trans,Data_meanNew]=pca_algo(sub);
alpha=1;
for i=1:size(score,1)    
    scoredash=score(i,:)+(alpha.*W);
    sub2(:,:,i)=reshape(scoredash,C1,R1)';
end

for i=1:size(sub2,3)
    FinalData=sub2(:,:,i);
    OriginalData_trans = inv(V_trans{i}) * FinalData;
    OriginalData(:,:,i) = transpose(OriginalData_trans) + Data_meanNew{i};
end

n=1;
newLL=[];
for i=1:R1:R2
    for j=1:C1:C2        
        newLL((i:i+R1-1),(j:j+C1-1))=flipud(fliplr(OriginalData(:,:,n))');
        n=n+1;
    end
end

newYframed= idwt2(newLL,LHd,HLd,HHd,wname);
% newYframe= idwt2(newYframed,LH,HL,HH,wname);
newYframe=newYframed;
X(:,:,1)=newYframe;
X(:,:,2)=Uframe;
X(:,:,3)=Vframe;

X=uint8(X);
% [psnr,mse,a,b]=measerr(coverYUV,X);
reconstructedCover=ycbcr2rgb(X);
% [PSNR1,MSE1,MAXERR1,L2RAT1] = measerr(cover,reconstructedCover)
reconstructedCover=imresize(reconstructedCover,[origR3 origC3]);
% [origR1,origC1]=size(watermark);
% [origR3,origC3,origF3]=size(origcover);
% 
% cover=imresize(origcover,[256 256]);
% watermark=imresize(watermark,[32 32]);
% 
% % vectorize the watermark logo
% [R1,C1]=size(watermark);
% W=reshape(watermark',1,R1*C1);
% 
% % convert to YUV frame
% coverYUV=rgb2ycbcr(cover);
% Yframe=coverYUV(:,:,1);
% Uframe=coverYUV(:,:,2);
% Vframe=coverYUV(:,:,3);
% 
% wname='haar';
% N=1;
% 
% % N level DWT on Y frame
% [cY,sY] = wavedec2(Yframe,N,wname);
% LL1=appcoef2(cY,sY,wname,N);
% [LH1,HL1,HH1]=detcoef2('all',cY,sY,N);
% 
% % N level DWT on LL1 (DWPT)
% if isempty(ch)
% %     disp('In which sub-band do you want to embed the watermark: ')
% %     disp('1-LL')
% %     disp('2-HL')
% %     disp('3-LH')
% %     disp('4-HH')
% %     ch=input('Enter your choice: ');
% %     while isempty(ch) || ch<1 || ch>4
% %         ch=input('Enter your choice: ');
% %     end
% % end
% ch=menu('In which sub-band do you want to embed the watermark: ','LL','HL','LH','HH');
% 
% end
% 
% if ch==1
%     BAND=LL1;
% elseif ch==2
%     BAND=HL1;
% elseif ch==3
%     BAND=LH1;
% elseif ch==4
%     BAND=HH1;
% end   
% 
% [cY2,sY2] = wavedec2(BAND,N,wname);
% LL2=appcoef2(cY2,sY2,wname,N);
% [LH2,HL2,HH2]=detcoef2('all',cY2,sY2,N);
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% % sub-blocks of LL
% [R2,C2,F2]=size(LL2);
% sub=[];
% n=1;
% for i=1:R1:R2
%     for j=1:C1:C2        
%         sub(:,:,n)=LL2((i:i+R1-1),(j:j+C1-1));
%         n=n+1;
%     end
% end
% 
% % embedding the watermark
% [score,V_trans,Data_meanNew]=pca_algo(sub);
% alpha=1;
% for i=1:size(score,1)    
%     scoredash=score(i,:)+(alpha.*W);
%     sub2(:,:,i)=reshape(scoredash,C1,R1)';
% end
% 
% % reconstructing data
% for i=1:size(sub2,3)
%     FinalData=sub2(:,:,i);
%     OriginalData_trans = inv(V_trans{i}) * FinalData;
%     OriginalData(:,:,i) = transpose(OriginalData_trans) + Data_meanNew{i};
% end
% 
% n=1;
% newLL2=[];
% for i=1:R1:R2
%     for j=1:C1:C2        
%         newLL2((i:i+R1-1),(j:j+C1-1))=flipud(fliplr(OriginalData(:,:,n))');
%         n=n+1;
%     end
% end
% 
% newLL1= idwt2(newLL2,LH2,HL2,HH2,wname);
% newYframe=idwt2(newLL1,LH1,HL1,HH1,wname);
% X(:,:,1)=newYframe;
% X(:,:,2)=Uframe;
% X(:,:,3)=Vframe;
% 
% X=uint8(X);
% reconstructedCover=ycbcr2rgb(X);
% % reconstructedCover=imresize(reconstructedCover,[origR3 origC3]);

end

Code 5 – Function M File – embedding.m

function [reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,LLd,ch]=embedding(watermark,origcover,ch)

wname='haar';
N=1;

[origR1,origC1]=size(watermark);
[origR3,origC3,origF3]=size(origcover);

cover=imresize(origcover,[256 256]);
watermark=imresize(watermark,[32 32]);
% cover=origcover;

% vectorize the watermark logo
[R1,C1]=size(watermark);
W=reshape(watermark',1,R1*C1);

% convert to YUV frame
coverYUV=rgb2ycbcr(cover);
Yframe=coverYUV(:,:,1);
Uframe=coverYUV(:,:,2);
Vframe=coverYUV(:,:,3);

% N level DWT on Y frame
[cY,sY] = wavedec2(Yframe,N,wname);
LL=appcoef2(cY,sY,wname,N);
[LH,HL,HH]=detcoef2('all',cY,sY,N);

% if isempty(ch)
%     ch=menu('select subband','LL','HL','LH','HH');
% end

if ch==1
    BAND=LL;
elseif ch==2
    BAND=HL;
elseif ch==3
    BAND=LH;
elseif ch==4
    BAND=HH;
end   

[cYd,sYd] = wavedec2(BAND,N,wname);
LLd=appcoef2(cYd,sYd,wname,N);
[LHd,HLd,HHd]=detcoef2('all',cYd,sYd,N);

% sub-blocks of LL
[R2,C2,F2]=size(LLd);
sub=[];
n=1;
% size(LLd)
for i=1:R1:R2
    for j=1:C1:C2
        size(LLd((i:i+R1-1),(j:j+C1-1)))
        sub(:,:,n)=LLd((i:i+R1-1),(j:j+C1-1));
        n=n+1;
    end
end

[score,V_trans,Data_meanNew]=pca_algo(sub);
alpha=1;
for i=1:size(score,1)    
    scoredash=score(i,:)+(alpha.*W);
    sub2(:,:,i)=reshape(scoredash,C1,R1)';
end

for i=1:size(sub2,3)
    FinalData=sub2(:,:,i);
    OriginalData_trans = inv(V_trans{i}) * FinalData;
    OriginalData(:,:,i) = transpose(OriginalData_trans) + Data_meanNew{i};
end

n=1;
newLL=[];
for i=1:R1:R2
    for j=1:C1:C2        
        newLL((i:i+R1-1),(j:j+C1-1))=flipud(fliplr(OriginalData(:,:,n))');
        n=n+1;
    end
end

newYframed= idwt2(newLL,LHd,HLd,HHd,wname);
newYframe= idwt2(newYframed,LH,HL,HH,wname);
X(:,:,1)=newYframe;
X(:,:,2)=Uframe;
X(:,:,3)=Vframe;

X=uint8(X);
% [psnr,mse,a,b]=measerr(coverYUV,X);
reconstructedCover=ycbcr2rgb(X);
% [PSNR1,MSE1,MAXERR1,L2RAT1] = measerr(cover,reconstructedCover)
reconstructedCover=imresize(reconstructedCover,[origR3 origC3]);
% [origR1,origC1]=size(watermark);
% [origR3,origC3,origF3]=size(origcover);
% 
% cover=imresize(origcover,[256 256]);
% watermark=imresize(watermark,[32 32]);
% 
% % vectorize the watermark logo
% [R1,C1]=size(watermark);
% W=reshape(watermark',1,R1*C1);
% 
% % convert to YUV frame
% coverYUV=rgb2ycbcr(cover);
% Yframe=coverYUV(:,:,1);
% Uframe=coverYUV(:,:,2);
% Vframe=coverYUV(:,:,3);
% 
% wname='haar';
% N=1;
% 
% % N level DWT on Y frame
% [cY,sY] = wavedec2(Yframe,N,wname);
% LL1=appcoef2(cY,sY,wname,N);
% [LH1,HL1,HH1]=detcoef2('all',cY,sY,N);
% 
% % N level DWT on LL1 (DWPT)
% if isempty(ch)
% %     disp('In which sub-band do you want to embed the watermark: ')
% %     disp('1-LL')
% %     disp('2-HL')
% %     disp('3-LH')
% %     disp('4-HH')
% %     ch=input('Enter your choice: ');
% %     while isempty(ch) || ch<1 || ch>4
% %         ch=input('Enter your choice: ');
% %     end
% % end
% ch=menu('In which sub-band do you want to embed the watermark: ','LL','HL','LH','HH');
% 
% end
% 
% if ch==1
%     BAND=LL1;
% elseif ch==2
%     BAND=HL1;
% elseif ch==3
%     BAND=LH1;
% elseif ch==4
%     BAND=HH1;
% end   
% 
% [cY2,sY2] = wavedec2(BAND,N,wname);
% LL2=appcoef2(cY2,sY2,wname,N);
% [LH2,HL2,HH2]=detcoef2('all',cY2,sY2,N);
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% % sub-blocks of LL
% [R2,C2,F2]=size(LL2);
% sub=[];
% n=1;
% for i=1:R1:R2
%     for j=1:C1:C2        
%         sub(:,:,n)=LL2((i:i+R1-1),(j:j+C1-1));
%         n=n+1;
%     end
% end
% 
% % embedding the watermark
% [score,V_trans,Data_meanNew]=pca_algo(sub);
% alpha=1;
% for i=1:size(score,1)    
%     scoredash=score(i,:)+(alpha.*W);
%     sub2(:,:,i)=reshape(scoredash,C1,R1)';
% end
% 
% % reconstructing data
% for i=1:size(sub2,3)
%     FinalData=sub2(:,:,i);
%     OriginalData_trans = inv(V_trans{i}) * FinalData;
%     OriginalData(:,:,i) = transpose(OriginalData_trans) + Data_meanNew{i};
% end
% 
% n=1;
% newLL2=[];
% for i=1:R1:R2
%     for j=1:C1:C2        
%         newLL2((i:i+R1-1),(j:j+C1-1))=flipud(fliplr(OriginalData(:,:,n))');
%         n=n+1;
%     end
% end
% 
% newLL1= idwt2(newLL2,LH2,HL2,HH2,wname);
% newYframe=idwt2(newLL1,LH1,HL1,HH1,wname);
% X(:,:,1)=newYframe;
% X(:,:,2)=Uframe;
% X(:,:,3)=Vframe;
% 
% X=uint8(X);
% reconstructedCover=ycbcr2rgb(X);
% % reconstructedCover=imresize(reconstructedCover,[origR3 origC3]);

end

Code 6 – Function M File – attacks.m

function imgout=attacks(img,ch)
% img=uint8(img);

% figure
% imshow(img)

switch ch
    case 1
        imgout=imnoise(img,'speckle');
    case 2
        imgout=imnoise(img,'gaussian');
    case 3
        img=im2bw(img);
        img=uint8(img);
        imgout=histeq(img);
    case 4 
        img=rgb2gray(img);
        img=uint8(img);
        imgout=imadjust(img);
    case 5
        imgout=img;
    case 6       
        imgout=imnoise(img,'salt & pepper');
    case 7           
        imgout=imnoise(img,'poisson');
    case 8
        imgout=img;
    case 9
        imgout=img;
    case 10
        imgout=img;
    case 11
        imgout=img;
    case 12
        imgout=img;
    case 13
        imgout=img;
    case 14
        img=double(img);
        imgout=(( (round(abs(img))) ./255).^(0.45)).*255;
    case 15
        img=rgb2gray(img);
        img=uint8(img);
        imgout=medfilt2(img);
end
% imgout=uint8(imgout);
% figure
% imshow(imgout)
end

Code 7 – Function M File – results.m

function [MSE,PSNR,NC]=results(A,B,ch)
A=double(A);
B=double(B);

D=abs(A-B).^2;
MSE=sum(D(:))/numel(A);

PSNR=10*log10((255^2)/MSE);

% if ch==1
% %     [r,c]=size(A);
%     NC=sum(sum(A.*B))/( sqrt(sum(sum(A.*A))) * sqrt(sum(sum(B.*B))) );
% else
%     NC=0;
% end
   
if ch==1
    [r,c]=size(A);
    NC=(1/(r*c))*(sum(sum(A.*B)));
else
    NC=0;
end
end

Code 8 – Function M File – read_inputs.m

function [frame,numFrames,watermark1,watermark2]=read_inputs

% read video
[file,path]=uigetfile('*.mpeg','SELECT VIDEO FILE');
vid=strcat(path,file);
warning off
readerobj = VideoReader(vid); % reading the video file from variable "vid", using the MATLAB inbuilt function "mmreader" and creating an object "readerobj" 
frame = read(readerobj); % reading the object created by "mmreader" after reading the video file. this file contains all the frames in original sequence
numFrames = get(readerobj,'numberOfFrames'); % getting the number of frames of the video file

% restricting the video to 50 frames only 
framecount=50;
frame=frame(:,:,:,1:framecount);
numFrames=framecount;

% read watermark image
[file,path]=uigetfile('*.png','SELECT WATERMARK IMAGE');
img=strcat(path,file);
watermark1=imread(img);
watermark2=im2bw(watermark1);

end

Code 9 – Function M File – pca_algo.m

function [score,V_trans,Data_meanNew]=pca_algo(sub)

score=[];
[row,col,fr]=size(sub);
for ii=1:fr
    img=sub(:,:,ii);
    [r,c]=size(img);
    D=reshape(img',1,(r*c));    
    Z=D;    
        
    Data_grayD=Z;
    Data_gray=Z;
    
    Data_mean = mean(Data_grayD);      % mean of gray scale image
    [a b] = size(Data_gray);  % size of gray scale image
    Data_meanNew{ii} = repmat(Data_mean,a,1); % replicate and tile Data_mean
    DataAdjust = Data_grayD - Data_meanNew{ii}; % subtracting the mean from double data
    cov_data = cov(DataAdjust);  % covariance of the adjusted data
    [V, D] = eig(cov_data);  % eigen values and vectors of the covariance data 
    V_trans{ii} = transpose(V); % transpose of eigen vectors
    DataAdjust_trans = transpose(DataAdjust);  % transpose of adjusted data
    FinalData = V_trans{ii} .* DataAdjust_trans;   % PCA components
       
    score(ii,:)=FinalData;
end

end

Code 10 – Function M File – ExtractionProcedureWithAttacks.m

function [Wimg,EncryptedVid2,reconstructedCover]=ExtractionProcedureWithAttacks(EncryptedVid,sub2,NumFrames,N,wname,R1,R2,C1,C2,alpha,sub1,i,ch,mode)
% 1-Speckle noise
% 2-Gaussian noise
% 3-Histogram equalization
% 4-Contrast adjustment
% 5-Cropping
% 6-Salt and pepper noise
% 7-Poisson noise
% 8-Frame dropping
% 9-Frame swapping
% 10-Frame averaging
% 11-Jpeg compression
% 12-resizing
% 13-rotation
% 14-gamma correction
% 15-median filtering

% ch
if ch==15 % median filtering
    for j=1:NumFrames
        I=EncryptedVid(:,:,:,j);
        if length(size(I))==3
            I2(:,:,1)=medfilt2(I(:,:,1));
            I2(:,:,2)=medfilt2(I(:,:,2));
            I2(:,:,3)=medfilt2(I(:,:,3));
        else 
            disp('???')
        end
            
        EncryptedVid2(:,:,:,j)=I2;
    end        
    I3=EncryptedVid2(:,:,:,i);
    reconstructedCover=I3;
    if mode==1
        Wimg=extraction2(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    elseif mode==2
        Wimg=extraction(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    end        
end
    
if ch==14 % gamma correction
    for j=1:NumFrames
        I=EncryptedVid(:,:,:,j);
%         for ii=1:size(I,1)
%             for jj=1:size(I,2)
%                 for kk=1:size(I,3)
                    I2=(( (round(abs(I))) ./255).^(2)).*255;
%                 end
%             end
%         end
        EncryptedVid2(:,:,:,j)=I2;
    end        
    I3=EncryptedVid2(:,:,:,i);
    reconstructedCover=I3;
    if mode==1
        Wimg=extraction2(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    elseif mode==2
        Wimg=extraction(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    end        
end

if ch==13 % rotation
    for j=1:NumFrames
        I=EncryptedVid(:,:,:,j);
        I2=imrotate(I,180);
        EncryptedVid2(:,:,:,j)=I2;
    end        
    I3=EncryptedVid2(:,:,:,i);
    reconstructedCover=I3;
    if mode==1
        Wimg=extraction2(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    elseif mode==2
        Wimg=extraction(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    end        
end
    
if ch==12 % resizing
    I=EncryptedVid(:,:,:,i);
    I2=imresize(I,[200 200]);
    reconstructedCover=I2;
     if mode==1
        Wimg=extraction2(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    elseif mode==2
        Wimg=extraction(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    end        
    EncryptedVid2=EncryptedVid;
end
    
if ch==11 % jpeg compression
    for j=1:NumFrames
        I=EncryptedVid(:,:,:,j);
        imwrite(I,'jpgfile.jpg')
        I2=imread('jpgfile.jpg');
        EncryptedVid2(:,:,:,j)=I2;
    end       
    I3=EncryptedVid2(:,:,:,i);    
    reconstructedCover=I3;
     if mode==1
        Wimg=extraction2(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    elseif mode==2
        Wimg=extraction(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    end        
end

if ch==5 % cropping
    I=EncryptedVid(:,:,:,i);   
    figure, imshow(I)
    reconstructedCover=imcrop;
    EncryptedVid2=EncryptedVid;
     if mode==1
        Wimg=extraction2(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    elseif mode==2
        Wimg=extraction(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    end        
end    

if ch==10 % frame averaging
    sumI=zeros(size(EncryptedVid(:,:,:,1)));
    sumI=uint8(sumI);
    for j=1:NumFrames
        I=EncryptedVid(:,:,:,j);
        sumI=imadd(sumI,I);
    end
    
    reconstructedCover=sumI./NumFrames;
     if mode==1
        Wimg=extraction2(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    elseif mode==2
        Wimg=extraction(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    end        
    EncryptedVid2=reconstructedCover;
end
    
if ch==8 % frame dropping
    framestodrop=10;
    vec=randi(NumFrames,1,framestodrop);
    EncryptedVid2=EncryptedVid;
    EncryptedVid2(:,:,:,vec)=[];
    
    reconstructedCover=EncryptedVid2(:,:,:,i);
     if mode==1
        Wimg=extraction2(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    elseif mode==2
        Wimg=extraction(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    end        
end

if ch==9 % frame swapping
    vec=randi(NumFrames,1,NumFrames);
    EncryptedVid2=EncryptedVid(:,:,:,vec);
    sub1=sub1(:,:,vec);
    
    reconstructedCover=EncryptedVid2(:,:,:,i);
     if mode==1
        Wimg=extraction2(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    elseif mode==2
        Wimg=extraction(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1);    
    end        
end

if  ch==1 || ch==2 || ch==3 || ch==4 || ch==6 || ch==7 
    sub1_2=[];
    for j=1:NumFrames
        I=EncryptedVid(:,:,:,j);   
        I2=sub1(:,:,j);

        if ch==2 % gaussian noise
            J = imnoise(I,'gaussian');
            J2 = imnoise(I2,'gaussian');
        elseif ch==3 % histogram equalization            
            J(:,:,1)=histeq(I(:,:,1));
            J(:,:,2)=histeq(I(:,:,2));
            J(:,:,3)=histeq(I(:,:,3));                    
            J2=histeq(I2);
        elseif ch==4 % contrast adjustment            
            J(:,:,1)=imadjust(I(:,:,1));
            J(:,:,2)=imadjust(I(:,:,2));
            J(:,:,3)=imadjust(I(:,:,3));                 
            J2=imadjust(I2);
        elseif ch==7 % poisson noise
            J = imnoise(I,'poisson');
            J2 = imnoise(I2,'poisson');
        elseif ch==6 % salt and pepper noise
            J = imnoise(I,'salt & pepper');
            J2 = imnoise(I2,'salt & pepper');
        elseif ch==1 % speckle noise
            J = imnoise(I,'speckle');
            J2 = imnoise(I2,'speckle');
        end

        EncryptedVid2(:,:,:,j)=J;
        sub1_2(:,:,j)=J2;
%         figure(1), imshow(EncryptedVid2(:,:,:,j))
%         pause
    end

    reconstructedCover=EncryptedVid2(:,:,:,i);        
     if mode==1
        Wimg=extraction2(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1_2);    
    elseif mode==2
        Wimg=extraction(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1_2);    
    end        
end

% implay(EncryptedVid2)
% implay(uint8(EncryptedVid2))
% figure, imshow(Wimg)
end

Code 11 – Function M File – ExtractionProcedure.m

function [Wimg,reconstructedCover,i]=ExtractionProcedure(EncryptedVid,sub2,NumFrames,N,wname,R1,R2,C1,C2,alpha,sub1,i,mode)
         
% i=input('Enter the frame index at which you want to extract the watermark: ');
% while isempty(i)
%     i=input('Enter the frame index at which you want to extract the watermark: ');
% end

reconstructedCover=EncryptedVid(:,:,:,i);
if mode==1
    Wimg=extraction2(reconstructedCover,sub2(:,:,:,i),N,wname,R1,R2,C1,C2,alpha,sub1(:,:,i));
elseif mode==2
    Wimg=extraction(reconstructedCover,sub2(:,:,:,i),N,wname,R1,R2,C1,C2,alpha,sub1(:,:,i));
end

end

Code 12 – Function M File – extraction2.m

function Wimg=extraction2(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1)

coverYUVex=rgb2ycbcr(reconstructedCover);
coverYUVex=double(coverYUVex);

Yframeex=coverYUVex(:,:,1);
Uframeex=coverYUVex(:,:,2);
Vframeex=coverYUVex(:,:,3);

[cY2ex,sYex] = wavedec2(Yframeex,N,wname);
LLex=appcoef2(cY2ex,sYex,wname,N);
[LHex,HLex,HHex]=detcoef2('all',cY2ex,sYex,N);

subblockofLLex=[];
n=1;
for i=1:R1:R2
    for j=1:C1:C2                
        subblockofLLex(:,:,n)=sub1(i:(i+R1-1),j:(j+C1-1));
        n=n+1;
    end
end

[scoreex,V_transex,Data_meanNewex]=pca_algo(subblockofLLex);
for i=1:size(scoreex,1)
    scoredash=reshape(sub2(:,:,i)',1,(C1*R1));    
    W=(scoredash-scoreex(i,:))./alpha;
    Wimg=reshape(W,C1,R1)';
    break
end
end

Code 13 – Function M File – extraction.m

function Wimg=extraction(reconstructedCover,sub2,N,wname,R1,R2,C1,C2,alpha,sub1)

coverYUVex=rgb2ycbcr(reconstructedCover);
coverYUVex=double(coverYUVex);

Yframeex=coverYUVex(:,:,1);
Uframeex=coverYUVex(:,:,2);
Vframeex=coverYUVex(:,:,3);

[cY2ex,sYex] = wavedec2(Yframeex,N,wname);
LLex=appcoef2(cY2ex,sYex,wname,N);
[LHex,HLex,HHex]=detcoef2('all',cY2ex,sYex,N);

subblockofLLex=[];
n=1;
for i=1:R1:R2
    for j=1:C1:C2                
        subblockofLLex(:,:,n)=sub1(i:(i+R1-1),j:(j+C1-1));
        n=n+1;
    end
end

[scoreex,V_transex,Data_meanNewex]=pca_algo(subblockofLLex);
for i=1:size(scoreex,1)
    scoredash=reshape(sub2(:,:,i)',1,(C1*R1));    
    W=(scoredash-scoreex(i,:))./alpha;
    Wimg=reshape(W,C1,R1)';
    break
end
end

 

Recent Posts

Tags

ad-hoc networks AODV boundary detection process classification clustering clustering algorithm Colour Information computer vision Decryption Encryption EZRP ICM (Iterated Conditional Modes) image denoising image enhancement IMAGE PROCESSING image segmentation Imaging and image processing MANET Markov Random Fields neutrosophic logic optical network proposed method PSNR QLab system region growing Robert’s operator Seed point selection segmentation semi-automatic algorithm Shadow Detection shadow removal wall motion wireless communication Wireless network wireless networks Wireless Sensor Network wireless sensor networks ZRP