Image watermark embedding, extraction method, device, electronic device and storage medium
By combining the scoring processing of the image and the edge airspace watermark embedding method, the problem of poor robustness of the image watermark at the edge is solved, the good invisibility and robustness of the watermark is achieved, and the effect of copyright protection is improved.
Patent Information
- Application Number
- CN202210307853.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-25
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2042-03-25
AI Technical Summary
In the prior art, the image watermarks are poorly robust at the edges, making it difficult to ensure the invisibility of the watermarks and their ability to resist attacks, resulting in poor copyright protection effect.
By scoring the image, the watermark embedding area is determined, and the watermark is embedded in multiple block areas is embedded using the edge airspace watermark embedding method. The embedding parameters are adjusted in combination with the adaptive parameter adjustment model to ensure the invisibility and robustness of the watermark.
It improves the invisibility and robustness of watermarks, enhances the utilization of image edge features, and improves the user experience and copyright protection effect.
Smart Images

Figure CN114782236B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of digital image copyright protection, and in particular to an image watermark embedding and extraction method, device, electronic equipment and storage medium. Background Art
[0002] With the development of network media, while it brings convenience to people, there are also phenomena such as digital works being copied and illegally disseminated, which has caused serious copyright disputes. The research and application of image watermarking technology plays a vital role in the protection of copyright of image works. The watermark representing the copyright of the work is imperceptibly hidden in the image work. When a copyright dispute occurs, it is correctly extracted and used to authenticate the copyright of the image work. Among them, the key to the real application of image watermarking technology in copyright protection is that the embedded watermark does not affect the quality of the image work and has the ability to resist various attacks (that is, the watermark is both invisible and robust).
[0003] Quantization method is a common method for watermark embedding and extraction. The existing spatial domain-based quantization watermarking algorithm can meet the requirements of image watermarking algorithm efficiency and effectively resist image scaling attacks. However, this type of algorithm has extremely poor robustness when embedded in the edge of the image. The reason for this phenomenon is that the grayscale of pixels at the edge changes dramatically. Compared with image blocks containing a large number of edges (called edge blocks) and non-edge blocks with smooth pixel grayscale value changes, when the image changes slightly, the pixel value of the edge block fluctuates greatly, causing the quantization value to lose synchronization with the quantization interval, resulting in watermark extraction errors. There are existing watermarking technologies that select the embedding area of the watermark based on information such as the variance and entropy of the image, but this information cannot accurately characterize the edge features of the image, and cannot specifically solve the problem of poor robustness of the watermark at the edge. It is also difficult to ensure that the embedded watermarks have good invisibility, resulting in poor visual effects. Summary of the invention
[0004] The present invention provides an image watermark embedding and extraction method, device, electronic device and storage medium, which are used to solve the technical problems in the prior art that image watermark embedding cannot guarantee good invisibility and has poor robustness, so as to achieve the purpose of improving the invisibility and robustness of image watermarks and enhancing user experience.
[0005] In a first aspect, the present invention provides an image watermark embedding method, comprising:
[0006] Scoring the local area of the image to be embedded with watermark, and determining the watermark embedding area according to the scoring result;
[0007] Scaling and dividing the watermark embedding area into blocks to obtain a plurality of first block areas;
[0008] The watermark to be embedded is embedded into the plurality of first block regions based on a preset edge spatial domain watermark embedding method, and after embedding, scaling is performed according to a preset scaling ratio to obtain an image containing the watermark.
[0009] Furthermore, according to the image watermark embedding method provided by the present invention, before the scoring process is performed on the local area in the image to be embedded with the watermark, the method comprises:
[0010] Performing denoising on the image to be embedded with a watermark to obtain a pre-processed image;
[0011] Performing edge detection on the preprocessed image to obtain a binary edge image;
[0012] Obtain pixels in the image to be embedded with watermarks that have the same edge pixel positions as those in the binary edge image, calculate the mean of the grayscale differences between the pixel and each pixel in its eight neighborhoods, and correct the binary edge image based on the relationship between the mean and a preset threshold to determine a first target binary edge image.
[0013] Furthermore, according to the image watermark embedding method provided by the present invention, the scoring process is performed on the local area in the image to be embedded with the watermark, and the watermark embedding area is determined according to the scoring result, including:
[0014] Using a sliding window to traverse the first target binary edge image, and determine the edge score of each window area;
[0015] Using a sliding window to traverse the image to be watermarked, determining a texture score, a gray value score and a position score of each window area;
[0016] Determine a comprehensive score for each window area according to the edge score, texture score, grayscale score and position score of each window area and a preset scoring calculation method;
[0017] The comprehensive scores are sorted, and the watermark embedding area is determined according to the sorting result; wherein the preset scoring calculation method is:
[0018]
[0019] Among them, (u, v) are the coordinates of the center point of each window area, m and n are the width and height of each window area respectively, and p i,j =255 is the pixel with a gray value of 255 in the first target binary edge image, that is, the edge pixel in each window area, and num is the number of edge pixels; k p is the proportion of pixels with gray value p in each window area; p i,jRepresents the grayscale value of the pixel in the i-th row and j-th column in each window area; (U, V) is the coordinate of the center point of the image; α, β, γ, δ are the scoring weights of the edge score, texture score, grayscale score, and position score of each window area, respectively.
[0020] Furthermore, according to the image watermark embedding method provided by the present invention, the watermark to be embedded is embedded into the plurality of first block regions based on a preset edge spatial domain watermark embedding method, comprising:
[0021] When embedding the watermark in each first block area, determining the embedding parameters in the preset edge spatial domain watermark embedding method according to the pre-established adaptive parameter adjustment model based on the image edge;
[0022] Based on a preset edge spatial domain watermark embedding method, each bit of the watermark to be embedded is embedded into each first block area, wherein the edge spatial domain watermark embedding method is expressed as:
[0023]
[0024] Among them, f x,y (i, j) is the grayscale value of the pixel at the i-th row and j-th column in the block at the x-th row and y-th column of the watermark embedding area; f*x,y(i, j) is the modified grayscale value; a and b represent the width and height of the first block area respectively; N x,y is the number of edge pixels in the first sub-block area; θ is the modification weight of the edge pixels in the first sub-block area; Δ x,y represents the total pixel modification amount in the first sub-block area, and the total pixel modification amount in the first sub-block area Δ x,y The calculation formula is:
[0025]
[0026] Among them, W x,y is the watermark position to be embedded in the first block area, σ x,y is the embedding parameter corresponding to the first block area, used to adjust the strength of watermark embedding.
[0027] Furthermore, according to the image watermark embedding method provided by the present invention, before the scoring process is performed on the local area in the image to be embedded with the watermark, the method further comprises:
[0028] Get image sample dataset;
[0029] According to any of the above-mentioned image watermark embedding methods, a watermark is embedded in the target sample image in the image sample data set, the embedding parameters in the preset edge spatial domain watermark embedding method are adjusted so that the structural similarity of all the second block areas before and after the watermark is embedded is kept within a threshold range, and the embedding parameters of the second block areas are confirmed;
[0030] Confirming the number of edge pixels of the second block area in the target sample image, and determining the corresponding relationship between the number of edge pixels and the embedding parameter of the second block area according to a preset linear regression method;
[0031] An adaptive parameter adjustment model based on the edge image is determined according to the corresponding relationship.
[0032] In a second aspect, the present invention further provides an image watermark extraction method, comprising:
[0033] Scoring the local area of the image to be watermarked, and determining the watermark extraction area according to the scoring result;
[0034] Scaling and dividing the watermark extraction area into blocks to obtain a plurality of third block areas;
[0035] A watermark bit is extracted from each third block region based on a preset edge spatial domain watermark extraction method, and a complete watermark is composed according to the extracted multiple watermark bits.
[0036] Further, according to the image watermark extraction method provided by the present invention, the watermark extraction method based on the preset edge spatial domain extracts a watermark from each of the third block areas, comprising:
[0037] When extracting the watermark from each of the third block areas, determining the extraction parameters in the preset edge spatial domain watermark extraction method according to the pre-trained image edge-based adaptive parameter adjustment model;
[0038] Based on a preset edge spatial domain watermark extraction method, a watermark is extracted from each third block area, wherein the expression of the edge spatial domain watermark extraction method is:
[0039]
[0040] Among them, W x,y ' is the watermark position to be extracted in the block located in the xth row and yth column of the watermark extraction area, a' and b' are the length and width of the watermark extraction area respectively, σ x,y ' is to extract parameters, floor() is the rounding down function.
[0041] In a third aspect, the present invention further provides an image watermark embedding device, comprising:
[0042] A scoring module is used to score the local area in the image to be embedded with watermark, and determine the watermark embedding area according to the scoring result;
[0043] A processing module, used for scaling and dividing the watermark embedding area into blocks to obtain a plurality of first block areas;
[0044] The embedding module is used to embed the watermark to be embedded into the multiple first block areas based on a preset edge spatial domain watermark embedding method, and after embedding, scale the watermark according to a preset scaling ratio to obtain an image containing the watermark.
[0045] In a fourth aspect, the present invention further provides an image watermark extraction device, comprising:
[0046] A scoring module is used to score the local area of the image to be watermarked, and determine the watermark extraction area according to the scoring result;
[0047] A processing module, used for scaling and dividing the watermark extraction area into blocks to obtain a plurality of third block areas;
[0048] The extraction module is used to extract a watermark bit from each third block area based on a preset edge spatial domain watermark extraction method, and compose a complete watermark according to the extracted multiple watermark bits.
[0049] In a fifth aspect, the present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the image watermark embedding method or the steps of the image watermark extraction method as described in any one of the above items are implemented.
[0050] In a sixth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the complaint cause analysis methods described above.
[0051] In a seventh aspect, the present invention further provides a computer program product, comprising computer executable instructions, which when executed are used to implement the steps of the image watermark embedding method or the steps of the image watermark extraction method as described in any one of the above items.
[0052] The present invention provides an image watermark embedding and extraction method, device, electronic device and medium. In the embedding stage, the local area in the image to be embedded with the watermark is scored, and the watermark embedding area is determined according to the scoring result; the watermark embedding area is scaled and divided into blocks to obtain multiple first block areas; the watermark to be embedded is embedded into the multiple first block areas based on a preset edge spatial domain watermark embedding method, and after embedding, the watermark is scaled according to a preset scaling ratio to obtain an image containing the watermark; in the extraction stage, multiple third block areas are obtained according to the same method as the embedding stage, and the watermark is extracted from them based on a preset edge spatial domain watermark extraction method. The image watermark embedding and extraction method provided by the present invention can make full use of the visual features of the image to adjust the embedding strength of the watermark, and can make the watermark have good invisibility and robustness. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0054] Figure 1 It is a flow chart of the image watermark embedding method provided by the present invention;
[0055] Figure 2 It is one of the example diagrams of an image watermark embedding method provided by the present invention;
[0056] Figure 3 This is the second example diagram of an image watermark embedding method provided by the present invention;
[0057] Figure 4 It is a comparison diagram between the non-adaptive and adaptive methods provided by the present invention;
[0058] Figure 5 It is a structural schematic diagram of the image watermark embedding device provided by the present invention;
[0059] Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0061] Figure 1 The schematic diagram of the process of the image watermark embedding method provided by the present invention is as follows: Figure 1 As shown, the image watermark embedding method provided by the present invention specifically includes the following steps:
[0062] Step 101: Perform scoring processing on the local area of the image to be embedded with watermark, and determine the watermark embedding area according to the scoring result.
[0063] In this embodiment, it is necessary to perform scoring processing on the local area in the acquired image to be embedded with a watermark, and then determine the watermark embedding area according to the scoring result, wherein the local area can be determined by dividing the image to be embedded with a watermark through a sliding window, determining multiple local areas, and performing scoring processing on the obtained local areas through a preset scoring method, and determining the watermark embedding area according to the scoring result. The specific processing method is shown in the following embodiment and will not be introduced in detail here.
[0064] Step 102: scaling and dividing the watermark embedding area into blocks to obtain a plurality of first divided areas.
[0065] In this embodiment, the watermark embedding area determined in step 101 needs to be scaled and divided into blocks to obtain a plurality of first divided areas, wherein the scaling process refers to reducing or enlarging the watermark embedding area. In this embodiment, the watermark embedding area is scaled to the minimum extent, requiring that its width and height can be divided by v, wherein, L represents the original watermark W = [W 0 ,W 1 ,…,W L-1 ] length, and then divide the watermark embedding area into v*v equal blocks to obtain multiple block areas. Preferably, a randomly generated 361-bit binary sequence is used as the original watermark, and a 0-1 sequence with a length of 361 bits can basically achieve a more comprehensive description of the copyright information. It should be noted that the first block area refers to a block area without embedded watermark, and multiple first block areas constitute a watermark embedding area to be embedded with watermark, which is a local area in the image to be embedded with watermark.
[0066] Step 103: embedding the watermark to be embedded into the plurality of first block regions based on a preset edge spatial domain watermark embedding method, and performing scaling processing according to a preset scaling ratio after embedding to obtain an image containing the watermark.
[0067] In this embodiment, the watermark to be embedded needs to be embedded into multiple first block areas according to a preset edge spatial domain watermark embedding method. After the embedding is successful, the watermark embedding area composed of the multiple first block areas is scaled according to a preset scaling ratio to obtain an image containing the watermark. Among them, if the watermark embedding area to be embedded with the watermark is enlarged in the above step 102, in this embodiment, the watermark embedding area after the watermark is embedded is reduced according to the preset scaling ratio; if the watermark embedding area to be embedded with the watermark is reduced, in this embodiment, the watermark embedding area after the watermark is embedded is enlarged according to the preset scaling ratio; finally, an image containing the watermark is obtained with the same size as the original image.
[0068] It should be noted that the scaling ratio is the minimum scaling ratio that meets the requirements of step 102 and is not specifically limited here.
[0069] According to the image watermark embedding method provided by the present invention, the local area in the image to be embedded with the watermark is scored, and the watermark embedding area is determined according to the scoring result; the watermark embedding area is scaled and divided into blocks to obtain multiple first block areas; the watermark to be embedded is embedded into the multiple first block areas based on the preset edge spatial domain watermark embedding method, and after embedding, the watermark is scaled according to the preset scaling ratio to obtain the image containing the watermark. The image watermark embedding and extraction method provided by the present invention can make full use of the visual features of the image to adjust the embedding strength of the watermark, so that the watermark has good invisibility and robustness, and improves the user experience.
[0070] Based on any of the above embodiments, in this embodiment, before the scoring process is performed on the local area in the image to be embedded with a watermark, the process includes:
[0071] Performing denoising on the image to be embedded with a watermark to obtain a pre-processed image;
[0072] Performing edge detection on the preprocessed image to obtain a binary edge image;
[0073] Obtain pixels in the image to be embedded with watermarks that have the same edge pixel positions as those in the binary edge image, calculate the mean of the grayscale differences between the pixel and each pixel in its eight neighborhoods, and correct the binary edge image based on the relationship between the mean and a preset threshold to determine a first target binary edge image.
[0074] In this embodiment, the image to be embedded with a watermark needs to be preprocessed, edge detection is performed after the preprocessing, and then the obtained binary edge image is post-processed to obtain accurate edge information, which specifically includes the following contents:
[0075] 1) Preprocessing the image to be embedded with a watermark.
[0076] The preprocessing method is: performing discrete cosine transform (DCT) on the image to be embedded with a watermark, and in the DCT domain, traversing the AC coefficients in a "Z" shape from the lower right corner to obtain a coefficient sequence, setting the values of non-zero coefficients in the first 90% of the AC coefficients in the coefficient sequence to zero, eliminating noise information in the image to be embedded with a watermark, and obtaining a preprocessed image.
[0077] 2) Performing edge detection on the preprocessed image.
[0078] The edge detection process is as follows: using an edge detection operator to detect the edge in the preprocessed image to obtain a binary edge image. In the binary edge image, pixels with a gray value of 255 correspond to edge pixels in the image to be embedded with a watermark, i.e., pixels with a sudden change in gray value; pixels with a gray value of 0 correspond to non-edge pixels in the image to be embedded with a watermark, i.e., pixels with a smooth change in gray value.
[0079] It should be noted that, in this embodiment, the edge detection operator is the Canny operator, and other edge detection operators are all applicable to the present invention and belong to the protection scope of the present invention.
[0080] 3) Post-processing the binary edge image, including: obtaining pixels in the image to be embedded with watermarks that have the same edge pixel positions as those in the binary edge image, calculating the mean of the grayscale differences between the pixel and each pixel in its eight neighborhoods, and correcting the binary edge image based on the relationship between the mean and a preset threshold, to determine a first target binary edge image.
[0081] In this embodiment, in order to further improve the detection accuracy, the accuracy of edge pixel detection in the binary edge image is determined by calculating the average of the grayscale differences between each edge pixel and other pixels in the eight neighborhoods in the image to be embedded with the watermark, and comparing it with the preset threshold. It should be noted that the size of the preset threshold can be set according to the actual needs of the user and is not specifically limited here.
[0082] The post-processing method is: in the image to be embedded with watermark, the mean value of the grayscale difference between the edge pixel and the other pixels in its eight neighborhoods is calculated. The specific calculation formula is as follows:
[0083]
[0084] Where D is the eight-neighborhood of edge pixel c, and p is the grayscale value of edge pixel. Delete the falsely detected edges that do not meet the conditions according to the preset threshold τ. If A diff If the value is less than the preset threshold value τ, it is judged as a falsely detected edge, and the grayscale value of the pixel in the binary edge image is set to 0; if the value is greater than the preset threshold value, it is retained, and finally an accurate binary edge image is obtained. In this embodiment, preferably, the value of τ is 20.
[0085] According to the image watermark embedding method provided by the present invention, by preprocessing, edge detection and post-processing the image to be embedded with the watermark, the accuracy of the edge detection of the image can be improved, and the invisibility and robustness of the watermark can be improved.
[0086] Based on any of the above embodiments, scoring is performed on the local area in the image to be embedded with a watermark, and the watermark embedding area is determined according to the scoring result, including:
[0087] Using a sliding window to traverse the first target binary edge image, and determine the edge score of each window area;
[0088] Using a sliding window to traverse the image to be watermarked, determining a texture score, a gray value score and a position score of each window area;
[0089] Determine a comprehensive score for each window area according to the edge score, texture score, grayscale score and position score of each window area and a preset scoring calculation method;
[0090] The comprehensive scores are sorted, and the watermark embedding area is determined according to the sorting result; wherein the preset scoring calculation method is:
[0091]
[0092] Among them, (u, v) are the coordinates of the center point of each window area, m and n are the width and height of each window area respectively, and p i,j =255 is the pixel with a gray value of 255 in the first target binary edge image, that is, the edge pixel in each window area, and num is the number of edge pixels; k p is the proportion of pixels with gray value p in each window area; p i,j Represents the grayscale value of the pixel in the i-th row and j-th column in each window area; (U, V) is the coordinate of the center point of the image; α, β, γ, δ are the scoring weights of the edge score, texture score, grayscale score, and position score of each window area, respectively.
[0093] In this embodiment, it is necessary to use a sliding window to traverse the first target binary edge image and the image to be embedded with a watermark, determine the edge score, texture score, gray value score and position score factors of each window area for scoring, and then select multiple window areas with higher scores in the first target binary edge image as watermark embedding areas;
[0094] The preset scoring calculation method is shown in the above formula (2). It should be noted that, in this embodiment, preferably, α=0.4, β=0.3, γ=0.2, and δ=0.1 are set.
[0095] It should be noted that any watermark embedding and extraction method can be used to embed and extract watermarks in the watermark embedding area, and is not limited to the watermark embedding and extraction method used in the present invention. The use of other watermark embedding and extraction methods to embed and extract watermarks in the watermark embedding area is within the protection scope of the present invention.
[0096] In this embodiment, the first target binary edge image is traversed by a sliding window to calculate the edge score of each window area. It should be noted that the size of the sliding window is proportional to the size of the image to be watermarked, and the ratio is recorded as s1, and the moving step is also proportional to the size of the sliding window, and the ratio is recorded as s2. Preferably, the ratio s1 is set to 1 / 4, and s2 is set to 1 / 4.
[0097] It should be noted that for the spatial domain-based quantization watermark algorithm, the watermark at the edge has a weaker ability to resist attacks under the same embedding strength. In order to improve the robustness of the watermark, the watermark should be embedded in an area with fewer edges. Therefore, if the window area is scored, the window area with fewer edge pixels should be given a higher score.
[0098] In this embodiment, the edge score is expressed as E u,v The specific expression is shown in (3):
[0099]
[0100] Among them, (u, v) represents the coordinates of the center point of the window area, e is a constant, m and n are the width and height of the block area respectively, num pi,j = 255 is the number of edge pixels in the window area. Preferably, e is set to 1, the main function of which is to avoid the denominator being 0, and usually the smallest integer is taken.
[0101] It should be noted that, in this embodiment, it is also necessary to use a sliding window to traverse the image to be embedded with watermarks, and calculate the texture score, grayscale score, and position score of each window area, wherein the size of the sliding window is proportional to the size of the image to be embedded with watermarks, and the ratio is recorded as s1, and the moving step is also proportional to the size of the sliding window, and the ratio is recorded as s2. Preferably, the ratio s1 is set to 1 / 4, and s2 is set to 1 / 4.
[0102] It should be noted that, according to the visual masking characteristics of the human eye, a watermark embedded in an image with rich texture is less likely to be detected by the human eye than a watermark embedded in an image with smooth texture. To ensure the invisibility of the watermark, an area with rich texture should be selected when determining the embedding area. Information entropy characterizes the amount of information contained in an image and is often used to measure the richness of the texture of an image. The richer the texture, the greater the information entropy value. Therefore, in the window area scoring feature, the window area with a larger information entropy value should have a higher corresponding score.
[0103] In this embodiment, the texture score is expressed as H u,v The specific expression is shown in the following formula (4):
[0104]
[0105] Among them, p k Indicates the proportion of pixels with grayscale value k in the window area.
[0106] It should be noted that by modifying the grayscale value of pixels in the spatial domain to embed a watermark, if the watermark is embedded in an area with a grayscale value close to 0 or 255, it is easy to cause the grayscale value to cross the boundary after the grayscale value is modified, resulting in the inability to embed the watermark. Therefore, the more moderate the grayscale level of the window area is, the more suitable it is as a watermark embedding area. In this embodiment, the window area with a moderate grayscale level is set to a higher score.
[0107] In this embodiment, the grayscale value is represented by G u,v The specific expression is shown in the following formula (5):
[0108]
[0109] Among them, p i,j Represents the grayscale value of the pixel in the i-th row and j-th column in the window area.
[0110] It should be noted that during the image transmission process, information near the edge is easily modified or deleted, so the watermark should be embedded as close to the center of the image as possible. In other words, the closer the area is to the center, the higher the score should be.
[0111] In this embodiment, the position score is expressed as P u,v The specific expression is shown in the following formula (6):
[0112]
[0113] Where (U, V) represents the coordinates of the center point of the image to be embedded with the watermark.
[0114] In this embodiment, it is necessary to calculate the feature comprehensive score of each window area according to the edge score, texture score, grayscale score and position score of each window area.
[0115] In this embodiment, the feature comprehensive score is expressed as Score u,v The calculation process is shown in the following formula (7):
[0116] Score u,v =α×E u,v +β×H u,v +γ×G u,v +δ×P u,v (7)
[0117] Among them, α, β, γ, and δ are the weights of the edge score, texture score, grayscale score, and position score of the window area, respectively.
[0118] It should be noted that the weights of the above-mentioned scores are set based on certain theoretical analysis, and the optimal setting is made by analyzing the influence of each feature on the invisibility and robustness of the watermark. Under the premise of the same invisibility, the robustness of the watermark at the edge is poor. For the comprehensive score, the edge score has a larger weight; texture is an evaluation of the overall grayscale distribution of the image, while the grayscale value only reflects the grayscale level of a single pixel in the image. In comparison, the richness of the texture has a greater impact on the watermark, and the weight of the texture score should be slightly higher than the grayscale score. Among them, the edge, texture, and grayscale are all characteristics of the image itself, which can more realistically describe the image information, while the position has nothing to do with the image characteristics. Compared with the other three features, the description of the image information is poor. In the comprehensive score, the relative weight of the position score is set to the smallest. Based on the above analysis, in this embodiment, it is preferred to set α=0.4, β=0.3, γ=0.2, and δ=0.1.
[0119] In this embodiment, it is also necessary to delete the overlapping window areas and retain the window areas with higher feature comprehensive scores as the watermark embedding areas.
[0120] In this embodiment, it is necessary to first arrange the feature comprehensive scores of each window area in descending order; then determine whether the window areas overlap. If two window areas overlap, the embedded watermarks will interfere with each other, affecting the accuracy of watermark extraction. Therefore, in this embodiment, the window areas with smaller feature comprehensive scores in the window areas where the positions overlap are deleted, and the n window areas with the highest feature comprehensive scores in the remaining non-overlapping areas are retained as watermark embedding areas. If the number of window areas finally obtained is less than the threshold value n, all the saved non-overlapping areas are determined as watermark embedding areas. In this embodiment, preferably, the threshold value n is set to 4.
[0121] According to the image watermark embedding method provided by the present invention, a sliding window is used to traverse the first target binary edge image and the image to be embedded with a watermark, the edge score, texture score, grayscale score and position score of each window area are determined, and a comprehensive score is determined. The watermark embedding area is determined according to the sorting result, which can improve the accuracy of positioning the watermark embedding area and improve the invisibility and robustness of image watermark embedding.
[0122] Based on any of the above embodiments, in this embodiment, embedding the watermark to be embedded into the multiple first block areas based on a preset edge spatial domain watermark embedding method includes:
[0123] When embedding the watermark in each first block area, determining the embedding parameters in the preset edge spatial domain watermark embedding method according to the pre-established adaptive parameter adjustment model based on the image edge;
[0124] Based on a preset edge spatial domain watermark embedding method, each bit of the watermark to be embedded is embedded into each first block area, wherein the edge spatial domain watermark embedding method is expressed as:
[0125]
[0126] Among them, f x,y (i, j) is the grayscale value of the pixel at the i-th row and j-th column in the block at the x-th row and y-th column of the watermark embedding area; f* x,y (i, j) is the gray value after modification; a and b represent the width and height of the first block area respectively; N x,y is the number of edge pixels in the first sub-block area; θ is the modification weight of the edge pixels in the first sub-block area; Δ x,y represents the total pixel modification amount in the first sub-block area, and the total pixel modification amount in the first sub-block area Δ x,y The calculation formula is:
[0127]
[0128] Among them, W x,y is the watermark position to be embedded in the first block area, σ x,y is the embedding parameter corresponding to the first block area, used to adjust the strength of watermark embedding.
[0129] In this embodiment, when embedding a watermark in each first block area, it is necessary to determine the embedding parameters in the edge spatial domain watermark embedding method according to a pre-established adaptive parameter adjustment model based on the image edge, and then for each of the first block areas, use the edge spatial domain watermark embedding method to embed a 1-bit watermark in each first block area, and embed all the bits of the watermark in all the first block areas respectively.
[0130] In this embodiment, the edge spatial domain watermark embedding method is expressed as follows:
[0131]
[0132] Among them, f x,y (i, j) is the grayscale value of the pixel at the i-th row and j-th column in the block whose center is located at the x-th row and y-th column of the embedded area, and f* x,y (i,j) is the gray value after modification, ω x,y (i,j) is the pixel modification amount.
[0133] Specifically expressed as:
[0134]
[0135] Among them, f x,y (i, j) is the grayscale value of the pixel at the i-th row and j-th column in the block at the x-th row and y-th column of the watermark embedding area; f* x,y (i, j) is the gray value after modification; a and b represent the width and height of the first block area respectively; N x,y is the number of edge pixels in the first sub-block area; θ is the modification weight of the edge pixels in the first sub-block area; Δ x,y Represents the total pixel modification amount of the first block area.
[0136] It should be noted that in the formula (8), the pixel modification amount ω x,y The calculation formula for (i,j) is as follows:
[0137]
[0138] Wherein, a and b are the width and height of the first block area respectively; N x,yis the number of edge pixels in the first block area; θ is the edge pixel modification weight, and in this embodiment, preferably, θ is 0.4; Δ x,y is the total pixel modification amount in the first block area;
[0139] It should be noted that a block area containing a large number of edge pixels is defined as an edge block, and the number of edge pixels in the edge block is greater than the threshold Th; a block area containing very few or no edge pixels is defined as a smooth block, and the number of edge pixels in the smooth block is less than the threshold Th. In this embodiment, preferably, Th is set to 25.
[0140] It should be noted that the interpretation of formula (10) is: if the block area is a smooth block, the total pixel modification amount is averaged to each pixel in each first block area; if the block area is an edge block, the total pixel modification amount is divided into the total edge pixel modification amount and the total non-edge pixel modification amount according to the adjustable parameter θ, and the pixel type is further determined, and the total edge pixel modification amount is averaged to each edge pixel, and the total non-edge pixel modification amount is averaged to each non-edge pixel.
[0141] It should be noted that the idea of formula (10) is that there are differences in the degree of correlation between different pixels and adjacent pixels in the spatial domain. The similarity between edge pixels and adjacent pixels is extremely low, and it is difficult for the human eye to perceive the change of edge pixels. In contrast, the similarity between non-edge pixels and adjacent pixels is extremely high, which makes the human eye less tolerant of changes in non-edge pixels. When embedding watermarks in the spatial domain, different types of pixels have different tolerances to watermarks. The tolerance of non-edge pixels to watermarks is far less than that of edge pixels. Under the same visual perception requirements, the modification that can be made to non-edge pixels is also far less than that of edge pixels. Based on this, in order to ensure that the quality of the image after embedding the watermark is not affected, when modifying the pixel grayscale value in the spatial domain to embed the watermark, this embodiment needs to adaptively set the pixel modification amount according to the pixel type.
[0142] It should be noted that in the formula (10), the total pixel modification amount Δ in the first block area is x,y The calculation method is as follows:
[0143]
[0144] Among them, W x,y is the watermark position to be embedded in the first block area, σ x,y is the embedding parameter corresponding to the first block area, used to adjust the strength of watermark embedding.
[0145] It should be noted that if the embedding parameter σ x,ySetting it to a fixed value means that the embedding strength of the watermark in different block areas is the same, that is, the modification amount of all pixels is the same. However, different textures in the image have different hiding abilities for watermarks, and the same embedding strength is difficult to ensure that all embedded watermarks have good invisibility. In order not to affect the image quality, only a small embedding parameter σ can be set. x,y The embedding strength of the watermark can be reduced by increasing the embedding strength, but the ability of the watermark to resist attacks is also reduced. Therefore, to solve this defect, the characteristics of the image itself and the visual characteristics of the human eye should be fully considered when setting the embedding parameters. According to the visual masking effect, the human eye is less sensitive to the grayscale change of the edge. For the watermark in the edge block, the embedding strength will not be perceived by the human eye if it is appropriately increased. This embodiment uses this characteristic to design an adaptive parameter adjustment model, which adaptively adjusts the embedding parameters according to the number of edge pixels in the block area to balance the constraints between the invisibility and robustness of the watermark.
[0146] It should be noted that, in the formula (11), according to the number of edge pixels of each first block area, the embedding parameters corresponding to each block area are set using a pre-trained image edge-based adaptive parameter adjustment model. Preferably, the image edge-based adaptive parameter adjustment model is expressed as follows:
[0147]
[0148] in, To ensure the stability of the number of edge pixels.
[0149] It should be noted that when setting the embedding parameters, the adaptive parameter adjustment model based on the image edge shown in the above formula (12) is used to determine the embedding parameters according to the number of edge pixels in the first block area, and the pixel modification amount of the watermark embedding is adaptively adjusted in combination with the size of the block area using formula (11) to ensure that the watermark in the non-edge block is not easily detected. At the same time, the robustness of the watermark in the edge block is improved due to the setting of a greater embedding strength. The training process of the adaptive parameter adjustment model based on the image edge is shown in the following embodiment and is not described in detail here.
[0150] According to the image watermark embedding method provided by the present invention, the watermark to be embedded is embedded into multiple first block areas based on a preset edge spatial domain watermark embedding method to obtain a complete image containing the watermark, thereby improving the invisibility and robustness of the watermark embedding.
[0151] Based on any of the above embodiments, in this embodiment, before the local area in the image to be embedded with a watermark is scored, the method further includes:
[0152] Get image sample dataset;
[0153] According to any of the above-mentioned image watermark embedding methods, a watermark is embedded in the target sample image in the image sample data set, the embedding parameters in the preset edge spatial domain watermark embedding method are adjusted so that the structural similarity of all the second block areas before and after the watermark is embedded is kept within a threshold range, and the embedding parameters of the second block areas are confirmed;
[0154] Confirming the number of edge pixels of the second block area in the target sample image, and determining the corresponding relationship between the number of edge pixels and the embedding parameter of the second block area according to a preset linear regression method;
[0155] An adaptive parameter adjustment model based on the edge image is determined according to the corresponding relationship.
[0156] In this embodiment, before the local area in the image to be embedded with watermark is scored, it is necessary to train and complete the construction of the adaptive parameter adjustment model based on the image edge. The training process specifically includes the following contents:
[0157] First, an image sample data set is obtained, and 100 images are randomly selected from the image data set. Then, the second target binary edge image, the watermark embedding area and the multiple second block areas divided therefrom of each image are determined according to the method described in step 101 and step 102. When the number of the second block areas is the same as the number of watermark bits, the number of edge pixels N in each second block area is calculated and recorded in the second target binary edge image according to the calculation method shown in the following formula (13) for training the model.
[0158]
[0159] Among them, a and b represent the width and height of the second block area respectively, and p i,j It is the edge pixel corresponding to the second block area in the second target binary edge image.
[0160] A watermark is embedded in each second block region using the calculation method shown in the above formulas (9) and (11). By adjusting the embedding parameter value σ in formula (11), the structural similarity (SSIM) of all second block regions before and after the watermark is embedded is kept within the similarity threshold range. The embedding parameter value σ corresponding to each second block region is recorded for training the model.
[0161] To verify the relationship between the two, the number of edge pixels N is taken as the independent variable and the embedding parameter σ is taken as the dependent variable. The correlation coefficient of the two variables is calculated by the following formula (14): r(N, σ) = 0.9942. Based on the calculation results, the linear correlation between the embedding parameter and the number of edge pixels can be determined.
[0162]
[0163] Among them, N i To record the number of edge pixels in the i-th second block area, is the mean number of edge pixels, σ i To record the embedding parameter value corresponding to the i-th second block area, is the mean value of the embedding parameter, and n is the total number of the second block areas.
[0164] The linear regression method is used to fit the data by least squares approximation to train the adaptive parameter adjustment model based on image edges. The specific training method is as follows:
[0165]
[0166] Wherein, σ represents the embedding parameter of the second block area; N represents the number of edge pixels of the second block area. i To record the number of edge pixels in the i-th second block area, is the mean number of edge pixels, σ i To record the embedding parameter value corresponding to the i-th second block area, is the mean value of the embedding parameter, and n is the total number of the second block areas.
[0167] By calculating the values of s and t through the above formula, we can get the functional relationship of the embedding parameter σ in the second block area with respect to the number of edge pixels N, that is, the adaptive parameter adjustment model based on the image edge. In this embodiment, it is specifically shown in formula (16).
[0168] σ=0.2243N+1.5228 (16)
[0169] It should be noted that the adaptive parameter adjustment model based on image edge is derived under the premise of keeping the image to be embedded with watermark having the same SSIM value, which can ensure that the watermark in each watermark embedding area has good invisibility.
[0170] It should be noted that when using the above model to adjust the embedding parameters, one problem still needs to be considered: it is difficult to ensure that the number of edge pixels remains unchanged after the image is attacked. If the embedding parameters are set according to the actual number of edge pixels in the second block area, it cannot be ensured that the embedding parameters remain consistent before and after the image is attacked, which is easy to cause watermark extraction errors. To avoid this problem, when embedding the watermark, the present invention uses formula (13) to count the number of edge pixels N in each second block area in its second target binary edge image. x,y According to the number of edge pixels in each block area and the preset threshold Th, all block areas in the embedded area are divided into edge blocks and non-edge blocks, and each type of block area is assigned a fixed edge pixel number value N* x,y Even if the image deformation causes the actual value of the number of edge pixels to change, it will basically not affect the type of the block area. At the extraction end, an embedding parameter consistent with the embedding can be obtained based on the fixed number of edge pixels corresponding to the block area type. The specific division rules are as follows:
[0171]
[0172] Among them, Th is the threshold used to divide edge blocks and non-edge blocks, and then according to the fixed edge pixel number N* of the block area x,y , using formula (16), adaptively set the embedding parameter σ of the watermark in the block area x,y , so that the watermarks in different types of block areas have different embedding strengths.
[0173] The adaptive parameter adjustment model based on image edges corresponds to the adopted watermark embedding method and is not limited to the use of the watermark embedding method based on image edges in the present invention. The corresponding adaptive parameter adjustment model based on image edges may be obtained by using other watermark embedding methods, which all fall within the protection scope of the present invention.
[0174] It should be noted that the watermark embedding area that does not meet the size requirements needs to be scaled, which will have a slight impact on the image quality. In this embodiment, after the watermark is embedded according to the above steps, the average structural similarity can reach 99.136. Generally, the closer the structural similarity is to 1, the better the visual quality. Figure 2 and 3 As shown, Figure 2 is the image before watermark is embedded. Figure 3 This is the image after the watermark is embedded. It can be seen that the human eye cannot see the difference between the image before and after the watermark is embedded.
[0175] It should be noted that, in order to demonstrate that the use of the adaptive parameter adjustment model based on the image edge to adaptively adjust the embedding parameters can ensure the invisibility of each image, in this embodiment, it is preferred to directly set the embedding parameter σ to a fixed value of 1.523 as a comparison to obtain the same structural similarity as that using the adaptive embedding parameter, and compare the structural similarity of each image obtained by using the fixed embedding parameter and the adaptive embedding parameter. In order to avoid the impact of the scaling operation of the watermark embedding area on the structural similarity, this embodiment selects 100 images that do not require scaling operations, among which, Figure 4 The figure shows the structural similarity of 100 images after embedding watermarks, where non-adaptive means using fixed embedding parameters, and adaptive means using adaptive embedding parameters. It can be seen that when using fixed embedding parameters, there will be many images with low structural similarity, which means that the embedded watermark may be detected. Using adaptive embedding parameters can ensure that the structural similarity of all images is basically close to 1, thereby ensuring the invisibility of the watermark.
[0176] Based on any of the above embodiments, in this embodiment, in order to accurately extract a watermark from an image containing a watermark, the present invention further provides an image watermark extraction method, comprising:
[0177] Scoring the local area of the image to be watermarked, and determining the watermark extraction area according to the scoring result;
[0178] Scaling and dividing the watermark extraction area into blocks to obtain a plurality of third block areas;
[0179] A watermark bit is extracted from each third block region based on a preset edge spatial domain watermark extraction method, and a complete watermark is composed according to the extracted multiple watermark bits.
[0180] In this embodiment, a local area in the image to be watermarked is scored, and then the watermark extraction area is determined based on the scoring result. The watermark extraction area is then scaled and divided into blocks to obtain multiple third block areas. The specific processing process is the same as the steps in the watermark embedding method, and will not be described in detail here.
[0181] In this embodiment, it is also necessary to extract a watermark from each third block region based on a preset edge spatial domain watermark extraction method, and form a complete watermark based on the obtained multiple watermark bits. The third block region refers to a block region containing a watermark to be extracted. The specific extraction method is shown in the following embodiment and will not be described in detail here.
[0182] The image watermark extraction method provided by the present invention can ensure the integrity of the extracted watermark and the robustness of the watermark.
[0183] Based on any of the above embodiments, in this embodiment, extracting a watermark from each third block region based on a preset edge spatial domain watermark extraction method includes:
[0184] When extracting the watermark from each of the third block areas, determining the extraction parameters in the preset edge spatial domain watermark extraction method according to the pre-trained image edge-based adaptive parameter adjustment model;
[0185] Based on a preset edge spatial domain watermark extraction method, a watermark is extracted from each third block area, wherein the expression of the edge spatial domain watermark extraction method is:
[0186]
[0187] Among them, W x,y ' is the watermark position to be extracted in the block located in the xth row and yth column of the watermark extraction area, a' and b' are the length and width of the watermark extraction area respectively, σ x,y ' is to extract parameters, floor() is the rounding down function.
[0188] In this embodiment, for each third block area, a 1-bit watermark is extracted using an edge spatial domain-based watermark extraction method, and the watermark bits extracted from all the third block areas are combined into complete watermark information.
[0189] In this embodiment, the edge spatial domain based watermark extraction method and the edge spatial domain based watermark embedding method in the watermark embedding method have a corresponding relationship. The specific calculation formula is shown in (18) above.
[0190] In the formula (18), according to the number of edge pixels of the third block area, the extraction parameters corresponding to the third block area are set using the adaptive parameter adjustment model based on the image edge. The adaptive parameter adjustment model based on the image edge is expressed as follows:
[0191]
[0192] in, To ensure the stability of the number of edge pixels.
[0193] It should be noted that the third block area containing a large number of edge pixels is defined as an edge block, and the number of edge pixels in the edge block is greater than the threshold Th; the third block area containing very few edge pixels or no edge pixels is defined as a smooth block, and the number of edge pixels in the smooth block is less than the threshold Th. In this embodiment, preferably, Th is set to 25.
[0194] It should be noted that, in this embodiment, a comprehensive analysis is performed on the watermarks extracted from each watermark extraction region of an image to determine the final watermark, wherein an image may have multiple watermark extraction regions, and a watermark is extracted from each watermark extraction region. All watermark sequences extracted from an image are correlated with each other. If the correlation between a certain watermark sequence and more than half of the other watermark sequences is higher than a given correlation threshold, the watermark sequence is taken as a pending watermark sequence. Finally, all pending watermark sequences are aligned bit by bit, and the mode of each bit is taken to form the final watermark sequence.
[0195] Since the same watermark sequence is embedded in each embedding area, the watermark sequence extracted from the watermarked area will still have a strong correlation even if individual watermark bits are extracted incorrectly. However, the falsely detected watermark is a watermark sequence extracted from an area without a watermark embedded, which does not meet the rules of watermark embedding and extraction and is equivalent to being randomly generated. Therefore, the correlation between the falsely detected watermark and the true watermark is weak. According to the above correlation principle, falsely detected watermarks can be excluded even without providing the original watermark information.
[0196] It should be noted that the robustness of the watermarking method is usually evaluated by the bit error rate (BER). The bit error rate is the ratio of the number of erroneous bits to the total number of bits when the extracted watermark is compared with the original watermark. The lower the bit error rate, the better the robustness of the watermark. 0 ,W 1 ,…,W L-1 ] and the extracted watermark sequence W' = [W 0 ',W 1 ',…,W L-1 The bit error rate between '] is calculated as shown in formula (20):
[0197]
[0198] For the 100 watermarked images obtained according to the above image watermark embedding method, various image processing attacks are implemented respectively, including: Gaussian noise with variances of 0.001, 0.01 and 0.3, salt and pepper noise with energies of 0.001, 0.01 and 0.03, median filtering of 3×3, 5×5 and 7×7, mean filtering of 3×3, 5×5 and 7×7, etc., and then an embodiment of an image watermark extraction method is used to extract the watermark from the watermarked image after the attack, and compared with the original watermark, the average bit error rate of the 100 extracted watermarks is shown in Table 1.
[0199] Table 1
[0200]
[0201] A variety of geometric attacks are performed on the 100 watermarked images obtained by the above-mentioned image watermark embedding method embodiment, including: horizontal flipping, vertical flipping, 90-degree counterclockwise rotation, 180-degree counterclockwise rotation, scaling by a factor of 80%, scaling by a factor of 250%, and stretching with an aspect ratio of 0.8×1.4, etc., and then the image watermark extraction method embodiment is used to extract the watermark from the watermarked image after the attack, and compared with the original watermark, the average bit error rate of the 100 extracted watermarks is shown in Table 2.
[0202] Table 2
[0203]
[0204] Figure 5 FIG5 is a schematic diagram of the structure of an image watermark embedding device provided by the present invention. As shown in FIG5 , the image watermark embedding device provided by the present invention comprises:
[0205] A scoring module 501 is used to score the local area in the image to be embedded with a watermark, and determine the watermark embedding area according to the scoring result;
[0206] A processing module 502 is used to scale and block the watermark embedding area to obtain a plurality of first block areas;
[0207] The embedding module 503 is used to embed the watermark to be embedded into the multiple first block areas based on a preset edge spatial domain watermark embedding method, and after embedding, perform scaling processing according to a preset scaling ratio to obtain an image containing the watermark.
[0208] According to the image watermark embedding device provided by the present invention, a local area in the image to be embedded with a watermark is scored, a watermark embedding area is determined according to the scoring result, and then the watermark embedding area is scaled and blocked to obtain a plurality of first block areas. The watermark to be embedded is embedded into the plurality of first block areas based on a preset edge spatial domain watermark embedding method, and after embedding, it is scaled according to a preset scaling ratio to obtain an image containing a watermark. The image watermark embedding device provided by the present invention has good invisibility, improves the robustness of the image watermark, and enhances the user experience.
[0209] Based on any of the above embodiments, in this embodiment, an image watermark extraction device is provided, including:
[0210] A scoring module is used to score the local area of the image to be watermarked, and determine the watermark extraction area according to the scoring result;
[0211] A processing module, used for scaling and dividing the watermark extraction area into blocks to obtain a plurality of third block areas;
[0212] The extraction module is used to extract a watermark bit from each third block area based on a preset edge spatial domain watermark extraction method, and compose a complete watermark according to the extracted multiple watermark bits.
[0213] According to the image watermark extraction device provided by the present invention, the local area in the image to be watermarked is scored, and the watermark extraction area is determined according to the scoring result; the watermark extraction area is scaled and divided into blocks to obtain multiple third block areas; a watermark is extracted from each third block area based on a preset edge spatial domain watermark extraction method, and a complete watermark is formed according to the extracted multiple watermark bits. The watermark obtained by the image watermark extraction device provided by the present invention has good invisibility, improves the robustness of the image watermark, and enhances the user experience.
[0214] Since the principle of the device described in the embodiment of the present invention is the same as that of the method described in the above embodiment, a more detailed explanation is not repeated here.
[0215] Figure 6 Schematic diagram of the physical structure of an electronic device provided in an embodiment of the present invention. Figure 6 As shown, the present invention provides an electronic device, including: a processor (processor) 601, a memory (memory) 602 and a bus 603;
[0216] The processor 601 and the memory 602 communicate with each other via the bus 603;
[0217] The processor 601 is used to call the program instructions in the memory 602 to execute the methods provided in the above-mentioned method embodiments, for example, including: scoring the local area in the image to be embedded with the watermark, and determining the watermark embedding area according to the scoring result; scaling and blocking the watermark embedding area to obtain multiple first block areas; embedding the watermark to be embedded into the multiple first block areas based on a preset edge spatial domain watermark embedding method, and after embedding, scaling it according to a preset scaling ratio to obtain an image containing the watermark.
[0218] Another example is: a local area in an image to be watermarked is scored, and a watermark extraction area is determined based on the scoring result; the watermark extraction area is scaled and divided into blocks to obtain a plurality of third block areas; a watermark bit is extracted from each of the third block areas based on a preset edge spatial domain watermark extraction method, and a complete watermark is formed based on the extracted multiple watermark bits.
[0219] In addition, the logic instructions in the above-mentioned memory 603 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0220] On the other hand, the present invention further provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer, the computer can perform the method provided by the above methods, the method comprising:
[0221] The local area in the image to be embedded with watermark is scored, and the watermark embedding area is determined according to the scoring result; the watermark embedding area is scaled and divided into blocks to obtain a plurality of first block areas; the watermark to be embedded is embedded into the plurality of first block areas based on a preset edge spatial domain watermark embedding method, and after embedding, it is scaled according to a preset scaling ratio to obtain an image containing the watermark.
[0222] Another example is: a local area in an image to be watermarked is scored, and a watermark extraction area is determined based on the scoring result; the watermark extraction area is scaled and divided into blocks to obtain a plurality of third block areas; a watermark bit is extracted from each of the third block areas based on a preset edge spatial domain watermark extraction method, and a complete watermark is formed based on the extracted multiple watermark bits.
[0223] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the computer program is implemented to perform the above-mentioned methods, the method comprising:
[0224] The local area in the image to be embedded with watermark is scored, and the watermark embedding area is determined according to the scoring result; the watermark embedding area is scaled and divided into blocks to obtain a plurality of first block areas; the watermark to be embedded is embedded into the plurality of first block areas based on a preset edge spatial domain watermark embedding method, and after embedding, it is scaled according to a preset scaling ratio to obtain an image containing the watermark.
[0225] Another example is: a local area in an image to be watermarked is scored, and a watermark extraction area is determined based on the scoring result; the watermark extraction area is scaled and divided into blocks to obtain a plurality of third block areas; a watermark bit is extracted from each of the third block areas based on a preset edge spatial domain watermark extraction method, and a complete watermark is formed based on the extracted multiple watermark bits.
[0226] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0227] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, or of course by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0228] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for embedding an image watermark, characterized in that: include: Scoring the local area of the image to be embedded with watermark, and determining the watermark embedding area according to the scoring result; Scaling and dividing the watermark embedding area into blocks to obtain a plurality of first block areas; Embedding the watermark to be embedded into the plurality of first block regions based on a preset edge spatial domain watermark embedding method, and performing scaling processing according to a preset scaling ratio after embedding to obtain an image containing the watermark; Before the scoring process is performed on the local area in the image to be embedded with a watermark, the process includes: Performing denoising on the image to be embedded with a watermark to obtain a pre-processed image; Performing edge detection on the preprocessed image to obtain a binary edge image; Obtain pixels in the image to be embedded with watermarks that have the same edge pixel position as that in the binary edge image, calculate the mean of the grayscale differences between the pixel and each pixel in its eight neighborhoods, and correct the binary edge image according to the relationship between the mean and a preset threshold value to determine a first target binary edge image; The step of scoring the local area in the image to be embedded with a watermark and determining the watermark embedding area according to the scoring result comprises: Using a sliding window to traverse the first target binary edge image, and determine the edge score of each window area; Using a sliding window to traverse the image to be watermarked, determining a texture score, a gray value score and a position score of each window area; Determine a comprehensive score for each window area according to the edge score, texture score, grayscale score and position score of each window area and a preset scoring calculation method; The comprehensive scores are sorted, and the watermark embedding area is determined according to the sorting result; wherein the preset scoring calculation method is: ; in,( u , v ) are the coordinates of the center point of each window area, m , n are the width and height of each window area respectively. p i,j =255 is the pixel with a gray value of 255 in the first target binary edge image, that is, the edge pixel in each window area, and num is the number of edge pixels; k p The gray value in each window area is p The proportion of pixels in p i,j Indicates the first i Row, No. j Gray value of the column pixel; ( U , V ) are the coordinates of the center point of the image; α , β , γ , δ They are the scoring weights for the edge score, texture score, grayscale score, and position score of each window area.
2. The image watermark embedding method according to claim 1, characterized in that: The method for embedding a watermark to be embedded into the plurality of first block regions based on a preset edge spatial domain watermark embedding method includes: When embedding the watermark in each first block area, determining the embedding parameters in the preset edge spatial domain watermark embedding method according to the pre-established adaptive parameter adjustment model based on the image edge; Based on a preset edge spatial domain watermark embedding method, each bit of the watermark to be embedded is embedded into each first block area, wherein the edge spatial domain watermark embedding method is expressed as: ; in, f x,y ( i , j ) is the watermark embedding area x Row, No. y In the block of columns i Row, No. j Gray value of pixel at column; is the gray value after modification; a , b Respectively represent the width and height of the first block area; N x,y is the number of edge pixels in the first block area; θ Modifying weights of edge pixels of the first block area; represents the total pixel modification amount in the first sub-block area, the total pixel modification amount in the first sub-block area The calculation formula is: ; in, W x,y is the watermark position to be embedded in the first block area, σ x,y is the embedding parameter corresponding to the first block area, used to adjust the strength of watermark embedding.
3. The image watermark embedding method according to claim 1, characterized in that: Before the scoring process is performed on the local area in the image to be embedded with the watermark, the method further comprises: Get image sample dataset; Embed a watermark on the target sample image in the image sample data set according to the image watermark embedding method according to any one of claims 1 or 2, adjust the embedding parameters in the preset edge spatial domain watermark embedding method so that the structural similarity of all second block areas before and after the watermark is embedded is maintained within a threshold range, and confirm the embedding parameters of the second block areas; Confirming the number of edge pixels of the second block area in the target sample image, and determining the corresponding relationship between the number of edge pixels and the embedding parameter of the second block area according to a preset linear regression method; An adaptive parameter adjustment model based on the edge image is determined according to the corresponding relationship.
4. A method for extracting an image watermark, characterized in that: include: Scoring the local area of the image to be watermarked, and determining the watermark extraction area according to the scoring result; Scaling and dividing the watermark extraction area into blocks to obtain a plurality of third block areas; Extracting a watermark bit from each third block region based on a preset edge spatial domain watermark extraction method, and forming a complete watermark based on the extracted multiple watermark bits; The method for extracting a watermark based on a preset edge spatial domain watermark includes: When extracting the watermark from each of the third block areas, determining the extraction parameters in the preset edge spatial domain watermark extraction method according to the pre-trained image edge-based adaptive parameter adjustment model; Based on a preset edge spatial domain watermark extraction method, a watermark is extracted from each third block area, wherein the expression of the edge spatial domain watermark extraction method is: ; in, is located in the watermark extraction area x Row, No. y The watermark bits to be extracted in the blocks of the column, and are the length and width of the watermark extraction area respectively, To extract parameters, floor() is a floor function.
5. An image watermark embedding device, characterized in that: include: A scoring module is used to score the local area of the image to be embedded with the watermark, and determine the watermark embedding area according to the scoring result; A processing module, used for scaling and dividing the watermark embedding area into blocks to obtain a plurality of first block areas; An embedding module, used for embedding the watermark to be embedded into the plurality of first block areas based on a preset edge spatial domain watermark embedding method, and performing scaling processing according to a preset scaling ratio after embedding to obtain an image containing the watermark; Before the scoring process is performed on the local area in the image to be embedded with a watermark, the process includes: Performing denoising on the image to be embedded with a watermark to obtain a pre-processed image; Performing edge detection on the preprocessed image to obtain a binary edge image; Obtain pixels in the image to be embedded with watermarks that have the same edge pixel position as that in the binary edge image, calculate the mean of the grayscale differences between the pixel and each pixel in its eight neighborhoods, and correct the binary edge image according to the relationship between the mean and a preset threshold value to determine a first target binary edge image; The step of scoring the local area in the image to be embedded with a watermark and determining the watermark embedding area according to the scoring result comprises: Using a sliding window to traverse the first target binary edge image, and determine the edge score of each window area; Using a sliding window to traverse the image to be watermarked, determining a texture score, a gray value score and a position score of each window area; Determine a comprehensive score for each window area according to the edge score, texture score, grayscale score and position score of each window area and a preset scoring calculation method; The comprehensive scores are sorted, and the watermark embedding area is determined according to the sorting result; wherein the preset scoring calculation method is: ; in,( u , v ) are the coordinates of the center point of each window area, m , n are the width and height of each window area respectively. p i,j =255 is the pixel with a gray value of 255 in the first target binary edge image, that is, the edge pixel in each window area, and num is the number of edge pixels; k p The gray value in each window area is p The proportion of pixels in p i,j Indicates the first i Row, No. j Gray value of the column pixel; ( U , V ) are the coordinates of the center point of the image; α , β , γ , δ They are the scoring weights for the edge score, texture score, grayscale score, and position score of each window area.
6. An image watermark extraction device, characterized in that: include: A scoring module is used to score the local area in the image to be watermarked, and determine the watermark extraction area according to the scoring result; A processing module, used for scaling and dividing the watermark extraction area into blocks to obtain a plurality of third block areas; An extraction module, used for extracting a watermark bit from each third block region based on a preset edge spatial domain watermark extraction method, and forming a complete watermark according to the extracted multiple watermark bits; The method for extracting a watermark based on a preset edge spatial domain watermark includes: When extracting the watermark from each of the third block areas, determining the extraction parameters in the preset edge spatial domain watermark extraction method according to the pre-trained image edge-based adaptive parameter adjustment model; Based on a preset edge spatial domain watermark extraction method, a watermark is extracted from each third block area, wherein the expression of the edge spatial domain watermark extraction method is: ; in, is located in the watermark extraction area x Row, No. y The watermark bits to be extracted in the blocks of the column, and are the length and width of the watermark extraction area respectively, To extract parameters, floor() is a floor function.
7. An electronic device, characterized in that: include: processor, memory and bus, wherein, The processor and the memory communicate with each other via the bus; The memory stores program instructions executable by the processor, and the processor calls the program instructions to execute the steps of the image watermark embedding method according to any one of claims 1 to 3 or the steps of the image watermark extraction method according to claim 4.
8. A non-transitory computer-readable storage medium, characterized in that: The non-transitory computer-readable storage medium stores computer instructions, which enable the computer to execute the steps of the image watermark embedding method according to any one of claims 1 to 3 or the steps of the image watermark extraction method according to claim 4.