38 International Journal of Advanced Network Monitoring and Controls Volume 02, No.2, 2017 A DCT Domain Image Watermarking Method Based on Matlab Wu He-Jing Department of Computer Science & Electrical Engineering, East University of Heilongjiang, Harbin, China Email: 499917928@qq.com Abstract. In the text, A method of image watermarking based on DCT (Discrete Cosine Transform) domain algorithm is proposed and verified in experiment by Matlab. The experimental result shows that the current method can achieve embedding with sound robustness and invisibility. From the experimental results, the quality of the watermarked image is almost no decline relative to the original. Keywords: DCT, watermarking, matlab, embedding 1. Introduction Along with the development of technologies about computer, network, and multimedia, the transmission of multimedia information such as music, image and video becomes more and more convenient, whereas the problem of copyright infringement has brought new opportunity for the effective protection of intellectual property. People invented a technique to hide the company logo, specific digital identifier and other information into the multimedia files for the sake of identification of ownership. Such a technique is called Digital Watermarking, which is a branch in the information hiding technology. The basic requirements are: 1) transparency, referring to that a certain amount of digital watermarking information is embedded in a digital media host, with the hidden data being imperceptible and without causing degradation to the original media; 2)robustness, referring to that the digital watermarking must be immune to the transformation applied on host media such as lossy compression, filtering and cropping, that is, the watermark information should not be lost due to some transformation applied to the host media; 3)safety, referring to that the digital watermark can resist all kinds of deliberate attack, and it is difficult to be copied or forged by others, as long as they do not know the secret key control algorithm. This paper focuses on a theme on DCT-based image digital watermark design and implementation. Improve a digital image watermarking algorithm which is based on DCT transform and Arnold scrambling. It is ensure the security of the watermarking by Arnold scrambling the original watermark information. The experimental results show that it is hiding the information of gray image, and make an experimental simulation on some common image attacks. 2. Dct Transformation Discrete Cosine Transform is based on orthogonal transform, which is one of the most commonly used linear transform in digital signal processing. It reflects the correlation properties of image signal. DCT algorithm is of moderate complexity, with medium energy consumption and has the good ability to energy compression. Thus, it is widely used in digital signal compression such as image A DCT Domain Image Watermarking Method Based on Matlab 39 compression and other fields. JPEG compression is a standard established on the basis of the DCT transform. Watermarking algorithm of JPEG compression standard has greatly enhanced the ability to resist JPEG compression based on watermark. So the DCT transform in watermark technology is very important. DCT transform decompose the image into a spectrum of different spatial frequencies ( ),F u v ,with ( ),u v known as the frequency domain coordinates. The inverse transform puts different spatial frequency components into the original image synthesis. In digital image processing often a two dimensional DCT transform is used. For a picture with the dimension M N× , the DCT transform is: 1 1 0 0 (2 1) (2 1) ( , ) ( ) ( ) ( , ) cos cos 2 2 M N x y x y F u c u c v f x y M N π π ν − − = = + + = ∑ ∑ (1) ( ) 1 0 2 1, 2, , M 1 uMc u uM  = =   = ⋅⋅⋅ −  (2) 1 0 ( ) 2 1, 2, , 1 vNc v v NN  = =   = ⋅⋅⋅ −  (3) The two dimensional inverse DCT transform formula is: N vy M ux vuFvcucyxf M u N v 2 )12( cos 2 )12( cos),()()(),( 1 0 1 0 ++ = ∑∑ − = − = ππ (4) Among them, x,y are spatial sampling values and u,v are the frequency domain sampling values. Because digital image is always measured by pixels, that is, M=N, in such cases, the two-dimensional DCT transform and inverse transform can be simplified as: 1 1 0 0 (2 1) (2 1) ( , ) ( ) ( ) ( , ) cos cos 2 2 N N x y x y F u c u c v f x y N N π π ν − − = = + + = ∑ ∑ (5) N vy N ux vuFvcucyxf N u N v 2 )12( cos 2 )12( cos),()()(),( 1 0 1 0 ++ = ∑∑ − = − = ππ 3. Discrete Cosine Transform Watermarking Embedding Algorithm Digital image watermarking algorithm that select the value of the two gray image as watermark information, choose the best one from different embedding coefficient. The vector image is 8*8 block, and the gray level digital watermark value directly embedded into the DCT transform domain vector in gray image, which realize the embedded watermarking. Specific methods are as follows: let I be the original image with the size of M N× , W is the watermark image with the size of P Q× , M and N are even times of P and Q, and the watermark W is loaded into the image I. The algorithm is divided into the following steps: 40 International Journal of Advanced Network Monitoring and Controls Volume 02, No.2, 2017 (1)I is divided into the block B with the size of ( / 8) * ( / 8)M N , and make a DCT transform; (2)By Arnold transform, B is divided into the block V with the size of (8 / ) * (8 / )P M Q N , and make a DCT transform; (3)Watermark is embedded according to the multiplicative watermarking algorithm, which put the block into the carrier image in I, and the IDCT transform is performing and get a new image with watermark. The program code is as follows: M=960; N=120; K=8; I=zeros(M,M); J=zeros(N,N); BLOCK=zeros(K,K); subplot(3,2,1); I=imread(‘lena.jpg’); I=rgb2gray(I); I=imresize(I,[960,960],’bicubic’); imwrite(I,’lena1.jpg’,’jpg’); imshow(I); title(‘original image’); subplot(3,2,2); J=imread(‘heida.jpg’); J=im2bw(J,0.4); J=imresize(J,[120,120],’bicubic’); imwrite(J,’heida2.jpg’,’jpg’); imshow(J); title(‘the original image’); for p=1:N for q=1:N x=(p-1)*K+1; y=(q-1)*K+1; A DCT Domain Image Watermarking Method Based on Matlab 41 BLOCK=I(x:x+K-1,y:y+K-1); BLOCK=dct2(BLOCK); if J(p,q)==0 a=-1; else a=1; end BLOCK=BLOCK*(1+a*0.03); BLOCK=idct2(BLOCK); I(x:x+K-1,y:y+K-1)=BLOCK; end end subplot(2,2,1); imshow(I); title(‘matermark image’); imwrite(I,’watermarked.jpg’,’jpg’); 4. Discrete Cosine Transform Watermark Extraction AlgorithmIn Set the image I as the carrier image with embedded watermark. Firstly, it need extract the watermark image from I, and the extraction process is the inverse of the embedded watermarking algorithm. (1) The image I is decomposed into the size of ( / 8) * ( / 8)M N ; (2) Make a DCT transform for each block; (3) Make each block watermark extraction process according to the multiplicative inverse algorithm ; (4) Make the IDCT transform, and a watermark image is synthesized. clear all M=960; N=120; K=8; A=imread(‘lena1.jpg’); %I=imread(‘watermarked.jpg’); %I=rgb2gray(I); 42 International Journal of Advanced Network Monitoring and Controls Volume 02, No.2, 2017 A=imresize(A,[960,960],’bicubic’); b=imread(‘watermarkedR.jpg’); for p=1:N for q=1:N x=(p-1)*K+1; y=(q-1)*K+1; BLOCK1=A(x:x+K-1,y:y+K-1); BLOCK2=b(x:x+K-1,y:y+K-1); BLOCK1=idct2(BLOCK1); BLOCK2=idct2(BLOCK2); if BLOCK1(1,1)==0 if BLOCK1(1,1)~=0 a=(BLOCK2(1,1)/BLOCK1(1,1))-1; if a<0 W(p,q)=0; else W(p,q)=1; end end end end subplot(2,2,1); imshow(W); title(‘the extracted watermark image’); imwrite(W,’w1.jpg’,’jpg’); 5. Experimental Results And Analysis In this paper, the experimental results are obtained based on MATLAB7.0 simulation. The original image uses the gray image of Lena, the watermark image is the two value image containing the words East University of Heilongjiang. A DCT Domain Image Watermarking Method Based on Matlab 43 (a)The original carrier image (b) Two value watermark image (c) The watermarking image after Figure.1 The watermark embedding test results We can see from the experimental results, the quality of the watermarked image is almost no decline relative to the original, almost invisible. Respectively, shear attacks、noise attacks、compression attacks are put on the watermarked image, and carries the watermark detection, get the following figure. (a) gray image after shear 10% (b) 10% shear watermarked image Figure.2 10% experimental results of shear (a) Gray image after shear 15% (b) 15% shear watermarked image Figure.3 15% experimental results of shear 44 International Journal of Advanced Network Monitoring and Controls Volume 02, No.2, 2017 (a) Gray image after shear 30% (b) 30% shear watermarked image Figure.4 30% experimental results of shear Table 1 normalized different shear ratio similarity coefficient From Table 1, we can see that according to the continuous change of different shear ratio, the extracted watermark image whose normalized similarity coefficient (NC)also showed different changes. According to the data in the above table and the extracted watermark image with different shear ratio, we can see that shearing off a portion of the image, but the relevant information from the original color image watermarking is still extracted. (a)Gauss joined the variance of noise image 0.02 (b)From the variance of 0.02 images extracted watermark Figure.5 Adding Gauss noise variance for experimental results of 0.02 (a)The compression factor of 70 gray image (b)From a factor of 70 images extracted watermark Figure.6 Experimental results for gray image compression factor of 70 Shear ratio 5% 10% 15% 20% 30% 50% NC 1 0.9980 0.9920 0.9880 0.9870 0.9827 A DCT Domain Image Watermarking Method Based on Matlab 45 Table 2 Different quality factor compression experimen We conducted various experiments to attack the algorithm, it is concluded that the algorithm can be well applied to copyright protection and authentication. The experiment results prove that the digital watermarking algorithm we used is a good robustness、transparency、low complexity algorithm. In a word,research on the digital watermarking technique is developed in recent years and more active. The research in this area has achieved some results, but the workload is not enough. More research is needed to obtain greater progress in this field. References [1] Hernandez J R, Amado M,Perez G F.DCT domain watermarking techniques for still images:Detector performance analysis and a new structure.IEEE Trans on Image Processing,2000,9(1):55-68. [ 2 ] A . Z . T r i k e l , G . A . R a n k i n a n d R . v a n S c h y n d e l . E l e c t r o n i c W a t e r m a r k [ C ] . I n : D i g i t a l I m a g e Computing,Technology and Applications-DICTA93, Macquarie University,1993:666-673. [3] R.G.Van Schyndel,A.Z.Tirkel and C.F.Osborne.A Digital Watermark[C]. Proceedings of IEEE International Conference on Image Processing, 1994,2:86-90. [4] Sun X M, Luo G,Huang HJ.Component-based digital watermarking of Chinese texts[C].Proceedings of the third International Conference on Information Security.Shanghai,China,2004,85:76-81. [5] P.S.Huang,C.S.Chiang, C.P.Chang.Robust Spatial Watermarking Technique for Color Images via Direct Saturation Adjustment[J]. Proceedings of IEEE:Vision, Image and Signa Processing, 2005, 152(5):561-571. [6] F.A.P.Petitcolas, R.J.Anderson and M.G.Kuhu.Information Hiding-A Survey[J].Proceedings of IEEE,1999,87(7):1062-1078. [7] G.Voyatzis and I. Pitas. The Use of Watermarks in the Protection of Digital Multimedia Products[J]. Proceedings of the IEEE, 1999, 87(7):1197-1207. [8] Nikolaidis N, Pitas I.Copyright Protection of Images Using Robust Digital Signatures[C].IEEE International Conference on Acoustics, Speech,and Signal Processing.USA,1996:2168-2171. [ 9 ] J . M . A c k e n . H o w W a t e r m a r k i n g A d d s V a l u e t o D i g i t a l C o n t e n t [ J ] . C o m m u n i c a t i o n s o f t h e ACM,1998,41(7):74-77. Quality factor(%) 90 80 70 60 50 40 30 NC 1 1 0.9930 0.9901 0.9850 0.9432 0.9120