A dual image protection method based on frequency domain adversarial watermark
Embedding and extracting watermarks in images through frequency domain adversarial watermark technology solves the problem of poor dual protection effects of anti-disturbance and watermarks in the existing technology, and achieves effective protection of image copyright and semantic information while maintaining high imperceptibility. .
Patent Information
- Application Number
- CN202410891886.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-04
- Publication Date
- 2024-09-17
- Estimated Expiration
- 2044-07-04
AI Technical Summary
Existing technologies are difficult to achieve dual protection against perturbation and digital watermarks without reducing image quality, and existing adversarial attack methods cannot effectively defend against the inference of image semantic information by deep neural network models, and watermark extraction and verification are difficult to achieve.
Adopting an adversarial watermarking method based on the frequency domain, the image is converted to the frequency domain through discrete cosine transform, the watermark is embedded and adversarial is optimized to ensure that the watermark is embedded and extracted in the frequency domain, and converted back to the spatial domain through inverse discrete cosine transform to generate an adversarial watermark Images, enabling blind extraction and verification of adversarial and watermarks.
The generated adversarial watermark image can effectively protect the copyright of the image and prevent the neural network model from inferring the semantic information of the image. At the same time, it maintains the imperceptibility of high watermark disturbance and achieves double protection of the image.
Smart Images

