Disclosure of Invention
The invention aims to provide a digital image blind watermarking method based on two-dimensional discrete cosine transform, which is characterized in that the realization of watermarking is divided into two processes of watermarking embedding and watermarking extracting, and the watermarking embedding process is described as follows:
the first step: host imagePreprocessing of watermark images: dividing a gray host image H with the size of MxM into non-overlapped pixel blocks with the size of Mxm; the method comprises the steps of carrying out private key Ka-based on a gray watermark image W with the size of N multiplied by N i To improve the security of the watermark and to convert each decimal pixel value in the watermark image W into an 8-bit binary sequence, connected in turn to a length of 8N 2 Watermark bit sequence SW of (a);
and a second step of: selecting an embedded block of the host image: selecting a pixel block A from the host image H by using a pseudo-random sequence generated by a random function;
and a third step of: according to formula (1), performing two-dimensional Discrete Cosine Transform (DCT) on the selected pixel block A to obtain a transformation matrix dctA, and selecting 4 pairs of DCT intermediate frequency coefficients (c i1, c i2 ) Where i=1, 2,3,4, respectively represent the i-th pair of DCT intermediate frequency coefficients;
dctA=dct2(A) (1)
wherein dct2 ()' is a two-dimensional discrete cosine transform function;
fourth step: sequentially selecting 4 watermark bits w from the watermark sequence SW according to the sequence i The method comprises the steps of carrying out a first treatment on the surface of the Using equations (2), (3), the DCT intermediate frequency coefficient pair (c) is modified i1, c i2 ) The size relationship between them to embed watermark bits w i ,i=1,2,3,4;
The definition rule of the custom function sign () is as follows:
where sign () is a signed function, avg= (abs (c) i1 )+abs(c i2 ) The step of quantization is known as) 2, TLong;
fifth step: with modified DCT intermediate frequency coefficient pair (c i1 * ,c i2 * ) Replacing the original DCT intermediate frequency coefficient pair (c i1 ,c i2 ) Obtaining a transformation matrix dctA containing watermarks * Where i=1, 2,3,4, respectively represent the i-th pair of DCT intermediate frequency coefficients;
sixth step: for the transformation matrix dctA according to equation (5) * Performing inverse two-dimensional discrete cosine transform to obtain a pixel block A containing watermark * And pixel block A containing watermark * Updating into the host image H;
A * =idct2(dctA * ) (5)
wherein idct2 ()'s are inverse two-dimensional discrete cosine transform functions;
seventh step: repeating the second to sixth steps until all watermark information is embedded, thereby obtaining a watermark-containing host image H * ;
The watermark extraction process is described as follows:
the first step: preprocessing of the watermark-containing host image: will contain the watermark host image H * Dividing into non-overlapping pixel blocks with the size of m multiplied by m;
and a second step of: selecting an extraction block containing a watermark host image: pseudo-random sequence generated using randperm function from watermark-containing host image H * Selecting a pixel block A containing a watermark * ;
And a third step of: for selected blocks A of pixels containing ink * Performing two-dimensional discrete cosine transform to obtain a transformation matrix dctA * And selecting a transformation matrix dctA according to the Z shape * 4 pairs of DCT intermediate frequency coefficients (c) i1 * , c i2 * ) Where i=1, 2,3,4, respectively represent the i-th pair of DCT intermediate frequency coefficients;
fourth step: based on the DCT intermediate frequency coefficient pair (c
i1 * , c
i2 * ) The size relationship between the pixel blocks A is printed from the water by using the formula (6)
* Extracting watermark bits from a watermark
Where abs (, i=1, 2,3, 4) is an absolute function;
fifth step: repeating the second to fourth steps to obtain the binary watermark sequence SW of the extracted watermark-containing image * Watermark sequence SW * Dividing each 8 bits of binary information into a group and converting the group into decimal pixel values to obtain a decimal number column;
sixth step: the decimal number sequence is based on the private key Ka i Is transformed by the inverse Arnold to obtain the final extracted watermark W * 。
The method utilizes the size relation between DCT intermediate frequency coefficients in two-dimensional discrete cosine transformation to finish the embedding and blind extraction of the digital watermark; the method has better watermark invisibility and stronger watermark robustness.
Drawings
Fig. 1 (a), 1 (b) are two original gray scale host images.
Fig. 2 (a), 2 (b) are two original grayscale watermark images.
Fig. 3 (a) and 3 (b) are watermark images obtained by embedding the watermark shown in fig. 2 (a) into the host image in sequence in fig. 1 (a) and 1 (b), wherein the structural similarity SSIM values are 0.9283 and 0.9696 in sequence, and the peak signal to noise ratio PSNR values are 42.8192dB and 41.3844dB in sequence.
Fig. 4 (a) and 4 (b) are watermarks extracted from fig. 3 (a) and 3 (b) in order, and normalized cross-correlation coefficient NC values thereof are 1.0000 and 1.0000, respectively.
Fig. 5 (a), 5 (b), 5 (c), 5 (d), 5 (e), and 5 (f) are watermarks extracted by sequentially subjecting the watermark image shown in fig. 3 (a) to attacks such as JPEG2000 compression (6:1), salt and pepper noise (0.2%), JPEG compression (60), low-pass filtering (100, 4), scaling (75%), and shearing (12.5%), and the normalized cross-correlation coefficient NC values thereof are 0.9959, 0.9623, 0.9799, 0.9740, 1.0000, and 0.9865, respectively.
Fig. 6 (a) and 6 (b) show watermark images obtained by embedding the watermark shown in fig. 2 (b) into the host image in sequence in fig. 1 (a) and 1 (b), wherein the structural similarity SSIM values are 0.9303 and 0.9689 in sequence, and the peak signal-to-noise ratio PSNR values are 42.9986dB and 41.0945dB in sequence.
Fig. 7 (a) and 7 (b) are watermarks extracted from fig. 6 (a) and 6 (b) in order, and normalized cross-correlation coefficient NC values thereof are 1.0000 and 1.0000, respectively.
Fig. 8 (a), 8 (b), 8 (c), 8 (d), 8 (e), and 8 (f) are watermarks extracted by sequentially subjecting the watermark image shown in fig. 6 (a) to attacks such as JPEG2000 compression (6:1), salt and pepper noise (0.2%), JPEG compression (60), low-pass filtering (100, 4), scaling (75%), and shearing (12.5%), and the normalized cross-correlation coefficient NC values thereof are 0.9967, 0.9693, 0.9810, 0.9750, 0.9999, 0.9885, respectively.
Detailed Description
The invention aims to provide a digital image blind watermarking method based on two-dimensional discrete cosine transform, which is characterized in that the realization of watermarking is divided into two processes of watermarking embedding and watermarking extracting, and the watermarking embedding process is described as follows:
the first step: preprocessing a host image and a watermark image: dividing a gray host image H with the size of 512 multiplied by 512 into non-overlapped pixel blocks with the size of 8 multiplied by 8; the method comprises the steps of carrying out private key Ka-based on a gray watermark image W with the size of 32 multiplied by 32 i To increase the security of the watermark and to convert each decimal pixel value in the watermark image W into an 8-bit binary sequence (e.g., decimal number 214 may be converted into binary sequence '11010110'), which in turn are connected into a watermark bit sequence SW of length 8 x 32 2 =8192;
And a second step of: selecting an embedded block of the host image: selecting a pixel block A from the host image H by using a pseudo-random sequence generated by a random function, wherein the selected pixel block A is set as
And a third step of: according to formula (1), performing two-dimensional Discrete Cosine Transform (DCT) on the selected pixel block A to obtain a transformation matrix dctA, and selecting 4 pairs of DCT intermediate frequency coefficients (c i1, c i2 ) Wherein i=1, 2,3,4, respectively represent the i-th pair of DCT intermediate frequency coefficients;
dctA=dct2(A) (1)
wherein dct2 ()' is a two-dimensional discrete cosine transform function; at this time, a transform matrix dctA obtained by performing two-dimensional discrete cosine transform on the pixel block a is
4 pairs of DCT intermediate frequency coefficients (c) of the transformation matrix dctA are selected according to zigzags
i1, c
i2 ) (-9.4018,11.4220), (15.9976, -5.8750), (-9.0920,13.1825), (4.7516,3.8495), respectively;
fourth step: sequentially selecting 4 watermark bits w from the watermark sequence SW according to the sequence i The method comprises the steps of carrying out a first treatment on the surface of the Using equations (2), (3), the DCT intermediate frequency coefficient pair (c) is modified i1, c i2 ) The size relationship between them to embed watermark bits w i ,i=1,2,3,4;
The definition rule of the custom function sign () is as follows:
where sign () is a signed function, avg= (abs (c) i1 )+abs(c i2 ) T is the quantization step size,/2; at this time, 4 watermark bits selected from the watermark sequence SWw i Is '0', '0'; modified DCT intermediate frequency coefficient pair (c i1 * , c i2 * ) (-27.2119,3.2119), (15.9976, -5.8750), (-27.9372,3.9372), (21.1005, -2.8995);
fifth step: with modified DCT intermediate frequency coefficient pair (c i1 * , c i2 * ) Replacing the original DCT intermediate frequency coefficient pair (c i1, c i2 ) Obtaining a transformation matrix dctA containing watermarks * Wherein i=1, 2,3,4, respectively represent the i-th pair of DCT intermediate frequency coefficients; at this time, the transformation matrix dctA containing the watermark * Is that
Sixth step: for the transformation matrix dctA according to equation (5) * Performing inverse two-dimensional discrete cosine transform to obtain a pixel block A containing watermark * And pixel block A containing watermark * Updating into the host image H;
A * =idct2(dctA * ) (5)
wherein idct2 ()'s are inverse two-dimensional discrete cosine transform functions; at this time, pixel block A containing watermark * Is that
Seventh step: repeating the second to sixth steps until all watermark information is embedded, thereby obtaining a watermark-containing host image H * ;
The watermark extraction process is described as follows:
the first step: preprocessing of the watermark-containing host image: will contain the watermark host image H * Dividing into non-overlapping pixel blocks with the size of 8 multiplied by 8;
and a second step of: selecting a block of pixels containing a watermark host image: pseudo-random sequence generated using randperm function from watermark-containing host image H * Selecting a pixel block A containing a watermark * The method comprises the steps of carrying out a first treatment on the surface of the At this time, a pixel block A containing a watermark is provided * Is that
And a third step of: for selected blocks A of pixels containing ink
* Performing two-dimensional discrete cosine transform to obtain a transformation matrix dctA
* And selecting a transformation matrix dctA according to the Z shape
* 4 pairs of DCT intermediate frequency coefficients (c)
i1 * , c
i2 * ) Where i=1, 2,3,4, respectively represent the i-th pair of DCT intermediate frequency coefficients; at this time, a transformation matrix dctA obtained after two-dimensional discrete cosine transformation
* Is that
Selected 4 pairs of DCT intermediate frequency coefficients (c
i1 * , c
i2 * ) (-27.1567,3.2463), (15.8511, -5.5000), (-27.7883,4.2891), (21.0825, -2.2370), respectively;
fourth step: based on the DCT intermediate frequency coefficient pair (c
i1 * , c
i2 * ) The size relationship between the pixel blocks A is printed from the water by using the formula (6)
* Extracting watermark bits from a watermark
Where abs (, i=1, 2,3, 4) is an absolute function; at this time, the extracted watermark bits
Respectively '0', '0';
fifth step: repeating the second to fourth steps to obtain the binary system of the extracted watermark-containing imageWatermark sequence SW * Watermark sequence SW * Dividing each 8 bits of binary information into a group and converting the group into decimal pixel values to obtain a decimal number column;
sixth step: the decimal number sequence is based on the private key Ka i Is transformed by the inverse Arnold to obtain the final extracted watermark W * 。
The method is simple and quick, strong in robustness, good in watermark invisibility and suitable for copyright protection of the digital image serving as the watermark.
The invention has the effect of verification
To prove the effectiveness of the present invention, two standard images of 24 bits of 512×512 size as shown in fig. 1 (a) and 1 (b) were selected as host images, and two gray-scale images of 24 bits of 32×32 size as shown in fig. 2 (a) and 2 (b) were used as digital watermarks, respectively, for verification.
Fig. 3 (a) and 3 (b) are watermark images obtained by embedding the watermarks shown in fig. 2 (a) into the host images in sequence in fig. 1 (a) and 1 (b), wherein the structural similarity SSIM values are 0.9283 and 0.9696 in sequence, and the peak signal-to-noise ratio PSNR values are 42.8192dB and 41.3844dB in sequence; fig. 4 (a) and 4 (b) are watermarks extracted from fig. 3 (a) and 3 (b) in sequence, and normalized cross-correlation coefficient NC values thereof are 1.0000 and 1.0000, respectively; fig. 5 (a), 5 (b), 5 (c), 5 (d), and 5 (e) are watermarks extracted after the watermark image shown in fig. 3 (a) is subjected to attacks such as JPEG2000 compression (6:1), salt and pepper noise (0.2%), JPEG compression (60), low-pass filtering (100, 4), scaling (75%), and shearing (12.5%), and the normalized cross-correlation coefficient NC values thereof are 0.9959, 0.9623, 0.9799, 0.9740, 1.0000, 0.9865, respectively.
Fig. 6 (a) and 6 (b) are watermark images obtained by embedding the watermarks shown in fig. 2 (b) into the host images in sequence in fig. 1 (a) and 1 (b), wherein the structural similarity SSIM values are 0.9303 and 0.9689 in sequence, and the peak signal-to-noise ratio PSNR values are 42.9986dB and 41.0945dB in sequence; fig. 7 (a) and 7 (b) are watermarks extracted from fig. 6 (a) and 6 (b) in order, and normalized cross-correlation coefficient NC values thereof are 1.0000 and 1.0000, respectively; fig. 8 (a), 8 (b), 8 (c), 8 (d), 8 (e), and 8 (f) are watermarks extracted by sequentially subjecting the watermark image shown in fig. 6 (a) to attacks such as JPEG2000 compression (6:1), salt and pepper noise (0.2%), JPEG compression (60), low-pass filtering (100, 4), scaling (75%), and shearing (12.5%), and the normalized cross-correlation coefficient NC values thereof are 0.9967, 0.9693, 0.9810, 0.9750, 0.9999, 0.9885, respectively.
In summary, the embedded digital image watermark has better invisibility, and meets the invisibility requirement of a watermark algorithm; meanwhile, the digital image watermark extracted from various attacked images has better authenticability and higher NC value, which indicates that the method has stronger robustness and meets the requirement of digital image copyright protection.