Disclosure of Invention
The invention provides a processing and extracting method and device for image watermark information, so as to improve the capacity and stability of embedding digital watermark into an image.
To solve the above technical problem, an embodiment of the present invention provides an image watermark information processing method, including:
acquiring an image to be processed and a watermark template matrix, wherein each element in the watermark template matrix corresponds to digital watermark information;
Dividing a target embedded channel image block in the image to be processed to obtain a plurality of first sub-image blocks of the target embedded channel image block;
Determining a first transformation coefficient matrix corresponding to each first sub-image block in a plurality of first sub-image blocks, wherein each element in the first transformation coefficient matrix corresponds to one first transformation coefficient;
According to the digital watermark information in the watermark template matrix, first transformation coefficients in a target row and column position area in the first transformation coefficient matrix are adjusted to obtain a first target transformation coefficient matrix corresponding to each first sub-image block;
And obtaining a target image embedded with watermark information according to the first target transformation coefficient matrix and the first sub-image block corresponding to the first target transformation coefficient matrix.
Optionally, obtaining the watermark template matrix includes:
And processing watermark information to be embedded according to preset coding information and a first preset sequence to obtain the watermark template matrix.
Optionally, processing watermark information to be embedded according to preset coding information and a first preset sequence to obtain the watermark template matrix, including:
according to the preset coding word length and information bit number, coding the watermark information to obtain a coded watermark information sequence;
Obtaining the watermark template matrix according to the first preset sequence and the watermark information sequence, wherein the length of the first preset sequence is the same as that of the watermark information sequence.
Optionally, determining a first transform coefficient matrix corresponding to each of the plurality of first sub-image blocks includes:
And performing discrete cosine transform on each first sub-image block in the plurality of first sub-image blocks obtained after segmentation to obtain a first transformation coefficient matrix corresponding to each first sub-image block.
Optionally, according to the digital watermark information in the watermark template matrix, adjusting the first transform coefficients in the target row and column position area in the first transform coefficient matrix to obtain a first target transform coefficient matrix corresponding to each first sub-image block, including:
Traversing in the watermark template matrix, wherein each time of traversing, if the digital watermark information on the current row is the first digital information, according to a first preset embedding strength, performing adjustment and increment processing on a first transformation coefficient on a target row and column position area in a first transformation coefficient matrix of a first sub-image block corresponding to the digital watermark information on the current row, and obtaining a first target transformation coefficient matrix corresponding to the first sub-image block;
And if the digital watermark information element on the current row is the second digital information, performing subtraction processing on the first transformation coefficient on the target row and column position area in the first transformation coefficient matrix of the first sub-image block corresponding to the digital watermark information on the current row according to the second preset embedding strength, and obtaining a first target transformation coefficient matrix corresponding to the first sub-image block.
Optionally, the image watermark information processing method further includes:
acquiring a second transformation coefficient matrix corresponding to each second sub-image block in a plurality of second sub-image blocks of a target channel image block in a target image;
Determining target watermark information embedded in each second sub-image block according to the similarity between a preset detection matrix and the second transformation coefficient matrix;
obtaining a target watermark information matrix of the target channel image block according to the target watermark information embedded in each second sub-image block;
and processing the target watermark information matrix according to a second preset sequence and preset decoding information to obtain embedded original target watermark information.
The embodiment of the invention also provides an image watermark information processing device, which comprises:
The first acquisition module is used for acquiring an image to be processed and a watermark template matrix, and each element in the watermark template matrix corresponds to one piece of digital watermark information;
The first processing module is used for dividing a target embedded channel image block in the image to be processed to obtain a plurality of first sub-image blocks of the target embedded channel image block, determining a first transformation coefficient matrix corresponding to each first sub-image block in the plurality of first sub-image blocks, wherein each element in the first transformation coefficient matrix corresponds to one first transformation coefficient, adjusting the first transformation coefficients in a target row and column position area in the first transformation coefficient matrix according to digital watermark information in the watermark template matrix to obtain a first target transformation coefficient matrix corresponding to each first sub-image block, and obtaining a target image embedded with watermark information according to the first target transformation coefficient matrix and the first sub-image block corresponding to the first target transformation coefficient matrix.
The embodiment of the invention also provides an extraction method of the image watermark information, which comprises the following steps:
Obtaining a second transformation coefficient matrix corresponding to each second sub-image block in a plurality of second sub-image blocks of a target channel image block in a target image, wherein watermark information is embedded in the target channel image block in the target image;
Determining target watermark information embedded in each second sub-image block according to the similarity between a preset detection matrix and the second transformation coefficient matrix;
obtaining a target watermark information matrix of the target channel image block according to the target watermark information embedded in each second sub-image block;
and processing the target watermark information matrix according to a second preset sequence and preset decoding information to obtain embedded original target watermark information.
Optionally, the preset detection matrix comprises a first detection matrix in which first digital information is embedded in a first target row and column area and a second detection matrix in which second digital information is embedded in a second target row and column area, wherein the row and column numbers of the first detection matrix, the second detection matrix and the second transformation coefficient matrix are the same.
The embodiment of the invention also provides an extraction device of the image watermark information, which comprises the following steps:
The second acquisition module is used for acquiring a second transformation coefficient matrix corresponding to each second sub-image block in a plurality of second sub-image blocks of the target channel image block in the target image, wherein watermark information is embedded in the target channel image block in the target image;
The second processing module is used for obtaining the similarity between the preset detection matrix and the second transformation coefficient matrix according to the elements in the preset detection matrix and the elements in the second transformation coefficient matrix, determining the embedded target watermark information of each second sub-image block according to the similarity, obtaining the target watermark information matrix of the target channel image block according to the embedded target watermark information of each second sub-image block, and processing the target watermark information matrix according to a second preset sequence and preset decoding information to obtain the embedded original target watermark information.
The scheme of the invention at least comprises the following beneficial effects:
The image watermark information processing method includes the steps of obtaining a plurality of first sub-image blocks of an object embedding channel image block by dividing the object embedding channel image block in an obtained image to be processed, determining first transformation coefficient matrixes corresponding to the first sub-image blocks in the first sub-image blocks respectively, wherein each element in the first transformation coefficient matrixes corresponds to one first transformation coefficient, adjusting first transformation coefficients in a target row and column position area in the first transformation coefficient matrixes according to acquired digital watermark information in the watermark template matrixes to obtain a first target transformation coefficient matrix corresponding to each first sub-image block, and obtaining a target image with embedded watermark information according to the first target transformation coefficient matrixes and the first sub-image blocks corresponding to the first target transformation coefficient matrixes so as to improve capacity and stability of the embedded watermark.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
As shown in fig. 1, an embodiment of the present invention provides a method for processing image watermark information, including:
Step 11, obtaining an image to be processed and a watermark template matrix, wherein each element in the watermark template matrix corresponds to one piece of digital watermark information;
Step 12, dividing a target embedded channel image block in the image to be processed to obtain a plurality of first sub-image blocks of the target embedded channel image block;
Step 13, determining a first transformation coefficient matrix corresponding to each first sub-image block in a plurality of first sub-image blocks, wherein each element in the first transformation coefficient matrix corresponds to one first transformation coefficient;
step 14, according to the digital watermark information in the watermark template matrix, adjusting the first transformation coefficients in the target row and column position area in the first transformation coefficient matrix to obtain a first target transformation coefficient matrix corresponding to each first sub-image block;
And step 15, obtaining a target image embedded with watermark information according to the first target transformation coefficient matrix and the first sub-image block corresponding to the first target transformation coefficient matrix.
In this embodiment, the watermark template matrix is generated according to watermark information to be embedded, which provides a basis for embedding subsequent watermark information, each element in the watermark template matrix corresponds to one piece of digital watermark information, and the watermark information may be copyright information;
the method comprises the steps of processing a target embedded channel image block in an image to be processed into an image block corresponding to a G channel in an RGB three-channel image, dividing the target embedded channel image block into a plurality of corresponding first sub-image blocks by taking the image block corresponding to the G channel as an embedded target, wherein the target embedded channel image block can be guaranteed to have good transparency and anti-attack performance after watermark embedding, further, dividing the target embedded channel image block into a plurality of corresponding first sub-image blocks, arranging the plurality of first sub-image blocks according to a row-column sequence and a column-column sequence when dividing the target embedded channel image block into the first sub-image blocks according to the number of the divided first sub-image blocks after dividing to obtain a first sub-image block matrix, taking the target embedded channel image block with the size of 512×512 as an example, dividing the target embedded channel image block into the first sub-image blocks with the size of 64×64×8, wherein the first sub-image blocks with the size of 64×8×8 can form a first sub-image block matrix with the same size as the first sub-image block matrix, and the watermark matrix is embedded into the watermark matrix with the corresponding position of the matrix according to the number of the water mark matrix, and the water mark matrix is convenient to carry out the watermark embedding on the water mark matrix;
Further, the first sub-image blocks at the corresponding line and column positions in the first sub-image block matrix are adjusted according to the digital watermark information at the corresponding line and column positions in the watermark template matrix, specifically, according to the digital watermark information at the current line and column positions in the watermark template matrix, the first transformation coefficients at the target line and column position areas in the first transformation coefficient matrix corresponding to the digital watermark information at the current line and column positions in the first sub-image block matrix are adjusted to obtain the corresponding first target transformation coefficient matrix of each first sub-image block, wherein the target line and column position areas comprise a plurality of first transformation coefficients, the target line and column position areas are position areas meeting the diagonal texture direction, the plurality of first transformation coefficients in the target line and column position areas are all the first transformation coefficients of medium and high frequency, as shown in fig. 4, the first sub-image blocks with the size of 8×8, and the first transformation coefficients corresponding to the positions of 1,2,3,4, 5, 6, 7, 8, 9 and 10 in the figures are the first transformation coefficients in the target line and column position areas, namely the first transformation coefficients in the target position areas are the target line and column position areas, and column position areas are the first transformation coefficients in the target line and column position areas, and column position areas are all the first transformation coefficients in the first sub-image blocks, and the first transformation coefficients corresponding to the target line and column position areas are further, and the first transformation coefficients in the target line and column position areas are needed, and the first transformation coefficients can be embedded into the target watermark matrix;
Here, the first transformation coefficients in the first transformation coefficient matrix of the first sub-image block are adjusted according to the digital watermark information in the watermark template matrix, and the target image embedded with the watermark information is obtained according to the adjusted first sub-image block, which is equivalent to directly modifying the original first sub-image block, and complex operations such as integrating the watermark information with the image are not needed, so that the difficulty of embedding the watermark information into the image is reduced; and meanwhile, the first transformation coefficients in the target row and column position area are adjusted, so that the robustness of watermark embedding and the attack resistance of the target image after watermark information is embedded can be improved.
In an optional embodiment of the present invention, in the step 11, obtaining the watermark template matrix may include:
And step 111, processing watermark information to be embedded according to preset coding information and a first preset sequence to obtain the watermark template matrix.
In this embodiment, before the watermark information to be embedded is processed according to the preset encoding information and the first preset sequence, preferably, the watermark information may be subjected to binary=binary conversion to obtain binary-converted watermark information, so as to reduce complexity of subsequent adjustment of the first transform coefficient of the first sub-image block according to the watermark template matrix;
The first preset sequence can be a random sequence obtained according to a random number generation algorithm, and the size of the first preset sequence can be set according to the specific bit number of the watermark information after binary conversion or the size of the target embedded channel image block;
further, the step 111 may include:
step 1111, performing coding processing on the watermark information according to a preset coding word length and information bit number to obtain a coded watermark information sequence;
Step 1112, obtaining the watermark template matrix according to the first preset sequence and the watermark information sequence, where the length of the first preset sequence is the same as the length of the watermark information sequence.
In this embodiment, the binary-processed watermark information is encoded according to the preset encoding word length and the information bit number, so as to ensure the stability and reliability of watermark information embedding; here, before the encoding processing, the original watermark information to be embedded may be binary processed, so as to reduce the difficulty of adjusting the first transform coefficient of the first sub-image block; further, the watermark information sequence is subjected to spread spectrum processing through the first preset sequence to obtain the watermark template matrix, so that the embedding amount of watermark information is increased, and the robustness and invisibility of the watermark information embedded subsequently are further ensured; when the watermark information sequence is subjected to spread spectrum processing, a first preset sequence matched with the size of the target embedded channel image block is required to be set, and the length of the first preset sequence is the same as that of the watermark information sequence so as to ensure that a watermark template matrix with the same row and column as that of a first sub-image block matrix formed by the first sub-image block is obtained, and further ensure the efficiency of embedding watermark information and the utilization rate of the target embedded channel image block;
Taking 36-bit watermark information obtained after binary processing, a preset code word length of 63 and a preset information bit number of 36 as an example, describing the above coding process, wherein the 36-bit watermark information is represented as an information vector m with a length of 36, each bit is a binary information bit, multiplying the information vector m by a preset generating matrix (the preset generating matrix is a 63×63 matrix, the first 36 columns can be unit matrixes, and the last 27 columns can be coefficients of a generating polynomial meeting the BCH coding requirement), obtaining a code vector with a length of 63, adding a preset error correction code with a preset number into the code vector with a length of 63, obtaining a 63-bit BCH code containing 36-bit watermark information and the preset error correction code, and further, additionally supplementing one bit of 0 to the 63-bit BCH code, thereby obtaining a 64-bit coded watermark information sequence, as shown in fig. 2;
As shown in FIG. 3, further, a first preset sequence with 64 bits is obtained by processing according to a random number generation algorithm, such as a random 01 sequence, and the watermark information sequence is subjected to spread spectrum processing, specifically, the watermark information sequence is multiplied with the first preset sequence to obtain a watermark template matrix with the size of 6×64 so as to enlarge the embedding amount of the watermark, preferably, the watermark template matrix obtained after the spread spectrum processing can be used for scrambling the sequence of elements in the matrix through a preset disorder method, so that the complexity of embedding watermark information is ensured, and the stability and the safety of a target image in which the watermark information is embedded are further ensured, and it is known that the watermark template matrix only comprises the first digital watermark information with the matrix element of the first digital information 1 and the second digital watermark information with the matrix element of the second digital information 0 because the watermark template matrix is obtained by binary conversion of the original watermark information and then is subjected to code spread spectrum.
In an optional embodiment of the present invention, the step 13 may include:
Step 131, discrete cosine transforming each of the plurality of first sub-image blocks obtained after the segmentation is performed to obtain a first transformation coefficient matrix corresponding to each first sub-image block.
In the embodiment, the image data represented by the first sub-image block in the space domain is converted into the frequency domain for representation through discrete cosine transform to reduce redundancy and complexity of pixel values of the first sub-image block and reduce complexity of subsequent embedded watermark information, specifically, after the pixel values of the first sub-image block with the size of N×N are subjected to discrete cosine transform, high-frequency transform coefficients are taken as 0, and the transformed low-frequency transform coefficients are rearranged into a matrix with N rows and N columns, so as to obtain a first transform coefficient matrix of each first sub-image block, and preferably, the first transform coefficient matrix of each first sub-image block can be calculated through the following formula:
wherein N represents the height and width of the first sub-image block (the default first sub-image block is square), F (x, y) is the pixel value at the position (x, y) in the first sub-image block, F (u, v) represents the transformed first transform coefficient at the corresponding position, u, v represent different frequencies in the transform domain, N-1;Ku、Kv are normalized coefficients, when u=v=0,When u=v+.0, Ku=Kv =1;
since the watermark template matrix has the same row and column number as the first sub-image block matrix formed by the plurality of first sub-image blocks, each matrix element (digital watermark information) in the watermark template matrix corresponds to a first transformation coefficient matrix of a first sub-image block.
In an alternative embodiment of the present invention, the step 14 may include:
Step 141, performing traversal in the watermark template matrix, performing increment processing on a first transformation coefficient on a target row and column position area in a first transformation coefficient matrix of a first sub-image block corresponding to the digital watermark information on the current row and column according to a first preset embedding strength if the digital watermark information on the current row and column is the first digital information, and obtaining a first target transformation coefficient matrix corresponding to the first sub-image block;
Step 142, if the digital watermark information element on the current row is the second digital information, performing subtraction processing on the first transform coefficient on the target row-column position area in the first transform coefficient matrix of the first sub-image block corresponding to the digital watermark information on the current row according to the second preset embedding strength, and obtaining the first target transform coefficient matrix corresponding to the first sub-image block.
In this embodiment, the first preset embedding strength and the second preset embedding strength may be set according to actual needs of processing, so as to ensure accuracy of adjusting the first transform coefficient according to the numerical watermark information in the watermark template matrix, and further ensure accuracy of embedding watermark information;
In the watermark template matrix, according to the digital watermark information on the current row and column, carrying out modulation and subtraction on all first transformation coefficients on the first transformation coefficient matrix of the first sub-image block corresponding to the digital watermark information on the current row and column according to the digital watermark information on the current row and column, and respectively obtaining a first transformation coefficient of the first sub-image block corresponding to the digital watermark information on the current row and column (matrix element in the watermark template matrix) as first digital information 1, carrying out modulation and multiplication on all first transformation coefficients on the target row and column position area according to the first preset embedding strength, and carrying out modulation and subtraction on all first transformation coefficients on the first transformation coefficient matrix of the first sub-image block corresponding to the digital watermark information on the current row and column according to the second preset embedding strength as second digital information 0, and respectively obtaining a first transformation coefficient of the first sub-image block corresponding to the digital watermark information 1 and a first transformation coefficient of the first sub-image block corresponding to the digital watermark information on the current row and column position area as first digital watermark information 0;
The method comprises the steps of adaptively modifying first transformation coefficients in a target line and row position area in a first transformation coefficient matrix of a first sub-image block corresponding to digital watermark information through the digital watermark information in the watermark template matrix, enabling first transformation coefficient values in the target line and row position area in the corresponding first transformation coefficient matrix of the digital watermark information 1 to be as high as possible, enabling first transformation coefficient values in the target line and row position area in the corresponding first transformation coefficient matrix of the digital watermark information 0 to be as low as possible, modifying the original first sub-image block directly in the whole processing process, and not needing complex operations such as integrating the watermark information with the first sub-image block, so that the difficulty of embedding the watermark information into an image is reduced, and adjusting a plurality of first transformation coefficients in the target line and row position area, so that the robustness of watermark embedding and the anti-attack of the target image after watermark information are improved.
In an optional embodiment of the present invention, the step 15 may include:
Step 151, performing inverse discrete cosine transform on each first sub-image block with a first target transform coefficient matrix to obtain a second target transform coefficient matrix corresponding to each first sub-image block, where the second target transform coefficient matrix corresponds to the first target transform coefficient matrix one by one;
And 152, performing stitching processing on the plurality of first sub-image blocks with the second target transformation matrix according to a row-column sequence, and replacing the target embedded channel image blocks in the image to be processed to obtain a target image with embedded watermark information.
In this embodiment, the first transform coefficient in the first transform coefficient matrix of the first sub-image block is modified according to the digital watermark information in the watermark template information to implement embedding of watermark information, and the first sub-image block represented by the frequency domain is restored to the image block represented by the spatial domain by performing inverse discrete cosine transform on the first target transform coefficient matrix obtained after transformation, so as to further splice the image block embedded with watermark information, and ensure the integrity of the target image;
Preferably, the inverse discrete cosine transform may be performed on each of the first sub-image blocks having the first target transform coefficient matrix by the following formula:
In an alternative embodiment of the present invention, on the basis of steps 11 to 15, the method may further include:
Step 16, obtaining a second transformation coefficient matrix corresponding to each second sub-image block in a plurality of second sub-image blocks of the target channel image block in the target image;
step 17, determining the embedded target watermark information of each second sub-image block according to the similarity between a preset detection matrix and the second transformation coefficient matrix;
step 18, obtaining a target watermark information matrix of the target channel image block according to the target watermark information embedded in each second sub-image block;
and step 19, processing the target watermark information matrix according to a second preset sequence and preset decoding information to obtain embedded original target watermark information.
In the embodiment, the target channel image block is an image block corresponding to a G channel, wherein the determined target channel image block is firstly subjected to segmentation processing to obtain a plurality of second sub-image blocks of the target channel image block, wherein the size and the number of the segmented second sub-image blocks can be the same as those of the first sub-image blocks in the embodiment, and each second sub-image block is subjected to discrete cosine transform to obtain a second transformation coefficient matrix of each second sub-image block;
Further, detecting each second transformation coefficient matrix according to the preset detection matrix, and determining target watermark information embedded in each second sub-image block, wherein the target watermark information is digital watermark information based on which transformation coefficients in a target row and column position area in the original sub-image block without embedded watermark information are adjusted;
here, the second transformation coefficient matrix may be detected by two preset detection matrices, the first detection matrix and the second detection matrix, respectively; the first detection matrix and the second detection matrix are matrices with the same size as the second transformation coefficient matrix; as shown in fig. 7, in the first detection matrix, the digital information is embedded in the position corresponding to the target row and column position area to be-1, and the rest positions are all 0; in the second detection, as shown in fig. 8, the digital information is embedded at the position corresponding to the target line and row position area is 1, and the rest positions are all 0, when the detection is performed, respectively acquiring the first similarity of the first detection matrix and the second transformation coefficient matrix to be detected currently, and the second similarity of the second detection matrix and the second transformation coefficient matrix to be detected currently, and comparing the first similarity with the second similarity, when the first similarity is greater than the second similarity, the second transformation coefficient matrix of the second sub-image block is considered to be adjusted according to the first detection matrix, the corresponding embedded target watermark information is 0, and when the first similarity is smaller than the second similarity, the second transformation coefficient matrix of the second sub-image block is considered to be adjusted according to the second detection matrix, and the corresponding embedded target watermark information is considered to be 1;
preferably, the first similarity may be calculated by the following formula:
The second similarity may be calculated by the following formula:
Wherein S1 represents a first similarity, S2 represents a second similarity, A represents a first detection matrix, Aj represents a j-th element component in the first detection matrix, C represents a second detection matrix, Cj represents a j-th element component in the second detection matrix, Bi represents a second transformation coefficient matrix corresponding to an i-th second sub-image block, Bij represents a j-th element component in the second transformation coefficient matrix, D represents the number of elements in the first detection matrix, the second detection matrix and the second transformation coefficient matrix, j=1, 2, 3, and D is a positive integer;
Further, according to the embedded target watermark information of each second sub-image block and the row-column sequence of the second sub-image, the target watermark information is arranged according to the corresponding row-column sequence, so as to obtain a target watermark information matrix of the target channel image block, further, the target watermark information matrix is subjected to inverse spread spectrum processing through the second preset sequence, so as to obtain a target watermark information sequence of the target watermark matrix, the target watermark information sequence is subjected to decoding and binarization processing through the preset decoding information, so that corrected information is the original target watermark information embedded in the target image, and the process of processing the target watermark information to obtain the embedded original target watermark information is the inverse process of processing the watermark information to obtain the watermark information template matrix in the embodiment, so that the accuracy of the extracted embedded original target watermark information can be ensured.
In the processing method of the image watermark information disclosed by the embodiment of the invention, the target embedded channel image block in the image to be processed is segmented to obtain a plurality of first sub-image blocks, the first transformation coefficient matrix corresponding to each first sub-image block in the plurality of first sub-image blocks is calculated, the watermark information to be embedded is sequentially encoded and spread according to preset encoding information and a first preset sequence to obtain a watermark template matrix, the first transformation coefficient in a target row and column position area in the first transformation coefficient matrix is adjusted according to digital watermark information in the watermark template matrix to obtain a first target transformation coefficient matrix corresponding to each first sub-image block, the target image after watermark information is embedded is obtained according to the first target transformation coefficient matrix and the first sub-image block corresponding to the first target transformation coefficient matrix, so that the capacity and the stability of the image embedded with the digital watermark are improved, the watermark information is embedded by modifying the first transformation coefficient in a transformation domain matrix of the first sub-image block during embedding, the watermark template matrix is increased by using a spread spectrum technology, the robustness and the watermark is enhanced, the watermark is effectively extracted by combining with a BCH (the error correction channel is effectively extracted and the error correction channel is effectively decoded) and the watermark information is effectively extracted by the method of the contrast of the original image, to enable protection and management of digital rights.
As shown in fig. 5, an embodiment of the present invention further provides an image watermark information processing apparatus 50, including:
a first obtaining module 51, configured to obtain an image to be processed and a watermark template matrix, where each element in the watermark template matrix corresponds to one piece of digital watermark information;
the first processing module 52 is configured to segment a target embedded channel image block in the image to be processed to obtain a plurality of first sub-image blocks of the target embedded channel image block, determine a first transform coefficient matrix corresponding to each of the plurality of first sub-image blocks, where each element in the first transform coefficient matrix corresponds to a first transform coefficient, adjust, according to digital watermark information in the watermark template matrix, a first transform coefficient in a target rank position area in the first transform coefficient matrix to obtain a first target transform coefficient matrix corresponding to each first sub-image block, and obtain a target image after embedding watermark information according to the first target transform coefficient matrix and the first sub-image block corresponding to the first target transform coefficient matrix.
Optionally, the first obtaining module 51 is configured to obtain a watermark template matrix, including:
And processing watermark information to be embedded according to preset coding information and a first preset sequence to obtain the watermark template matrix.
Optionally, the first obtaining module 51 is configured to process watermark information to be embedded according to preset encoding information and a first preset sequence to obtain the watermark template matrix, and includes:
according to the preset coding word length and information bit number, coding the watermark information to obtain a coded watermark information sequence;
Obtaining the watermark template matrix according to the first preset sequence and the watermark information sequence, wherein the length of the first preset sequence is the same as that of the watermark information sequence.
Optionally, the first processing module 52 is configured to determine a first transform coefficient matrix corresponding to each of the plurality of first sub-image blocks, including:
And performing discrete cosine transform on each first sub-image block in the plurality of first sub-image blocks obtained after segmentation to obtain a first transformation coefficient matrix corresponding to each first sub-image block.
Optionally, the first processing module 52 is configured to adjust, according to the digital watermark information in the watermark template matrix, a first transform coefficient on a target line-column position area in the first transform coefficient matrix, to obtain a first target transform coefficient matrix corresponding to each first sub-image block, where the first target transform coefficient matrix includes:
Traversing in the watermark template matrix, wherein each time of traversing, if the digital watermark information on the current row is the first digital information, according to a first preset embedding strength, performing adjustment and increment processing on a first transformation coefficient on a target row and column position area in a first transformation coefficient matrix of a first sub-image block corresponding to the digital watermark information on the current row, and obtaining a first target transformation coefficient matrix corresponding to the first sub-image block;
And if the digital watermark information element on the current row is the second digital information, performing subtraction processing on the first transformation coefficient on the target row and column position area in the first transformation coefficient matrix of the first sub-image block corresponding to the digital watermark information on the current row according to the second preset embedding strength, and obtaining a first target transformation coefficient matrix corresponding to the first sub-image block.
Optionally, the first processing module 52 is further configured to:
acquiring a second transformation coefficient matrix corresponding to each second sub-image block in a plurality of second sub-image blocks of a target channel image block in a target image;
obtaining the similarity between the preset detection matrix and the second transformation coefficient matrix according to the elements in the preset detection matrix and the elements in the second transformation coefficient matrix;
Determining target watermark information embedded in each second sub-image block according to the similarity;
obtaining a target watermark information matrix of the target channel image block according to the target watermark information embedded in each second sub-image block;
and processing the target watermark information matrix according to a second preset sequence and preset decoding information to obtain embedded original target watermark information.
The image watermark information processing apparatus is an apparatus corresponding to the image watermark information processing method, and all implementation manners in the method embodiment are applicable to the embodiment of the apparatus, so that the same technical effects can be achieved.
As shown in fig. 6, an embodiment of the present invention further provides a method for extracting image watermark information, including:
step 61, obtaining a second transformation coefficient matrix corresponding to each second sub-image block in a plurality of second sub-image blocks of a target channel image block in a target image, wherein watermark information is embedded in the target channel image block in the target image;
Step 62, determining the embedded target watermark information of each second sub-image block according to the similarity between the preset detection matrix and the second transformation coefficient matrix;
step 63, obtaining a target watermark information matrix of the target channel image block according to the target watermark information embedded in each second sub-image block;
and step 64, processing the target watermark information matrix according to the second preset sequence and the preset decoding information to obtain embedded original target watermark information.
In this embodiment, the target channel image block is an image block corresponding to a G channel in the target image, where the determined target channel image block is first subjected to segmentation processing to obtain a plurality of second sub-image blocks of the target channel image block, where the size and number of the segmented second sub-image blocks may also be set according to the actual processing requirement, preferably, before the segmentation, the target image may be subjected to correction processing (herein, correction may be performed by using image processing software) to avoid perspective distortion of the obtained target image with watermark information, so as to reduce the influence on the subsequent watermark information extraction;
Further, according to the preset detection matrix, detecting and processing are carried out on each second transformation coefficient matrix, so that target watermark information embedded in each second sub-image block can be determined, wherein the target watermark information is digital watermark information based on which transformation coefficients in a target row and column position area in the original sub-image block without embedded watermark information are adjusted;
The first detection matrix and the second detection matrix are both matrices with the same size as the second transformation coefficient matrix, preferably, the first detection matrix is a matrix in which first digital information is embedded in a first target row-column area and digital 0 is embedded in other areas except the first target row-column area, the second detection matrix is a matrix in which second digital information is embedded in a second target row-column area and digital 0 is embedded in other areas except the second target row-column area, and the specific positions of the first target row-column area and the second target row-column area in the matrix are the same;
In one example of the present invention, as shown in fig. 7, a first detection matrix may be represented, in which a first digital information-1 may be embedded in a first target row and column area in the matrix, and the rest of the positions are all 0;
preferably, the first similarity may be calculated by the following formula:
The second similarity may be calculated by the following formula:
Wherein S1 represents a first similarity, S2 represents a second similarity, A represents a first detection matrix, Aj represents a j-th element component in the first detection matrix, C represents a second detection matrix, Cj represents a j-th element component in the second detection matrix, Bi represents a second transformation coefficient matrix corresponding to an i-th second sub-image block, Bij represents a j-th element component in the second transformation coefficient matrix, D represents the number of elements in the first detection matrix, the second detection matrix and the second transformation coefficient matrix, j=1, 2, 3, and D is a positive integer;
When the detection is carried out, respectively acquiring the first similarity between the first detection matrix and the second transformation coefficient matrix to be detected currently, and the second similarity between the second detection matrix and the second transformation coefficient matrix to be detected currently, and comparing the first similarity with the second similarity, wherein when the first similarity is larger than the second similarity, the second transformation coefficient matrix of the second sub-image block is considered to be adjusted according to the first detection matrix, the corresponding embedded target watermark information is 0, and when the first similarity is smaller than the second similarity, the second transformation coefficient matrix of the second sub-image block is considered to be adjusted according to the second detection matrix, and the corresponding embedded target watermark information is 1;
Further, according to the target watermark information embedded in each second sub-image block and the row-column sequence of the second sub-image, arranging the target watermark information according to the corresponding row-column sequence to obtain a target watermark information matrix of the target channel image block, further, performing inverse spread spectrum processing on the target watermark information matrix through the second preset sequence to obtain a target watermark information sequence of the target watermark matrix, and performing decoding and binarization processing on the target watermark information sequence through the preset decoding information to obtain corrected information, namely original target watermark information embedded in the target image, wherein the process of processing the target watermark information to obtain the embedded original target watermark information after obtaining the target watermark information matrix is the same as the inverse process of processing watermark information to obtain a watermark information template matrix in the embodiment of the processing method, and is not repeated here;
the discrete cosine transform-based mode disclosed by the embodiment of the invention can effectively extract the embedded original target watermark information by sampling the local area (target channel image block) of the target image embedded with the watermark information and comparing the local area with the preset detection matrix and utilizing the BCH for error correction and decoding so as to realize the protection and management of digital copyrights. In an embodiment, the accuracy of the extracted embedded original target watermark information may thus be ensured.
As shown in fig. 9, an embodiment of the present invention further provides an apparatus 90 for extracting image watermark information, including:
A second obtaining module 91, configured to obtain a second transform coefficient matrix corresponding to each of a plurality of second sub-image blocks of a target channel image block in a target image, where watermark information is embedded in the target channel image block in the target image;
the second processing module 92 is configured to obtain a similarity between a preset detection matrix and the second transform coefficient matrix according to the elements in the preset detection matrix and the elements in the second transform coefficient matrix, determine target watermark information embedded in each second sub-image block according to the similarity, obtain a target watermark information matrix of the target channel image block according to the target watermark information embedded in each second sub-image block, and process the target watermark information matrix according to a second preset sequence and preset decoding information to obtain embedded original target watermark information.
Optionally, the preset detection matrix comprises a first detection matrix in which first digital information is embedded in a first target row and column area and a second detection matrix in which second digital information is embedded in a second target row and column area, wherein the row and column numbers of the first detection matrix, the second detection matrix and the second transformation coefficient matrix are the same.
It should be noted that, the device for extracting the image watermark information is a device corresponding to the method for extracting the image watermark information, and all implementation manners in the method embodiment are applicable to the embodiment of the device, so that the same technical effects can be achieved.
The embodiment of the invention also provides a computing device which comprises a processor and a memory storing a computer program, wherein the computer program is executed by the processor to execute the processing method of the image watermark information or the extraction method of the image watermark information. All the implementation modes in the embodiment of the processing method of the image watermark information or the extracting method of the image watermark information are applicable to the embodiment, and the same technical effect can be achieved.
Embodiments of the present invention also provide a computer-readable storage medium comprising instructions that, when executed on a computer, cause the computer to perform a processing method of image watermark information or an extraction method of image watermark information as described above. All the implementation modes in the embodiment of the processing method of the image watermark information or the extracting method of the image watermark information are applicable to the embodiment, and the same technical effect can be achieved.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. The coupling or direct coupling or communication connection shown or discussed with each other may be through some interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present invention. The storage medium includes various media capable of storing program codes such as a U disk, a mobile hard disk, a ROM, a RAM, a magnetic disk or an optical disk.
Furthermore, it should be noted that in the apparatus and method of the present invention, it is apparent that the components or steps may be disassembled and/or assembled. Such decomposition and/or recombination should be considered as equivalent aspects of the present invention. Also, the steps of performing the series of processes described above may naturally be performed in chronological order in the order of description, but are not necessarily performed in chronological order, and some steps may be performed in parallel or independently of each other. It will be appreciated by those of ordinary skill in the art that all or any of the steps or components of the methods and apparatus of the present invention may be implemented in hardware, firmware, software, or a combination thereof in any computing device (including processors, storage media, etc.) or network of computing devices, as would be apparent to one of ordinary skill in the art after reading this description of the invention.
The object of the invention can thus also be achieved by running a program or a set of programs on any computing device. The computing device may be a well-known general purpose device. The object of the invention can thus also be achieved by merely providing a program product containing program code for implementing said method or apparatus. That is, such a program product also constitutes the present invention, and a storage medium storing such a program product also constitutes the present invention. It is apparent that the storage medium may be any known storage medium or any storage medium developed in the future. It should also be noted that in the apparatus and method of the present invention, it is apparent that the components or steps may be disassembled and/or assembled. Such decomposition and/or recombination should be considered as equivalent aspects of the present invention. The steps of executing the series of processes may naturally be executed in chronological order in the order described, but are not necessarily executed in chronological order. Some steps may be performed in parallel or independently of each other.
While the foregoing is directed to the preferred embodiments of the present invention, it will be appreciated by those skilled in the art that various modifications and adaptations can be made without departing from the principles of the present invention, and such modifications and adaptations are intended to be comprehended within the scope of the present invention.