Figure CN118446875B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information security, and in particular to an image dual protection method based on frequency domain countermeasure watermark. Background Art
[0002] With the popularity of portable devices and network platforms, social media has become the main channel for people to share pictures. However, this widespread picture sharing also has potential risks that cannot be ignored. On the one hand, pictures uploaded by users face the risk of copyright infringement due to unauthorized use, which not only infringes on the legal rights of copyright owners, but may also damage their economic interests. On the other hand, the content of the picture may be inferred by deep neural network models to obtain privacy semantic information such as gender, age, emotion, and location, thereby increasing the risk of personal privacy leakage. In view of the above risks, it is particularly important to carry out comprehensive security protection of images from the two levels of copyright protection and personal privacy protection.
[0003] Studies have shown that adding invisible adversarial perturbations to images can destroy the reasoning effect of deep neural network (DNN) models, thereby protecting image semantic information; most existing adversarial attack methods usually use Lp distance in the spatial domain to limit the size of the perturbation, so that the generated adversarial samples "look like" the original image; however, studies have shown that the Lp distance metric is insufficient to evaluate perceptual similarity, and the magnitude of the perturbation amplitude may not directly reflect visual imperceptibility, because these perturbations may still appear in areas that are more easily perceived by the human visual system; in addition, existing adversarial attack methods usually add a meaningless perturbation to the image, making it impossible to extract and verify the watermark. Therefore, existing adversarial attack methods can only achieve single image semantic content protection; unlike adversarial perturbations, digital watermarks are a meaningful information hidden in digital multimedia. By embedding digital watermarks, the use of multimedia content can be effectively tracked and monitored to prevent piracy and infringement. Recent studies have found that the embedding of digital watermarks may lead to DNN model reasoning errors. Although there are existing methods that use watermarks for adversarial attacks, the imperceptibility of watermarks is poor and blind extraction of watermarks cannot be achieved. Therefore, dual protection of images cannot be achieved in actual scenarios. An intuitive idea for dual protection of images is to adopt a two-stage method, that is, embed a watermark first and then add an adversarial perturbation, or add an adversarial perturbation first and then embed a watermark. However, the above two-stage method requires two modifications to the carrier image, which leads to a decrease in image quality. At the same time, there may be mutual influence between the watermark and the perturbation, which reduces the dual protection effect.
[0004] Currently, no effective solution has been proposed for the problems in the related technologies. Summary of the invention
[0005] In view of the problems in the related art, the present invention proposes a dual image protection method based on frequency domain anti-watermarking to overcome the above technical problems existing in the existing related art.
[0006] To this end, the specific technical solution adopted by the present invention is:
[0007] A dual image protection method based on frequency domain countermeasure watermark, the dual image protection method comprising the following steps:
[0008] S1, load the pre-configured target neural network model, read and pre-process the carrier image, the original watermark image, and the frequency domain mask;
[0009] S2, converting the preprocessed carrier image into the frequency domain through discrete cosine transform to obtain frequency domain coefficients, and embedding the watermark in the frequency domain coefficients according to the frequency domain mask and the original watermark image to obtain a frequency domain watermark image;
[0010] S3, iteratively optimizing the adversarial nature of the frequency domain watermark image through gradient optimization, and obtaining the adversarial watermark image in the spatial domain through inverse discrete cosine transform;
[0011] S4. Convert the adversarial watermark image back to the frequency domain through discrete cosine transform, extract the watermark image from the frequency domain, compare the extracted watermark image with the original watermark image, and verify the copyright of the watermark based on the comparison result.
[0012] Optionally, loading a preconfigured target neural network model, reading and preprocessing the carrier image, the original watermark image, and the frequency domain mask comprises the following steps:
[0013] S11, loading a pre-configured deep neural network classifier as the target neural network model for attack, and using cross entropy loss as the loss function of the target neural network model;
[0014] S12, reading the carrier image and the real classification label of the carrier image, the original watermark image and the frequency domain mask;
[0015] S13, preprocessing the read carrier image;
[0016] Among them, the expression of frequency domain mask is:
[0017] ;
[0018] In the formula, represents the frequency domain mask;
[0019] Represents the frequency domain mask In coordinates The value of ;
[0020] Indicates the horizontal position where the disturbance starts;
[0021] represents the vertical position where the disturbance starts;
[0022] represents the size of the disturbance area;
[0023] represents the horizontal coordinate of the disturbance point;
[0024] Represents the vertical coordinate of the disturbance point.
[0025] Optionally, the preprocessed carrier image is converted to the frequency domain by discrete cosine transform to obtain frequency domain coefficients, and a watermark is embedded in the frequency domain coefficients according to the frequency domain mask and the original watermark image to obtain the frequency domain watermark image, including the following steps:
[0026] S21, performing discrete cosine transform on the preprocessed carrier image, and converting the preprocessed carrier image from the spatial domain to the frequency domain to obtain frequency domain coefficients;
[0027] S22, in the area where the preset position value is equal to 1 in the frequency domain mask, the frequency domain coefficient is adjusted according to the value of the original watermark image;
[0028] S23, embedding a watermark at a preset position to obtain a frequency domain watermark image after embedding the original watermark image.
[0029] Optionally, the transformation formula for converting the preprocessed carrier image from the spatial domain to the frequency domain is:
[0030] ;
[0031] In the formula, Indicates the size of the carrier image;
[0032] Respectively represent the horizontal and vertical components in the frequency domain;
[0033] Represents the carrier image in the spatial domain coordinates The pixel value at ;
[0034] Represents the carrier image in the frequency domain coordinates The frequency domain coefficients at ;
[0035] Represents the normalization coefficient, which is used to orthogonalize the transformation basis function;
[0036] Represents the normalization coefficient, which is used to orthogonalize the transformation basis function;
[0037] Represents the spatial domain image conduct Transformation;
[0038] Represents the horizontal coordinate of the spatial domain image;
[0039] Indicates the vertical coordinate of the spatial domain image.
[0040] Optionally, iteratively optimizing the adversarial nature of the frequency domain watermark image by gradient optimization, and obtaining the adversarial watermark image in the spatial domain by inverse discrete cosine transform comprises the following steps:
[0041] S31, using the chain rule to transfer the gradient of the model loss function to the carrier image step by step to the frequency domain;
[0042] S32, in the guarantee model p Under the constraint that the operation result remains unchanged, add a perturbation in the same direction as the gradient to optimize the frequency domain coefficients along the direction where the loss function increases fastest;
[0043] S33, repeating the step of S32 until it is detected that the image embedded with the watermark successfully attacks the deep neural network classification model, stopping the iteration, and obtaining a frequency domain adversarial watermark image;
[0044] S34, convert the frequency domain adversarial watermark image back to the spatial domain using inverse discrete cosine transform, and use The function clips the pixel values of the adversarial watermark image in the spatial domain coordinates to obtain the final spatial domain adversarial watermark image.
[0045] Optionally, add a perturbation in the same direction as the gradient to optimize the frequency domain coefficients along the direction where the loss function increases fastest:
[0046] ;
[0047] In the formula, represents the sign-taking function;
[0048] represents the frequency domain mask;
[0049] Indicates The frequency domain adversarial watermark image obtained by the iteration;
[0050] Indicates The frequency domain adversarial watermark image obtained by the iteration;
[0051] Represents the divisor of the modular operation, which is also the step size of the perturbation;
[0052] represents the loss function;
[0053] Represents the loss function right The gradient obtained by differentiation.
[0054] Optionally, the frequency domain adversarial watermark image is converted back to the spatial domain using inverse discrete cosine transform:
[0055] ;
[0056] In the formula, Respectively represent the horizontal and vertical components of the frequency domain;
[0057] Represents the image in spatial coordinates The pixel value at ;
[0058] Represents the image in frequency domain coordinates The frequency domain coefficients at ;
[0059] Represents the compensation coefficient, which can make The matrix obtained by transformation is an orthogonal matrix;
[0060] Represents the compensation coefficient, which can make The matrix obtained by transformation is an orthogonal matrix;
[0061] Represents the horizontal coordinate of the spatial domain image;
[0062] Represents the vertical coordinate of the spatial domain image;
[0063] Indicates the size of the carrier image;
[0064] Represents the frequency domain matrix conduct Transformation.
[0065] Optionally, the adversarial watermark image is converted back to the frequency domain by discrete cosine transform, and the watermark image is extracted from the frequency domain, and the extracted watermark image is compared with the original watermark image. Verifying the copyright of the watermark according to the comparison result includes the following steps:
[0066] S41, reading the adversarial watermark image and preprocessing it to obtain a spatial domain adversarial watermark image, and using discrete cosine transform to transform the spatial domain adversarial watermark image into the frequency domain to obtain a frequency domain coefficient matrix;
[0067] S42, based on the frequency domain coefficient matrix, using the model p Operationally extracting watermark bits;
[0068] S43, comparing the extracted watermark image with the original watermark image, and calculating the bit matching rate;
[0069] S44, comparing the bit matching rate with a preset threshold for watermark extraction, and judging whether the watermark is extracted successfully based on the comparison result.
[0070] Optionally, the formula for calculating the bit matching rate is:
[0071] ;
[0072] In the formula, represents the indicator function;
[0073] Represents the extracted watermark image With the original watermark image The bit matching rate;
[0074] represents the extracted watermark image;
[0075] represents the original watermark image;
[0076] Represents the horizontal coordinate of the frequency domain image;
[0077] Indicates the vertical coordinate of the frequency domain image.
[0078] Optionally, comparing the bit matching rate with a preset watermark extraction threshold, and judging whether the watermark is extracted successfully according to the comparison result includes the following steps:
[0079] S441, when the bit matching rate is higher than the preset watermark extraction threshold, it is considered that the watermark is successfully extracted, and copyright verification is achieved;
[0080] S442: When the bit matching rate is lower than the preset watermark extraction threshold, it is considered that the watermark extraction has failed and copyright verification cannot be achieved.
[0081] The beneficial effects of the present invention are as follows: the adversarial watermark image generated by the present invention can not only blindly extract the watermark to protect the image copyright, but also defend against the neural network model to protect the image semantic information from being inferred, thereby realizing the protection of the image semantic content; at the same time, the adversarial watermark image has a high imperceptibility to watermark disturbance. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only 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.
[0083] Figure 1 is a framework diagram of an image dual protection method based on frequency domain anti-watermarking according to an embodiment of the present invention;
[0084] Figure 2 Schematic diagram of a watermark embedding and optimization method in a dual image protection method based on frequency domain anti-watermarking according to an embodiment of the present invention;
[0085] Figure 3 Schematic diagram of a watermark extraction method in a dual image protection method based on frequency domain anti-watermarking according to an embodiment of the present invention;
[0086] Figure 4 The present invention is a flowchart of a method for dual image protection based on frequency domain anti-watermarking according to an embodiment of the present invention. DETAILED DESCRIPTION
[0087] To further illustrate each embodiment, the present invention provides drawings, which are part of the disclosure of the present invention and are mainly used to illustrate the embodiments. They can be used in conjunction with the relevant descriptions in the specification to explain the operating principles of the embodiments. With reference to these contents, ordinary technicians in this field should be able to understand other possible implementation methods and advantages of the present invention.
[0088] According to an embodiment of the present invention, a method for dual image protection based on frequency domain anti-watermark is provided.
[0089] The present invention will now be further described with reference to the accompanying drawings and specific embodiments. Figure 1-Figure 4 As shown, according to the image dual protection method based on frequency domain anti-watermarking according to an embodiment of the present invention, the image dual protection method includes the following steps:
[0090] S1. Load the pre-configured target neural network model, read and pre-process the carrier image, original watermark image and frequency domain mask.
[0091] Preferably, loading a preconfigured target neural network model, reading and preprocessing the carrier image, the original watermark image, and the frequency domain mask comprises the following steps:
[0092] S11, loading a pre-configured deep neural network classifier as the target neural network model for attack, and using cross entropy loss as the loss function of the target neural network model;
[0093] S12, reading the carrier image and the real classification label of the carrier image, the original watermark image, the secret code and the frequency domain mask;
[0094] S13, preprocessing the read carrier image;
[0095] Among them, the expression of frequency domain mask is:
[0096] ;
[0097] In the formula, represents the frequency domain mask;
[0098] Represents the frequency domain mask In coordinates The value of ;
[0099] Indicates the horizontal position where the disturbance starts;
[0100] represents the vertical position where the disturbance starts;
[0101] represents the size of the disturbance area;
[0102] represents the horizontal coordinate of the disturbance point;
[0103] Represents the vertical coordinate of the disturbance point.
[0104] It needs to be explained that the read sizes are The carrier image And its corresponding true classification label , size is The initial watermark image, ( is an even number), the size is The frequency domain mask of ; where the expression of the initial watermark image is:
[0105] ;
[0106] in, Represents a binary watermark image In coordinates The watermark bit value at ;
[0107] Indicates the size of the initial watermark image;
[0108] Indicates the horizontal and vertical coordinates of the watermark image.
[0109] S2. Convert the preprocessed carrier image to the frequency domain through discrete cosine transform to obtain frequency domain coefficients, and embed the watermark in the frequency domain coefficients according to the frequency domain mask and the original watermark image to obtain the frequency domain watermark image.
[0110] Preferably, the preprocessed carrier image is converted to the frequency domain by discrete cosine transform to obtain frequency domain coefficients, and a watermark is embedded in the frequency domain coefficients according to the frequency domain mask and the original watermark image to obtain the frequency domain watermark image, comprising the following steps:
[0111] S21, performing discrete cosine transform on the preprocessed carrier image, and converting the preprocessed carrier image from the spatial domain to the frequency domain to obtain frequency domain coefficients;
[0112] S22, in the area where the preset position value is equal to 1 in the frequency domain mask, the frequency domain coefficient is adjusted according to the value of the original watermark image;
[0113] S23, embedding a watermark at a preset position to obtain a frequency domain watermark image after embedding the original watermark image.
[0114] Preferably, the transformation formula for converting the preprocessed carrier image from the spatial domain to the frequency domain is:
[0115] ;
[0116] In the formula, Indicates the size of the carrier image;
[0117] Respectively represent the horizontal and vertical components in the frequency domain;
[0118] Represents the carrier image in the spatial domain coordinates The pixel value at ;
[0119] Represents the carrier image in the frequency domain coordinates The frequency domain coefficients at ;
[0120] Represents the normalization coefficient, which is used to orthogonalize the transformation basis function;
[0121] Represents the normalization coefficient, which is used to orthogonalize the transformation basis function;
[0122] Represents the spatial domain image conduct Transformation;
[0123] Represents the horizontal coordinate of the spatial domain image;
[0124] Indicates the vertical coordinate of the spatial domain image.
[0125] It should be explained that for color images, DCT transformation is performed on RGB channels separately, where and The expression is as follows:
[0126] ;
[0127] In the formula, Indicates the size of the carrier image;
[0128] Represents the compensation coefficient, which can make The matrix obtained by transformation is an orthogonal matrix;
[0129] Represents the compensation coefficient, which can make The transformed matrix is an orthogonal matrix.
[0130] Masking in the frequency domain The frequency domain coefficients of the image are adjusted according to the value of the watermark bit. Specifically: When embedding watermark, When the frequency domain coefficient The result is greater than or equal to ,but , if the frequency domain coefficient The result is less than ,but ; When the watermark is embedded When the frequency domain coefficient The result is less than ,but , if the frequency domain coefficient The result is less than ,but , and finally get the frequency domain watermark image after embedding the basic watermark .in, Indicates at location The watermark bit value at Represents the modulo operator.
[0131] S3. The adversarial nature of the watermark image in the frequency domain is optimized iteratively through gradient optimization, and the adversarial watermark image in the spatial domain is obtained through inverse discrete cosine transform.
[0132] Preferably, iteratively optimizing the adversarial nature of the frequency domain watermark image by gradient optimization, and obtaining the adversarial watermark image in the spatial domain by inverse discrete cosine transform comprises the following steps:
[0133] S31, using the chain rule to transfer the gradient of the model loss function to the carrier image step by step to the frequency domain;
[0134] S32, in the guarantee model p Under the constraint that the operation result remains unchanged, add a perturbation in the same direction as the gradient to optimize the frequency domain coefficients along the direction where the loss function increases fastest;
[0135] S33, repeating the step of S32 until it is detected that the image embedded with the watermark successfully attacks the deep neural network classification model, stopping the iteration, and obtaining a frequency domain adversarial watermark image;
[0136] S34, convert the frequency domain adversarial watermark image back to the spatial domain using inverse discrete cosine transform, and use The function clips the pixel values of the adversarial watermark image in the spatial domain coordinates to obtain the final spatial domain adversarial watermark image.
[0137] It should be explained that after embedding the basic watermark, Under the condition that the operation result remains unchanged, the frequency domain coefficients are optimized based on the gradient. The operation refers to the modulo operation of the frequency domain coefficients, that is, ; The specific optimization method is as follows: Due to the discrete cosine transform ( ) and the inverse discrete cosine transform ( ) are all differentiable, so we first use the chain rule to convert the model loss function The gradient of the image is transferred to the frequency domain step by step, specifically: ,in, Represents the loss function For the frequency domain matrix The gradient of represents the parameters of the model, represents the true label of the carrier image, Next, in the guarantee model Under the constraint that the operation result remains unchanged, a perturbation in the same direction as the gradient is added to optimize the frequency domain coefficients along the direction where the loss function increases fastest, and the steps of S32 are repeated until it is detected that the image embedded with the watermark can successfully attack the deep neural network classification model, that is, , then stop the iteration. Assume that After iterations, the attack is successful. Represents the final frequency domain adversarial watermark image.
[0138] use Function pair Cut to ensure that the range is within The specific formula is: For color images, the three channels are Transformation, finally get the spatial domain adversarial watermark image .
[0139] Preferably, a perturbation is added in the same direction as the gradient to optimize the frequency domain coefficients along the direction where the loss function increases fastest:
[0140] ;
[0141] In the formula, represents the sign-taking function;
[0142] represents the frequency domain mask;
[0143] Indicates The frequency domain adversarial watermark image obtained by the iteration;
[0144] Indicates The frequency domain adversarial watermark image obtained by the iteration;
[0145] Represents the divisor of the modular operation, which is also the step size of the perturbation;
[0146] represents the loss function;
[0147] Represents the loss function right The gradient obtained by differentiation.
[0148] Preferably, the expression for converting the frequency domain anti-watermark image back to the spatial domain using inverse discrete cosine transform is:
[0149] ;
[0150] In the formula, Respectively represent the horizontal and vertical components of the frequency domain;
[0151] Represents the image in spatial coordinates The pixel value at ;
[0152] Represents the image in frequency domain coordinates The frequency domain coefficients at ;
[0153] Represents the compensation coefficient, which can make The matrix obtained by transformation is an orthogonal matrix;
[0154] Represents the compensation coefficient, which can make The matrix obtained by transformation is an orthogonal matrix;
[0155] Represents the horizontal coordinate of the spatial domain image;
[0156] Indicates the vertical coordinate of the spatial domain image.
[0157] It should be explained that for color images, DCT transformation is performed on RGB channels separately, where and The expression is as follows:
[0158] ;
[0159] In the formula, Indicates the size of the carrier image;
[0160] Represents the compensation coefficient, which can make The matrix obtained by transformation is an orthogonal matrix;
[0161] Represents the compensation coefficient, which can make The transformed matrix is an orthogonal matrix.
[0162] Masking in the frequency domain The frequency domain coefficients of the image are adjusted according to the value of the watermark bit. Specifically: When embedding watermark, When the frequency domain coefficient The result is greater than or equal to ,but , if the frequency domain coefficient The result is less than ,but ; When the watermark is embedded When the frequency domain coefficient The result is less than ,but , if the frequency domain coefficient The result is less than ,but , and finally get the frequency domain watermark image after embedding the basic watermark .in, Indicates at location The watermark bit value at Represents the modulo operator.
[0163] S3. The adversarial nature of the watermark image in the frequency domain is optimized iteratively through gradient optimization, and the adversarial watermark image in the spatial domain is obtained through inverse discrete cosine transform.
[0164] Preferably, iteratively optimizing the adversarial nature of the frequency domain watermark image by gradient optimization, and obtaining the adversarial watermark image in the spatial domain by inverse discrete cosine transform comprises the following steps:
[0165] S31, using the chain rule to transfer the gradient of the model loss function to the carrier image step by step to the frequency domain;
[0166] S32, in the guarantee model p Under the constraint that the operation result remains unchanged, add a perturbation in the same direction as the gradient to optimize the frequency domain coefficients along the direction where the loss function increases fastest;
[0167] S33, repeating the step of S32 until it is detected that the image embedded with the watermark successfully attacks the deep neural network classification model, stopping the iteration, and obtaining a frequency domain adversarial watermark image;
[0168] S34, convert the frequency domain adversarial watermark image back to the spatial domain using inverse discrete cosine transform, and use The function clips the pixel values of the adversarial watermark image in the spatial domain coordinates to obtain the final spatial domain adversarial watermark image.
[0169] It should be explained that after embedding the basic watermark, Under the condition that the operation result remains unchanged, the frequency domain coefficients are optimized based on the gradient. The operation refers to the modulo operation of the frequency domain coefficients, that is, ; The specific optimization method is as follows: Due to the discrete cosine transform ( ) and the inverse discrete cosine transform ( ) are all differentiable, so we first use the chain rule to convert the model loss function The gradient of the image is transferred to the frequency domain step by step, specifically: ,in, Represents the loss function For the frequency domain matrix The gradient of represents the parameters of the model, represents the true label of the carrier image, Next, in the guarantee model Under the constraint that the operation result remains unchanged, a perturbation in the same direction as the gradient is added to optimize the frequency domain coefficients along the direction where the loss function increases fastest, and the steps of S32 are repeated until it is detected that the image embedded with the watermark can successfully attack the deep neural network classification model, that is, , then stop the iteration. Assume that After iterations, the attack is successful. Represents the final frequency domain adversarial watermark image.
[0170] use Function pair Cut to ensure that the range is within The specific formula is: For color images, the three channels are Transformation, finally get the spatial domain adversarial watermark image .
[0171] Preferably, a perturbation is added in the same direction as the gradient to optimize the frequency domain coefficients along the direction where the loss function increases fastest:
[0172] ;
[0173] In the formula, represents the sign-taking function;
[0174] represents the frequency domain mask;
[0175] Indicates The frequency domain adversarial watermark image obtained by the iteration;
[0176] Indicates The frequency domain adversarial watermark image obtained by the iteration;
[0177] Represents the divisor of the modular operation, which is also the step size of the perturbation;
[0178] represents the loss function;
[0179] Represents the loss function right The gradient obtained by differentiation.
[0180] Preferably, the expression for converting the frequency domain anti-watermark image back to the spatial domain using inverse discrete cosine transform is:
[0181] ;
[0182] In the formula, Respectively represent the horizontal and vertical components of the frequency domain;
[0183] Represents the image in spatial coordinates The pixel value at ;
[0184] Represents the image in frequency domain coordinates The frequency domain coefficients at ;
[0185] Represents the compensation coefficient, which can make The matrix obtained by transformation is an orthogonal matrix;
[0186] Represents the compensation coefficient, which can make The matrix obtained by transformation is an orthogonal matrix;
[0187] Represents the horizontal coordinate of the spatial domain image;
[0188] Represents the vertical coordinate of the spatial domain image;
[0189] Indicates the size of the frequency domain adversarial watermark image;
[0190] Represents the frequency domain matrix conduct Transformation.
[0191] S4. Convert the adversarial watermark image back to the frequency domain through discrete cosine transform, extract the watermark image from the frequency domain, compare the extracted watermark image with the original watermark image, and verify the copyright of the watermark based on the comparison result.
[0192] Preferably, the counter watermark image is converted back to the frequency domain by discrete cosine transform, and the watermark image is extracted from the frequency domain, and the extracted watermark image is compared with the original watermark image. Verifying the copyright of the watermark according to the comparison result includes the following steps:
[0193] S41, reading the adversarial watermark image and preprocessing it to obtain a spatial domain adversarial watermark image, and using discrete cosine transform to transform the spatial domain adversarial watermark image into the frequency domain to obtain a frequency domain coefficient matrix;
[0194] S42, based on the frequency domain coefficient matrix, using the model p Operationally extracting watermark bits;
[0195] S43, comparing the extracted watermark image with the original watermark image, and calculating the bit matching rate;
[0196] S44, comparing the bit matching rate with a preset threshold for watermark extraction, and judging whether the watermark is extracted successfully based on the comparison result.
[0197] It needs to be explained that the anti-watermark image is read and preprocessed to obtain , using the discrete cosine transform ( ) to convert it to the frequency domain: For color images, the RGB channels are Transformation; represent the horizontal and vertical components of the frequency domain, respectively. Represents the image in frequency domain coordinates The frequency domain coefficients at the position are obtained by using the frequency domain coefficient matrix obtained in the above steps. To extract the watermark, the specific method is: in the frequency domain position If , then extract the watermark bit , otherwise extract the watermark bit ; For color images, the frequency domain coefficient matrix The three channels perform watermarking respectively. If there are two or more channels to extract watermarks , then extract the watermark bit , otherwise, extract the watermark bit ;in, Indicates at location The watermark bit value at represents the extracted watermark image, and the watermark image extracted in step B With the original watermark image Compare and calculate the bit matching rate between the two. hour, ;otherwise, , Represents the extracted watermark image With the original watermark image The closer the value is to 1, the higher the similarity between the two. When , it is considered that the watermark is successfully extracted and copyright verification is achieved; when When , it is considered that the watermark extraction fails and copyright verification cannot be achieved; Indicates the threshold for watermark extraction.
[0198] Preferably, the formula for calculating the bit matching rate is:
[0199] ;
[0200] In the formula, represents the indicator function;
[0201] Represents the extracted watermark image With the original watermark image The bit matching rate;
[0202] represents the extracted watermark image;
[0203] represents the original watermark image;
[0204] Represents the horizontal coordinate of the frequency domain image;
[0205] Indicates the vertical coordinate of the frequency domain image.
[0206] Preferably, comparing the bit matching rate with a preset watermark extraction threshold, and judging whether the watermark is extracted successfully according to the comparison result comprises the following steps:
[0207] S441, when the bit matching rate is higher than the preset watermark extraction threshold, it is considered that the watermark is successfully extracted, and copyright verification is achieved;
[0208] S442: When the bit matching rate is lower than the preset watermark extraction threshold, it is considered that the watermark extraction has failed and copyright verification cannot be achieved.
[0209] To sum up, with the help of the above-mentioned technical scheme of the present invention, the adversarial watermark image generated by the present invention can not only blindly extract the watermark to protect the image copyright, but also defend the neural network model to protect the image semantic information from being inferred, thereby realizing the protection of the image semantic content; at the same time, the adversarial watermark image has a high imperceptibility to watermark disturbance.
[0210] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A dual image protection method based on frequency domain adversarial watermark, characterized in that: The image double protection method comprises the following steps: S1, load the pre-configured target neural network model, read and pre-process the carrier image, original watermark image, and frequency domain mask; S2, converting the preprocessed carrier image into the frequency domain through discrete cosine transform to obtain frequency domain coefficients, and embedding the watermark in the frequency domain coefficients according to the frequency domain mask and the original watermark image to obtain a frequency domain watermark image; S3, iteratively optimizing the adversarial nature of the frequency domain watermark image through gradient optimization, and obtaining the adversarial watermark image in the spatial domain through inverse discrete cosine transform; S4, converting the adversarial watermark image back to the frequency domain through discrete cosine transform, extracting the watermark image from the frequency domain, comparing the extracted watermark image with the original watermark image, and verifying the copyright of the watermark based on the comparison result; The method of iteratively optimizing the adversarial nature of the frequency domain watermark image by gradient optimization and obtaining the adversarial watermark image in the spatial domain by inverse discrete cosine transform comprises the following steps: S31, using the chain rule to transfer the gradient of the model loss function to the carrier image step by step to the frequency domain; S32, in the guarantee model p Under the constraint that the operation result remains unchanged, add a perturbation in the same direction as the gradient to optimize the frequency domain coefficients along the direction where the loss function increases fastest; S33, repeating the step of S32 until it is detected that the image embedded with the watermark successfully attacks the deep neural network classification model, stopping the iteration, and obtaining a frequency domain adversarial watermark image; S34, convert the frequency domain adversarial watermark image back to the spatial domain using inverse discrete cosine transform, and use The function clips the pixel values of the adversarial watermark image in the spatial domain coordinates to obtain the final spatial domain adversarial watermark image.
2. According to claim 1, the image dual protection method based on frequency domain anti-watermark is characterized in that: The loading of the pre-configured target neural network model, reading and pre-processing the carrier image, the original watermark image, and the frequency domain mask comprises the following steps: S11, loading a pre-configured deep neural network classifier as the target neural network model for attack, and using cross entropy loss as the loss function of the target neural network model; S12, reading the carrier image and the real classification label of the carrier image, the original watermark image, and the frequency domain mask; S13, preprocessing the read carrier image; Among them, the expression of frequency domain mask is: ; In the formula, represents the frequency domain mask; Represents the frequency domain mask In coordinates The value of ; Indicates the horizontal position where the disturbance starts; represents the vertical position where the disturbance starts; represents the size of the disturbance area; represents the horizontal coordinate of the disturbance point; represents the ordinate of the disturbance point; Indicates the size of the carrier image.
3. According to claim 2, the image dual protection method based on frequency domain anti-watermarking is characterized in that: The method of converting the preprocessed carrier image into the frequency domain by discrete cosine transform to obtain frequency domain coefficients, and embedding a watermark in the frequency domain coefficients according to the frequency domain mask and the original watermark image to obtain the frequency domain watermark image comprises the following steps: S21, performing discrete cosine transform on the preprocessed carrier image, and converting the preprocessed carrier image from the spatial domain to the frequency domain to obtain frequency domain coefficients; S22, in the area where the preset position value is equal to 1 in the frequency domain mask, the frequency domain coefficient is adjusted according to the value of the original watermark image; S23, embedding a watermark at a preset position to obtain a frequency domain watermark image after embedding the original watermark image.
4. According to claim 3, the image dual protection method based on frequency domain anti-watermarking is characterized in that: The transformation formula for converting the preprocessed carrier image from the spatial domain to the frequency domain is: ; In the formula, Indicates the size of the carrier image; Respectively represent the horizontal and vertical components in the frequency domain; Represents the carrier image in the spatial domain coordinates The pixel value at ; Represents the carrier image in the frequency domain coordinates The frequency domain coefficients at ; Represents the normalization coefficient, which is used to orthogonalize the transformation basis function; Represents the normalization coefficient, which is used to orthogonalize the transformation basis function; Represents the spatial domain image conduct Transformation; Represents the horizontal coordinate of the spatial domain image; Indicates the vertical coordinate of the spatial domain image.
5. The image dual protection method based on frequency domain anti-watermark according to claim 1 is characterized in that: The formula for adding a perturbation in the same direction as the gradient to optimize the frequency domain coefficients along the direction where the loss function increases fastest is: ; In the formula, represents the sign-taking function; represents the frequency domain mask; Indicates The frequency domain adversarial watermark image obtained by the iteration; Indicates The frequency domain adversarial watermark image obtained by the iteration; Represents the divisor of the modular operation and is also the step size of the perturbation; represents the loss function; Represents the loss function right The gradient obtained by differentiation.
6. The image dual protection method based on frequency domain anti-watermarking according to claim 5 is characterized in that: The expression for converting the frequency domain anti-watermark image back to the spatial domain using inverse discrete cosine transform is: ; In the formula, Respectively represent the horizontal and vertical components of the frequency domain; Represents the image in spatial coordinates The pixel value at ; Represents the image in frequency domain coordinates The frequency domain coefficients at ; Represents the compensation coefficient, which can make The matrix obtained by transformation is an orthogonal matrix; Represents the compensation coefficient, which can make The matrix obtained by transformation is an orthogonal matrix; Represents the horizontal coordinate of the spatial domain image; Represents the vertical coordinate of the spatial domain image; Indicates the size of the carrier image; Represents the frequency domain matrix conduct Transformation.
7. The image dual protection method based on frequency domain anti-watermark according to claim 1 is characterized in that: The method of converting the counter watermark image back to the frequency domain through discrete cosine transform, extracting the watermark image from the frequency domain, comparing the extracted watermark image with the original watermark image, and verifying the copyright of the watermark according to the comparison result includes the following steps: S41, reading the adversarial watermark image and preprocessing it to obtain a spatial domain adversarial watermark image, and using discrete cosine transform to transform the spatial domain adversarial watermark image into the frequency domain to obtain a frequency domain coefficient matrix; S42, based on the frequency domain coefficient matrix, using the model p Operationally extracting watermark bits; S43, comparing the extracted watermark image with the original watermark image, and calculating the bit matching rate; S44, comparing the bit matching rate with a preset threshold for watermark extraction, and judging whether the watermark is extracted successfully based on the comparison result.
8. The image dual protection method based on frequency domain anti-watermarking according to claim 7 is characterized in that: The formula for calculating the bit matching rate is: ; In the formula, represents the indicator function; Represents the extracted watermark image With the original watermark image The bit matching rate; represents the extracted watermark image; represents the original watermark image; Represents the horizontal coordinate of the frequency domain image; Represents the vertical coordinate of the frequency domain image; Indicates the size of the initial watermark image.
9. The image dual protection method based on frequency domain anti-watermarking according to claim 8 is characterized in that: The step of comparing the bit matching rate with a preset watermark extraction threshold and judging whether the watermark is extracted successfully according to the comparison result comprises the following steps: S441, when the bit matching rate is higher than the preset watermark extraction threshold, it is considered that the watermark is successfully extracted, and copyright verification is achieved; S442: When the bit matching rate is lower than the preset watermark extraction threshold, it is considered that the watermark extraction has failed and copyright verification cannot be achieved.
