A PROPOSED ALGORITHM FOR DIGITAL WATERMARKING Dr. Mohammed F. Al-Hunaity dr_alhunaity@bau.edu.jo Meran M. Al-Hadidi Merohadidi77@gmail.com Dr.Belal A. Ayyoub belal_ayyoub@ hotmail.com Abstract: This paper introduces how to use MATLAB to implement a new simple Image Watermarking Algorithm, In the proposed work a binary array of size (5 x 5) containing 1 and 0 is derived from the original image according to an algorithm implemented in MATLAB, then the binary array will be updated in a way that it can carry the secret message, after the binary array is changed; the original image will be processed in a way that it will be appeared as the original. After the receiver gets the image, the composed binary array will be derived and got the secret message according to some rules as agreed between the ser and him. Keywords: Watermarking Algorithm; Image Implementation using MATLAB. 1. Introduction Digital Watermarking describes methods and technologies that hide information, for example a number or text, in digital media, such as images, video or audio [Cox et al., (2008)]. The embedding takes place by manipulating the content of the digital data, which means the information is not embedded in the frame around the data. The hiding process has to be such that the modifications of the media are imperceptible. For images this means that the modifications of the pixel values have to be invisible [Barni and Bartolini, (2004)]. Also referred to as simply digital watermarking, a pattern of bits inserted into a digital image watermark, audio or video digital watermarks file [Al-Hunaity et al., (2007)]. Digital Image, like many other files, is known as a matrix in MATLAB (matrix laboratory) is a numerical computing environment and fourth-generation programming language. Developed by Math Works, MATLAB allows matrix manipulations, plotting of functions and data, Implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages, including C, C++, Java, and Fortran [Kattan, (2008)]. 2. Digital Image Processing by MATLAB A digital image a[m,n] described in a 2D discrete space is derived from an analog image a(x,y) in a 2D continuous space through a sampling process that is frequently referred to as digitization. For now we will look at some basic definitions associated with the digital image. The 2D continuous image a(x,y) is divided into N rows and M columns. The intersection of a row and a column is termed a pixel. The value assigned to the integer coordinates [m,n] with {m=0,1,2,...,m-1} and {n=0,1,2,...,n-1} is a[m,n] [Gonzaez and Woods, (2008)]. There are two types of images that can be processed by MATLAB: 1. RGB Images: A color perceived by the human eye can be defined by a linear combination of the three primary colors red, green and blue. These three colors form the basis for the RGB-color space. Hence, each perceivable color can be defined by a vector in the three-dimensional color space. The intensity is given by the length of the vector, and the actual color by the two angles describing the orientation of the vector in the color space. 2. Grayscale images: Grayscale images are images without color, or achromatic images. The levels of a grayscale range from 0 (black) to 1 (white). In our proposed algorithm we will use the grayscale image by converting the RGB image to a grayscale one using MATLAB [Pratap, (2010)]. 3. The Proposed Algorithm As mentioned before we will generate a binary matrix of size (5x5) from the original image after we have read the digital image using MATLAB, our algorithm can be applied on gray images or colored image, there will not be any effect on the quality of the image either it was colored or gray. To do any operation on digital images such as (addition, multiplication, division and subtraction), image should be converted to type double using im2double command, which takes an image as input, and returns an image of class double. If the input image is of class double, the output image is identical to it. ISSN : 0975-5462 Vol. 4 No.12 December 2012 4929
After that we will take the first 25 pixels from the converted image and finding the average of these specified pixels by calculating the summation of their pixels values first, and then divide it by 25, the number of pixels in the selected array, as shown in figure 1. Figure 1: the selected pixels from the image Then take the next adjacent 25 pixels from the converted image as shown in figure 2. Figure 2: the next adjacent 25 pixels from the image Generate a new matrix of size (5x5) and copy the next adjacent 25 pixels values to this new matrix, replace the values by 1 or 0 of the new matrix as follows: If the value of the pixel in the new matrix is less than or equal to the previous computed average of the first 25 pixels of the digital image, replace its value by 0, else replace it by 1. Finally insert the secret message or number in this new binary matrix so that the XOR operations of each diagonal from right to left will include the secret message as shown in figure 3, then update the original corresponding values to be greater than the computed average if we want to use 1, or to be less than the computed average if we want to use 0, this method will change specific pixels in the image but it will not affect the appearance of the image that we want to s to the receiver. Figure 3: the method to compute XOR operations 4. Algorithm Implementation As a simple example if we took the following image which name is 'image1.bmp as shown in figure 4. Figure 4: image1.bmp ISSN : 0975-5462 Vol. 4 No.12 December 2012 4930
Clear the MATLAB workspace of any variables and close open figure windows by the command: >> clear, close all To read an image, use the imread command. The example reads an image from a file named image1.bmp located in C drive and stores it in an array named I. image1.bmp is one of the sample images that is supplied with the Image Processing Toolbox. >> I = imread('c:\image1.bmp'); imread infers from the file that the graphics file format is BMP. Now display the image. The toolbox includes two image display functions: imshow. You can use either one to display an image; the result is shown in figure 5. >> imshow(i) Figure 5: image1.bmp by MATLAB To create a grayscale intensity image from an RGB image, we use the rgb2gray command: >> gray_image = rgb2gray(i); to display the gray image again, the result is shown in figure 6: >> imshow (gray_image) To do any operation on images such as (addition, multiplication, division and subtraction), image should be converted to type double using im2double command, which takes an image as input, and returns an image of class double [Thaler and Hochreutener, (2008)]. If the input image is of class double, the output image is identical to it. If the input image is of class logical, uint8 or uint16, im2double returns the equivalent image of class double, rescaling or offsetting the data as necessary. >> X=im2double(gray_image); >> imshow(x) The result will be the same as shown in figure 6. To calculate the average of the first 25 pixels values: sum=0; sum=sum+x(i,j); Figure 6: The grayscale intensity image ISSN : 0975-5462 Vol. 4 No.12 December 2012 4931
m1=sum/25; To create the new matrix b of size (5,5) of initial values of zeros: b=zeros(5,5); To copy the values of pixels in the adjacent pixels of the first 25 pixels into b: b(i,j)=x(i,j+5); To replace the values of pixels in b with 1 or 0 according to the following equations: b(i,j)=0, if b(i,j)<=m1 b(i,j)=1, if b(i,j)>m1 Where m1 is the previous computed average. if b(i,j)<=m1 b(i,j)=0; else b(i,j)=1; To display the contents of matrix b the following command is used as shown in figure 7: Figure 7: the new binary matrix b If the ser wants to s number 11 for example, in binary number 11 equals 1011 but we need to write it using 9 digits since the outputs of XOR operations will be 9 digits as follows: a 0 a 1 a 2 a 3 a 4 a 5 a 6 a 7 a 8 Number 1011 = 0 0 0 0 0 1 0 1 1 a0 = b(1,1) a1 = b(1,2) b(2,1) a2 = b(1,3) b(2,2) b(3,1) a3 = b(1,4) b(2,3) b(3,2) ) b(4,1) a4 =b(1,5) b(2,4) b(3,3) ) b(4,2) b(5,1) a5 = b(2,5) b(3,4) b(4,3) ) b(5,2) a6 = b(3,5) b(4,4) b(5,3) ) a7 = b(4,5) b(5,4) a8 = b(5,5) As we mentioned previously we will take the XOR operations diagonally as shown in figure 3. After we have computed a 0 a 1 a 2 a 3 a 4 a 5 a 6 a 7 a 8 from the above binary matrix, we will update the computed one to be the required one which is 000001011 1in our example, according to that we will update some pixels in the binary matrix to compute the wanted result. In our example the updated binary matrix is shown as in figure 8: ISSN : 0975-5462 Vol. 4 No.12 December 2012 4932
Figure 8: the updated binary matrix b Finally we will change the corresponding pixels X(2,7), X(2,10), X(3,8), X(5,9) and X(5,10) to make their values greater than m1 (the previous computed average), and change the corresponding pixel X(1,6) to make its value is less than m1, then s the updated image to the receiver. Figure 9 shows the updated original image and it is appeared that no change is done. Figure 9: the updated original image On the other side the receiver will get the updated image and repeat the previous algorithm and make the XORing operations to get the secret message or number. 5. Analysis and Conclusions In this paper a new simple algorithm in digital watermarking using MATLAB was proposed. We e tried the algorithm on several images, either gray or colored, bmp or jpeg images, all the images after update will be the same before update, even on the worst case if we needed to update all the required 25 pixels from the original image, image will not be affected and still the same. Watermarking is a very active research field with a lot of applications. Although it is a relatively new field, it has produced important algorithms for hiding messages into digital signals. These can be described by many different models. References [1] Al-Hunaity, M.F., et al. (2007): "Colored digital image watermarking using the wavelet technique", American Journal of Applied Sciences, 4(9), pp.658-662. [2] Barni, M. and Bartolini, F. (2004). "Watermarking Systems Engineering", Marcel Dekker Inc. [3] Cox, J., et al. (2008). "Digital Watermarking and Steganography", Morgan Kaufmann Pub., Elsevier Inc. [4] Gonzaez, R. and Woods, R. (2008). "Digital Image Processing". Third Edition. [5] Kattan, P. (2008). "Matlab For Beginners: A Gentle Approach". [6] Pratap, R. (2010). "Getting Started with MATLAB: A Quick Introduction for Scientists and Engineers". Indian Institute of Science. [7] Thaler, M. and Hochreutener, H. (2008). "Image Processing Basics Using MATLAB". ZHAW. ISSN : 0975-5462 Vol. 4 No.12 December 2012 4933