Disclosure of Invention
In order to solve the above problems in the prior art, the present invention provides a digital watermark processing method, apparatus, electronic device, and storage medium. The technical problem to be solved by the invention is realized by the following technical scheme:
a digital watermarking method, comprising:
acquiring at least one image to be embedded containing a face region;
extracting the face area of the image to be embedded and splicing to obtain a digital watermark image, wherein the digital watermark image is a binary image, and the size of the digital watermark image is the same as that of the image to be embedded;
dividing the image to be embedded of a preset channel of a YCbCr color space into a plurality of first image blocks with preset sizes;
and based on a dithering quantization index modulation algorithm, carrying out quantization embedding processing on the coefficients in the first image block by using the digital watermark image so as to obtain an image with an RGB color space and a digital watermark embedded therein.
In an embodiment of the present invention, extracting the face region of the image to be embedded and splicing the face region to obtain a digital watermark image, includes:
extracting a face region in the image to be embedded to obtain a face image;
carrying out gray level processing on the face image to obtain a face gray level image;
carrying out binary conversion on the face gray level image to obtain a binary face image;
and expanding the plurality of binary face images in a repeated arrangement mode to obtain the digital watermark image.
In an embodiment of the present invention, the dividing the image to be embedded of a preset channel of the YCbCr color space into a plurality of first image blocks includes:
converting the color space of the image to be embedded from an RGB color space to a YCbCr color space;
and dividing the image to be embedded of the preset channel in the YCbCr color space into a plurality of first image blocks according to a preset size.
In an embodiment of the present invention, based on a dithering quantization index modulation algorithm, performing quantization embedding processing on coefficients in the first image block by using the digital watermark image to obtain a digital watermark embedded image in an RGB color space, including:
performing discrete cosine transform processing on the first image block to obtain a second image block;
obtaining the first quantization result according to the coefficient of the kth pixel in the second image block, a quantizer corresponding to the f-dimensional vector of the digital watermark image and the quantization step size matrix, wherein the quantizer is generated according to a random number and the quantization step size matrix;
obtaining a coefficient of a kth pixel of the third image block according to the first quantization result and a quantizer corresponding to the f-dimensional vector of the digital watermark image;
carrying out inverse discrete cosine transform processing on the third image block to obtain a fourth image block;
and packaging all the fourth image blocks of the preset channel and the to-be-embedded images of the other channels to obtain the digital watermark embedded images in the RGB color space.
In an embodiment of the present invention, the size of the first image block is 8 × 8, and the quantization step size matrix is:
where Δ represents a quantization step matrix.
In an embodiment of the present invention, after obtaining the digital watermark embedded image in RGB color space, the method further includes:
converting the color space of the image embedded with the digital watermark from an RGB color space to a YCbCr color space;
dividing the image of the preset channel embedded with the digital watermark in the YCbCr color space into a plurality of fifth image blocks with preset sizes;
processing the fifth image block by using discrete cosine transform to obtain a sixth image block;
correspondingly obtaining a first coordinate position and a second coordinate position according to a coefficient of a kth pixel of the sixth image block and a first quantizer and a second quantizer corresponding to an f-dimension vector of the digital watermark image, wherein the first quantizer is generated according to a random number and a quantization step matrix, and the second quantizer is generated according to the first quantizer and the quantization step matrix;
respectively calculating absolute values of distances from the first coordinate position and the second coordinate position to a k-th pixel of the sixth image block, if the absolute value of the distance from the first coordinate position to the k-th pixel of the sixth image block is smaller than or equal to the absolute value of the distance from the second coordinate position to the k-th pixel of the sixth image block, setting an embedded watermark information value of the k-th pixel of the sixth image block to be 0, and if the absolute value of the distance from the first coordinate position to the k-th pixel of the sixth image block is larger than the absolute value of the distance from the second coordinate position to the k-th pixel of the sixth image block, setting the embedded watermark information value of the k-th pixel of the sixth image block to be 1.
In an embodiment of the present invention, obtaining a first coordinate position and a second coordinate position according to a coefficient of a kth pixel of the sixth image block and a first quantizer and a second quantizer corresponding to an f-th dimension vector of the digital watermark image, includes:
obtaining a second quantization result according to the coefficient of the kth pixel in the sixth image block, the first quantizer corresponding to the f-dimension vector of the digital watermark image and the quantization step matrix;
obtaining the first coordinate position according to the second quantization result and a first quantizer corresponding to the f-dimensional vector of the digital watermark image;
obtaining a third quantization result according to the coefficient of the kth pixel in the sixth image block, a second quantizer corresponding to the f-dimensional vector of the digital watermark image and the quantization step matrix;
and obtaining the second coordinate position according to the third quantization result and a second quantizer corresponding to the f-dimension vector of the digital watermark image.
An embodiment of the present invention further provides a digital watermark processing apparatus, including:
the image to be embedded acquisition module is used for acquiring at least one image to be embedded containing a face area;
the splicing module is used for extracting the face area of the image to be embedded and splicing to obtain a digital watermark image, wherein the digital watermark image is a binary image, and the size of the digital watermark image is the same as that of the image to be embedded;
the segmentation module is used for segmenting the image to be embedded of a preset channel of the YCbCr color space into a plurality of first image blocks with preset sizes;
and the digital watermark embedding module is used for carrying out quantization embedding processing on the coefficients in the first image block by utilizing the digital watermark image based on a dithering quantization index modulation algorithm so as to obtain an image of an RGB color space, wherein the digital watermark is embedded in the image.
An embodiment of the present invention further provides an electronic device, which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor, configured to implement the steps of the digital watermark processing method according to any one of the above embodiments when executing the computer program.
An embodiment of the present invention further provides a storage medium, where a computer program is stored in the storage medium, and when executed by a processor, the computer program implements the steps of the digital watermark processing method according to any one of the above embodiments.
The invention has the beneficial effects that:
the invention utilizes a dithering quantization index modulation algorithm and a digital watermark image to carry out quantization embedding processing on the coefficient in the first image block together, thereby obtaining an image embedded with the digital watermark, and the digital watermark image is obtained by splicing the face area of the image to be embedded.
The present invention will be described in further detail with reference to the drawings and examples.
Detailed Description
The present invention will be described in further detail with reference to specific examples, but the embodiments of the present invention are not limited thereto.
Example one
Referring to fig. 1, fig. 1 is a flowchart illustrating a digital watermark embedding method according to an embodiment of the present invention. The embodiment of the invention provides a digital watermark processing method, which can comprise a digital watermark embedding method part and/or a digital watermark extracting method part, and firstly introduces the digital watermark embedding method part in the digital watermark processing method, specifically, the digital watermark embedding part can comprise:
step 1.1, obtaining at least one image to be embedded containing a face area;
step 1.2, extracting a face area of an image to be embedded and splicing to obtain a digital watermark image, wherein the digital watermark image is a binary image, and the size of the digital watermark image is the same as that of the image to be embedded;
1.3, dividing an image to be embedded of a preset channel of a YCbCr color space into a plurality of first image blocks with preset sizes;
and step 1.4, based on a dithering quantization index modulation algorithm, carrying out quantization embedding processing on coefficients in the first image block by using the digital watermark image so as to obtain an image of an RGB color space, wherein the digital watermark is embedded in the image.
In this embodiment, the obtained image to be embedded may be obtained by obtaining video data, or may be other images including a human face, and if the image is video data, a video processing tool such as a Fast Forward Mpeg (multimedia processing tool) is required to segment the video into video frames.
Then, a face region in the image to be embedded needs to be extracted, and the extracted image containing the face region is spliced into a digital watermark image with the same size as the image to be embedded, wherein the digital watermark image is a binary image.
In addition, in order to obtain a better digital watermark embedding effect, in this embodiment, an image to be embedded of a preset channel in the YCbCr color space is subjected to segmentation processing, so as to obtain a plurality of first image blocks of a preset size, where the preset size is, for example, 8 × 8, and the preset size may also be other values. And it is preferable to preset the channel to be the Y channel since the loss of the Y channel at the time of the image compression operation is minimized. Finally, the coefficients in the first image block are quantized and embedded by using a jitter Quantization Index Modulation (QIM-DM) algorithm and the digital watermark image, so that the watermark can be embedded into the first image block, and then all the first image blocks embedded with the watermark in the preset channel and the images to be embedded in the other channels are encapsulated, so that the image embedded with the digital watermark can be obtained.
Referring to fig. 2, in an embodiment, step 1.2 may specifically include steps 1.21 to 1.24, where:
and step 1.21, extracting a face region to be embedded into the image to obtain a face image.
Specifically, a face region in the image to be embedded may be detected by using a face recognition algorithm (e.g., dlib face detection library function, dlib is a C + + written tool package), and then the face region in the image to be embedded is extracted, so as to obtain a face image, and the face image is used as the digital watermark to be processed.
And step 1.22, carrying out gray processing on the face image to obtain a face gray image.
Specifically, the extracted face image is subjected to image graying processing, so that a face grayscale image is obtained, and the pixel value of the face grayscale image is 0 to 255.
And step 1.23, carrying out binary conversion on the face gray level image to obtain a binary face image.
Specifically, the binary face image is a binary image, and a specific conversion method thereof is to set the pixel in the face grayscale image to be lower than 127 as 0 and to be greater than or equal to 127 as 255.
And step 1.24, expanding a plurality of binary face images in a repeated arrangement mode to obtain digital watermark images.
Specifically, after the binary face images are obtained, the multiple binary face images are expanded in a repeated arrangement mode according to the size of the image to be embedded, so that a digital watermark image which is only composed of the binary face images and has the same size as the image to be embedded is obtained, and the binary face images are not overlapped when being repeatedly arranged.
In a particular embodiment, step 1.3 may particularly comprise steps 1.31 to 1.32, wherein:
and 1.31, converting the color space of the image to be embedded from the RGB color space to the YCbCr color space.
Step 1.32, dividing an image to be embedded of a preset channel in a YCbCr color space into a plurality of first image blocks according to a preset size.
Specifically, the preset channel selects a Y channel, and an image to be embedded of the Y channel in the YCbCr color space is divided into a plurality of first image blocks according to a preset size according to formula (1).
In a particular embodiment, step 1.4 may particularly comprise steps 1.41 to 1.45, wherein:
and 1.41, performing discrete cosine transform processing on the first image block to obtain a second image block.
Specifically, each first image block is subjected to Discrete Cosine Transform (DCT) by using a Discrete Cosine Transform formula, the first image block is subjected to Discrete Cosine Transform to obtain a corresponding second image block, and the Discrete Cosine Transform formula is as follows:
where F (u, v) denotes a value of the coordinate point (u, v) in the first image block after DCT transformation, F (i, j) denotes a pixel value of the coordinate point (i, j) in the first image block, W denotes a width of the first image block, H denotes a length of the first image block, and preferably, W is H, λ takes u or v.
And step 1.42, obtaining a first quantization result according to the coefficient of the kth pixel in the second image block, a quantizer corresponding to the f-dimension vector of the digital watermark image and a quantization step size matrix, wherein the quantizer is generated according to the random number and the quantization step size matrix.
Specifically, the coefficient of the kth pixel in the second image block, the quantizer corresponding to the f-dimension vector of the digital watermark image, and the quantization step matrix are substituted into a quantization calculation formula to obtain a first quantization result, where the quantization calculation formula is:
Q(I)=[I/Δ]·Δ (3)
wherein, I ═ Ck+d(Wf),CkThe coefficients representing the pixels of the first order in the second image block, which are the coefficients of the DCT transformed pixels, d (W)f) Quantizer, W, corresponding to the f-th vector representing the digital watermark imagefThe watermark information value (also vector value) of the f-th dimension vector representing the digital watermark image has a value ranging from 0 to (W)1*H1-1),W1For the width of the digital watermark image, H1Δ represents a quantization step matrix for the width of the digital watermark image.
Further, in order to reduce the problem that the image is distorted after the digital watermark is embedded, the quantization step size matrix is:
in addition, since the method uses a binary watermark image, the quantizer includes two types of quantizers, namely a first quantizer d0 and a second quantizer d1, as shown in formula (5), and the first quantizer d0 and the second quantizer d1 select the watermark information value W of the f-th dimension vector in the binary watermark image (i.e. the digital watermark image)fTo determine, d0 represents when WfQuantizer at value 0, d1 denotes when W isfA quantizer at a value of 1; as shown in formula (6), the first quantizer d0 is composed of a product of a random number R and Δ, where R and Δ can be used as private keys of the user, and once the user sets a private key and adds a watermark to an image, the watermark can be extracted only by using the private key; the calculation of d1 is related to d0 as shown in equation (7).
d0=R*Δ,R∈(0,1] (6)
And step 1.43, obtaining the coefficient of the kth pixel of the third image block according to the first quantization result and the quantizer corresponding to the f-dimension vector of the digital watermark image.
Specifically, the difference is made between the first quantization result and the quantizer corresponding to the f-dimensional vector of the digital watermark image according to an embedding formula to obtain the coefficient of the kth pixel of the third image block, where the embedding formula is:
C′k=Q(Ck+d(Wf))-d(Wf) (8)
wherein, C'kAnd the coefficient of the first-order pixel of the third image block is the embedding result, and the third image block is the image block after the digital watermark is embedded in the second image block.
And 1.44, performing inverse discrete cosine transform processing on the third image block to obtain a fourth image block.
After the above processing, each third image block is embedded with a digital watermark, and then an inverse discrete cosine transform operation needs to be performed on each third image block to obtain a fourth image block, wherein the formula of the inverse discrete cosine transform is as follows:
where f (i, j) represents a pixel value of the coordinate point (i, j) in the first image block.
And step 1.45, packaging all fourth image blocks of the preset channel and the images to be embedded of the other channels to obtain the images of the RGB color space with the digital watermarks embedded.
Specifically, if the preset channel is a Y channel, a new luminance channel Y can be obtained after the inverse discrete cosine transform operation0Will be the luminance channel Y0All the fourth image blocks in the image are spliced according to the arrangement mode of the pixels of the image to be embedded to obtain a brightness channel Y0Embedding the image of the digital watermark, then packaging the image and the image to be embedded of the other channels (namely Cb and Cr channels) to obtain the image of the embedded digital watermark, as shown in a formula (10), finally converting the color space of the image of the embedded digital watermark from a YCbCr color space to an RGB color space, and finally obtaining the RGB color space, if the processed video data is, finally packaging the image of the embedded digital watermark into a video.
Referring to fig. 3 and fig. 4, fig. 3 is a schematic flowchart of a digital watermark extraction method according to an embodiment of the present invention, and fig. 4 is a schematic process diagram of the digital watermark extraction method according to the embodiment of the present invention. In addition, after the digital watermark is embedded into the image to be embedded, the digital watermark needs to be extracted, so that the digital watermark extraction method in the digital watermark processing method is also introduced in this embodiment, specifically, the digital watermark extraction method may include steps 2.1 to 2.5, where:
and 2.1, converting the color space of the image embedded with the digital watermark from an RGB color space to a YCbCr color space.
The digital watermark embedding method in the above embodiment is used to obtain the digital watermark embedded image in RGB color space, and then the color space of the image is converted from RGB color space to YCbCr color space.
And 2.2, dividing the image embedded with the digital watermark of a preset channel in the YCbCr color space into a plurality of fifth image blocks with preset sizes.
Specifically, if the Y channel is selected as the preset channel, the image to be embedded of the Y channel in the YCbCr color space is divided into a plurality of fifth image blocks according to a preset size, preferably, the preset size is 8 × 8.
And 2.3, processing the fifth image block by using discrete cosine transform to obtain a sixth image block.
Specifically, discrete cosine transform is performed on each fifth image block by using a discrete cosine transform formula, and the fifth image block is subjected to discrete cosine transform to correspondingly obtain a sixth image block.
And 2.4, correspondingly obtaining a first coordinate position and a second coordinate position according to the coefficient of the kth pixel of the sixth image block and a first quantizer and a second quantizer corresponding to the f-dimensional vector of the digital watermark image, wherein the first quantizer is generated according to a random number and a quantization step matrix, and the second quantizer is generated according to the first quantizer and the quantization step matrix.
Specifically, since the first coordinate position is obtained according to the coefficient of the kth pixel of the sixth image block and the first quantizer corresponding to the f-dimensional vector of the digital watermark image, and the second coordinate position is obtained according to the coefficient of the kth pixel of the sixth image block and the second quantizer corresponding to the f-dimensional vector of the digital watermark image, the watermark information value of each pixel in the sixth image block can be determined by judging the distance between the coefficient of the kth pixel of the sixth image block and the first coordinate position and the distance between the coefficient of the kth pixel of the sixth image block and the second coordinate position, respectively, so as to realize extraction of the watermark.
Further, step 2.4 may specifically comprise steps 2.41-2.44, wherein,
and 2.41, obtaining a second quantization result according to the coefficient of the kth pixel in the sixth image block, the first quantizer corresponding to the f-dimension vector of the digital watermark image and the quantization step size matrix.
Specifically, the coefficient of the kth pixel in the sixth image block, the first quantizer corresponding to the f-dimensional vector of the digital watermark image, and the quantization step size matrix are substituted into the quantization calculation formula to obtain the second quantization result, where I ═ C ″ ", where I isk+d0,C″kAnd a coefficient representing the kth pixel in the sixth image block, which is a DCT-transformed coefficient.
And 2.42, obtaining a first coordinate position according to the second quantization result and the first quantizer corresponding to the f-dimension vector of the digital watermark image.
Specifically, substituting the second quantization result and a first quantizer corresponding to the f-th dimension vector of the digital watermark image into a first coordinate position calculation formula to obtain a first coordinate position, where the first coordinate position calculation formula is:
L0=Q(C″k+d0)-d0 (11)
wherein L is0Representing a first coordinate position.
And 2.43, obtaining a third quantization result according to the coefficient of the kth pixel in the sixth image block, the second quantizer corresponding to the f-dimension vector of the digital watermark image and the quantization step matrix.
Specifically, the coefficient of the kth pixel in the sixth image block and the f-dimension vector of the digital watermark image are corresponded toAnd substituting the two quantizers and a quantization step matrix to obtain a third quantization result, wherein I ═ C ″k+d1。
And 2.44, obtaining a second coordinate position according to the third quantization result and a second quantizer corresponding to the f-dimension vector of the digital watermark image.
Specifically, substituting the third quantization result and a second quantizer corresponding to the f-th dimension vector of the digital watermark image into a second coordinate position calculation formula to obtain a second coordinate position, where the first coordinate position calculation formula is:
L1=Q(C″k+d0)-d0 (12)
wherein L is1Representing a second coordinate position.
Step 2.5, absolute values of distances from the first coordinate position and the second coordinate position to a k-th pixel of the sixth image block are respectively calculated, if the absolute value of the distance from the first coordinate position to the k-th pixel of the sixth image block is smaller than or equal to the absolute value of the distance from the second coordinate position to the k-th pixel of the sixth image block, the embedded watermark information value of the k-th pixel of the sixth image block is set to be 0, and if the absolute value of the distance from the first coordinate position to the k-th pixel of the sixth image block is larger than the absolute value of the distance from the second coordinate position to the k-th pixel of the sixth image block, the embedded watermark information value of the k-th pixel of the sixth image block is set to be 1.
Specifically, the absolute values of the distances from the first coordinate position and the second coordinate position to the k-th pixel of the sixth image block are calculated according to a distance calculation formula, where the distance calculation formula is:
wherein D is0Representing the absolute value of the distance, D, of the first coordinate position to the coefficient of the k-th pixel of the sixth image block1Representing the absolute value of the distance of the second coordinate position to the coefficient of the kth pixel of the sixth image block.
According toAccording to the formula (14), when D0Less than or equal to D1When the embedded watermark information value of the kth pixel of the sixth image block is 0, when D0Greater than D1Then, the embedded watermark information value of the kth pixel of the sixth image block is 0.
Based on the steps, the watermark of each sixth image block can be extracted, so that whether the sixth image block is subjected to the deep forgery attack or not can be judged through the extracted watermark.
After an original image (namely an image to be embedded) is added with a watermark, only a user with a private key can extract the hidden watermark in the image, because the R and delta values set by the user determine a quantization step matrix of the image, which determines the final result of watermark extraction, other people cannot successfully extract the watermark, and if the extracted watermark is the same as the face of a person in the image and the shape of the watermark is kept complete, a conclusion can be drawn that the image or video is not attacked by deep forgery, the image or video is real, or else the image or video is forged.
The coefficient in the first image block is quantized and embedded by using a QIM-DM dithering quantization index modulation algorithm and a digital watermark image, so that an image embedded with the digital watermark is obtained, and the digital watermark image is obtained by splicing the face area of the image to be embedded.
Example two
Referring to fig. 5, fig. 5 is a schematic structural diagram of a digital watermark processing apparatus according to an embodiment of the present invention. The digital watermark processing apparatus includes:
the image to be embedded acquisition module is used for acquiring at least one image to be embedded containing a face area;
the splicing module is used for extracting a face area of an image to be embedded and splicing to obtain a digital watermark image, wherein the digital watermark image is a binary image, and the size of the digital watermark image is the same as that of the image to be embedded;
the device comprises a segmentation module, a detection module and a display module, wherein the segmentation module is used for segmenting an image to be embedded of a preset channel of a YCbCr color space into a plurality of first image blocks with preset sizes;
and the digital watermark embedding module is used for carrying out quantization embedding processing on the coefficients in the first image block by utilizing the digital watermark image based on a dithering quantization index modulation algorithm so as to obtain the image of the RGB color space, wherein the digital watermark is embedded in the image.
In an embodiment of the present invention, the stitching module may be specifically configured to extract a face region in an image to be embedded to obtain a face image; carrying out gray level processing on the face image to obtain a face gray level image; carrying out binary conversion on the face gray level image to obtain a binary face image; and expanding a plurality of binary face images in a repeated arrangement mode to obtain the digital watermark image.
In an embodiment of the present invention, the segmentation module may be specifically configured to convert a color space of the image to be embedded from an RGB color space to a YCbCr color space; and dividing an image to be embedded of a preset channel in the YCbCr color space into a plurality of first image blocks according to a preset size.
In an embodiment of the present invention, the digital watermark embedding module may be specifically configured to perform a discrete cosine transform processing on a first image block to obtain a second image block; obtaining a first quantization result according to the coefficient of the kth pixel in the second image block, a quantizer corresponding to the f-dimensional vector of the digital watermark image and a quantization step size matrix, wherein the quantizer is generated according to the random number and the quantization step size matrix; obtaining a coefficient of a kth pixel of the third image block according to the first quantization result and a quantizer corresponding to the f-dimensional vector of the digital watermark image; carrying out inverse discrete cosine transform processing on the third image block to obtain a fourth image block; and packaging all the fourth image blocks of the preset channel and the images to be embedded of the other channels to obtain the images with the digital watermarks embedded in the RGB color space.
In an embodiment of the present invention, the digital watermark processing apparatus further includes a digital watermark extraction module, where the digital watermark extraction module is specifically configured to convert a color space of an image in which the digital watermark is embedded from an RGB color space to a YCbCr color space; dividing an image of a preset channel in the YCbCr color space, in which the digital watermark is embedded, into a plurality of fifth image blocks with preset sizes; processing the fifth image block by using discrete cosine transform to obtain a sixth image block; correspondingly obtaining a first coordinate position and a second coordinate position according to the coefficient of the kth pixel of the sixth image block and a first quantizer and a second quantizer corresponding to the f-dimension vector of the digital watermark image, wherein the first quantizer is generated according to a random number and a quantization step matrix, and the second quantizer is generated according to the first quantizer and the quantization step matrix; respectively calculating absolute values of distances from the first coordinate position and the second coordinate position to a k-th pixel of the sixth image block, if the absolute value of the distance from the first coordinate position to the k-th pixel of the sixth image block is smaller than or equal to the absolute value of the distance from the second coordinate position to the k-th pixel of the sixth image block, setting an embedded watermark information value of the k-th pixel of the sixth image block to be 0, and if the absolute value of the distance from the first coordinate position to the k-th pixel of the sixth image block is larger than the absolute value of the distance from the second coordinate position to the k-th pixel of the sixth image block, setting the embedded watermark information value of the k-th pixel of the sixth image block to be 1.
Furthermore, the digital watermark extraction module is further configured to obtain a second quantization result according to a coefficient of a kth pixel in the sixth image block, the first quantizer corresponding to the f-dimensional vector of the digital watermark image, and the quantization step size matrix; obtaining a first coordinate position according to the second quantization result and a first quantizer corresponding to the f-dimension vector of the digital watermark image; obtaining a third quantization result according to the coefficient of the kth pixel in the sixth image block, a second quantizer corresponding to the f-dimension vector of the digital watermark image and a quantization step matrix; and obtaining a second coordinate position according to the third quantization result and a second quantizer corresponding to the f-dimension vector of the digital watermark image.
The digital watermark processing apparatus provided in the embodiment of the present invention may implement the above method embodiment, and its implementation principle and technical effect are similar, which are not described herein again.
EXAMPLE III
Referring to fig. 6, fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention. The electronic device 1100 comprises: the system comprises a processor 1101, a communication interface 1102, a memory 1103 and a communication bus 1104, wherein the processor 1101, the communication interface 1102 and the memory 1103 complete communication with each other through the communication bus 1104;
a memory 1103 for storing a computer program;
the processor 1101, when executing the computer program, implements the above method steps.
The processor 1101, when executing the computer program, implements the following steps:
step 1.1, obtaining at least one image to be embedded containing a face area;
step 1.2, extracting a face area of an image to be embedded and splicing to obtain a digital watermark image, wherein the digital watermark image is a binary image, and the size of the digital watermark image is the same as that of the image to be embedded;
1.3, dividing an image to be embedded of a preset channel of a YCbCr color space into a plurality of first image blocks with preset sizes;
and step 1.4, based on a dithering quantization index modulation algorithm, carrying out quantization embedding processing on coefficients in the first image block by using the digital watermark image so as to obtain an image of an RGB color space, wherein the digital watermark is embedded in the image.
Further, the processor 1101 may also realize the following steps when executing the computer program:
2.1, converting the color space of the image embedded with the digital watermark from an RGB color space to a YCbCr color space;
2.2, dividing the image embedded with the digital watermark of a preset channel in the YCbCr color space into a plurality of fifth image blocks with preset sizes;
step 2.3, processing the fifth image block by using discrete cosine transform to obtain a sixth image block;
step 2.4, a first coordinate position and a second coordinate position are obtained according to the coefficient of the kth pixel of the sixth image block and a first quantizer and a second quantizer corresponding to the f-dimension vector of the digital watermark image, wherein the first quantizer is generated according to a random number and a quantization step matrix, and the second quantizer is generated according to the first quantizer and the quantization step matrix;
step 2.5, absolute values of distances from the first coordinate position and the second coordinate position to a k-th pixel of the sixth image block are respectively calculated, if the absolute value of the distance from the first coordinate position to the k-th pixel of the sixth image block is smaller than or equal to the absolute value of the distance from the second coordinate position to the k-th pixel of the sixth image block, the embedded watermark information value of the k-th pixel of the sixth image block is set to be 0, and if the absolute value of the distance from the first coordinate position to the k-th pixel of the sixth image block is larger than the absolute value of the distance from the second coordinate position to the k-th pixel of the sixth image block, the embedded watermark information value of the k-th pixel of the sixth image block is set to be 1.
The electronic device provided by the embodiment of the present invention can execute the above method embodiments, and the implementation principle and technical effect are similar, which are not described herein again.
Example four
Yet another embodiment of the present invention provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of:
step 1.1, obtaining at least one image to be embedded containing a face area;
step 1.2, extracting a face area of an image to be embedded and splicing to obtain a digital watermark image, wherein the digital watermark image is a binary image, and the size of the digital watermark image is the same as that of the image to be embedded;
1.3, dividing an image to be embedded of a preset channel of a YCbCr color space into a plurality of first image blocks with preset sizes;
and step 1.4, based on a dithering quantization index modulation algorithm, carrying out quantization embedding processing on coefficients in the first image block by using the digital watermark image so as to obtain an image of an RGB color space, wherein the digital watermark is embedded in the image.
In addition, the computer program may further realize the following steps when executed by a processor:
2.1, converting the color space of the image embedded with the digital watermark from an RGB color space to a YCbCr color space;
2.2, dividing the image embedded with the digital watermark of a preset channel in the YCbCr color space into a plurality of fifth image blocks with preset sizes;
step 2.3, processing the fifth image block by using discrete cosine transform to obtain a sixth image block;
step 2.4, correspondingly obtaining a first coordinate position and a second coordinate position according to a coefficient of a kth pixel of the sixth image block and a first quantizer and a second quantizer corresponding to an f-dimension vector of the digital watermark image, wherein the first quantizer is generated according to a random number and a quantization step matrix, and the second quantizer is generated according to the first quantizer and the quantization step matrix;
step 2.5, absolute values of distances from the first coordinate position and the second coordinate position to a k-th pixel of the sixth image block are respectively calculated, if the absolute value of the distance from the first coordinate position to the k-th pixel of the sixth image block is smaller than or equal to the absolute value of the distance from the second coordinate position to the k-th pixel of the sixth image block, the embedded watermark information value of the k-th pixel of the sixth image block is set to be 0, and if the absolute value of the distance from the first coordinate position to the k-th pixel of the sixth image block is larger than the absolute value of the distance from the second coordinate position to the k-th pixel of the sixth image block, the embedded watermark information value of the k-th pixel of the sixth image block is set to be 1.
The computer-readable storage medium provided in the embodiment of the present invention may implement the method embodiments, and the implementation principle and technical effects are similar, which are not described herein again.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, apparatus (device), or computer program product. Accordingly, this application may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects that may all generally be referred to herein as a "module" or "system. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-readable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein. A computer program stored/distributed on a suitable medium supplied together with or as part of other hardware, may also take other distributed forms, such as via the Internet or other wired or wireless telecommunication systems.
In the description of the present invention, it is to be understood that the terms "first", "second" and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implying any number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of the present invention, "a plurality" means two or more unless specifically defined otherwise.
In the description herein, references to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples described in this specification can be combined and combined by those skilled in the art.
The foregoing is a further detailed description of the invention in connection with specific preferred embodiments and it is not intended to limit the invention to the specific embodiments described. For those skilled in the art to which the invention pertains, numerous simple deductions or substitutions may be made without departing from the spirit of the invention, which shall be deemed to belong to the scope of the invention.