Data protection method and apparatus

By generating a secret image of the same size as the carrier image, multiple QR code images are arranged at intervals and hidden in the carrier image. Through training with an encoder and decoder, the problem of insufficient anti-interference ability of the secret image in the prior art is solved, and the decoding success rate is improved.

CN115482140BActive Publication Date: 2026-06-16QI-ANXIN LEGENDSEC INFORMATION TECH (BEIJING) INC +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
QI-ANXIN LEGENDSEC INFORMATION TECH (BEIJING) INC
Filing Date
2022-08-18
Publication Date
2026-06-16

AI Technical Summary

Technical Problem

Existing technologies fail to effectively consider the anti-interference capabilities of secret images when hiding important data within them, resulting in low decoding success rates.

Method used

A data protection method based on QR code images is adopted. By generating a secret image of the same size as the carrier image, multiple QR code images are arranged at intervals and hidden in the carrier image. The encoder and decoder are used for training to improve the anti-interference ability.

🎯Benefits of technology

It improves the decoding success rate of secret images, and can still successfully decode target data when faced with interference operations such as partial smearing or cropping.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115482140B_ABST
    Figure CN115482140B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a data protection method and device, and relate to the technical field of data security, wherein the method comprises: obtaining target data and a carrier image; determining a plurality of two-dimensional code pictures based on the target data; each of the two-dimensional code pictures containing the target data; arranging the plurality of two-dimensional code pictures to obtain a secret image; hiding the secret image in the carrier image to obtain a stego image; the size of the stego image being the same as the size of the carrier image. The data protection method and device provided by the present application have the advantage that, since the secret image hides a plurality of two-dimensional code pictures containing target data, even if a user performs an interference operation such as local smearing or local cutting on the secret image, the target data can still be decoded based on the two-dimensional code image hidden in the part that has not been smeared or cut, thereby improving the anti-interference ability of secret image decoding and further improving the success rate of secret image decoding.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data security technology, and in particular to a data protection method and apparatus. Background Technology

[0002] With the continuous development of technology, more and more important data needs to be kept confidential. Currently, there are increasingly more channels for data transmission, and the easiest way to leak important data is through taking photos or screenshots. If the source of the data leak cannot be found in time, it is impossible to stop the damage promptly. Therefore, data security is extremely important. Image steganography is a method that uses images as a carrier to hide data that needs to be protected or carried within the carrier image. The generated steganographic image is indistinguishable from the carrier image to the naked eye. It can be applied in fields such as electronic watermarking, copyright recognition, preventing image modification, data security, and transmitting confidential information.

[0003] In related technologies, the Discrete Cosine Transform (DCT) is typically used to convert the carrier image to the frequency domain, or the Discrete Wavelet Transform (DWT) is used to convert the carrier image to the wavelet domain. Then, important data is embedded in the frequency domain or wavelet domain to obtain a secret image containing important data, thus achieving the hiding of important data.

[0004] However, the aforementioned technologies, while achieving the hiding of important data, do not consider the anti-interference capability of the secret image, which will reduce the success rate of decoding the secret image. Summary of the Invention

[0005] To address the problems in the prior art, embodiments of the present invention provide a data protection method and apparatus.

[0006] Specifically, the embodiments of the present invention provide the following technical solutions:

[0007] In a first aspect, embodiments of the present invention provide a data protection method, comprising:

[0008] Acquire target data and carrier images;

[0009] Multiple QR code images are determined based on the target data; each QR code image contains the target data.

[0010] Arrange multiple QR code images to obtain a secret image;

[0011] The secret image is hidden within the carrier image to obtain a secret image; the size of the secret image is the same as the size of the carrier image.

[0012] Furthermore, the step of arranging multiple QR code images to obtain a secret image includes:

[0013] Generate a canvas of a preset color with the same size as the carrier image;

[0014] Based on the size of the canvas and the size of the QR code image, determine the target position for arranging each QR code image on the canvas;

[0015] The secret image is obtained by arranging each QR code image at intervals on the canvas based on each target location.

[0016] Furthermore, at least two of the stated QR code images are of different colors;

[0017] The step of arranging each QR code image on the canvas at intervals based on each target location includes:

[0018] Determine the main color of each target location in the carrier image;

[0019] Based on the colors of the multiple QR code images, a target QR code image matching each of the main body colors is determined;

[0020] Each of the target QR code images is arranged at intervals at its corresponding target position.

[0021] Further, determining the target QR code image that matches the main color of each of the multiple QR code images includes:

[0022] Search a preset list for a hidden color that matches each of the main colors; the preset list stores the correspondence between main colors and hidden colors;

[0023] The QR code image that matches the hidden color among the multiple QR code images is identified as the target QR code image.

[0024] Furthermore, the step of hiding the secret image within the carrier image to obtain the secret image includes:

[0025] The carrier image and the secret image are input into the encoder to obtain the carrier image output by the encoder; the encoder is trained based on carrier image samples and secret image samples.

[0026] Furthermore, the method also includes:

[0027] The target data is obtained by decoding the encrypted image using a decoder.

[0028] Furthermore, the training steps for the encoder and the decoder include:

[0029] Create encoding and decoding models;

[0030] The carrier image sample and the secret image sample are input into the coding model to obtain the carrier image sample output by the coding model;

[0031] The encrypted image sample is input into the decoding model to obtain the decrypted image sample output by the decoding model;

[0032] The encoder and the decoder are trained based on the carrier image sample, the secret image sample, the carrier image sample, and the decrypted image sample.

[0033] Further, training the encoder and the decoder based on the carrier image sample, the secret image sample, the secret-carrying image sample, and the decrypted image sample includes:

[0034] A first loss function is determined based on the carrier image sample and the secret image sample, and a second loss function is determined based on the secret image sample and the decrypted image sample;

[0035] The model parameters of the encoding model are optimized based on the first loss function until the convergence condition is met, thus obtaining the encoder;

[0036] The model parameters of the decoding model are optimized based on the first loss function and the second loss function until the convergence condition is met, thus obtaining the decoder.

[0037] Further, the step of inputting the encrypted image sample into the decoding model to obtain the decrypted image sample output by the decoding model includes:

[0038] The encrypted image sample is subjected to a perturbation operation to obtain a perturbed encrypted image sample;

[0039] The jammed encrypted image sample is input into the decoding model to obtain...

[0040] The decrypted image sample output by the decoding model;

[0041] The interference operations include at least one of the following: smearing, cropping, compressing, zooming in, zooming out, Gaussian blurring, flipping, and rotating.

[0042] Secondly, embodiments of the present invention also provide a data protection device, comprising:

[0043] The acquisition unit is used to acquire target data and carrier images;

[0044] The first determining unit is configured to determine multiple QR code images based on the target data; each QR code image contains the target data.

[0045] The arrangement unit is used to arrange multiple QR code images to obtain a secret image;

[0046] A hiding unit is used to hide the secret image in the carrier image to obtain a secret image; the size of the secret image is the same as the size of the carrier image.

[0047] Thirdly, embodiments of the present invention also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the data protection method as described in the first aspect.

[0048] Fourthly, embodiments of the present invention also provide a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the data protection method as described in the first aspect.

[0049] Fifthly, embodiments of the present invention also provide a computer program product having executable instructions stored thereon, which, when executed by a processor, cause the processor to implement the steps of the data protection method described in the first aspect.

[0050] The data protection method and apparatus provided in this invention first determine multiple QR code images containing the target data based on the target data, then determine a secret image based on the multiple QR code images, and finally hide the secret image in a carrier image to obtain a secret image of the same size as the carrier image, thereby achieving protection of the target data. Because the secret image hides multiple QR code images containing the target data, even if the user performs interference operations such as partial obfuscation or cropping on the secret image, the target data can still be decoded based on the QR code images hidden in the unobfuscated or uncropped areas. This improves the anti-interference capability of the secret image decoding and further increases the success rate of secret image decoding. Attached Figure Description

[0051] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0052] Figure 1 This is one of the flowcharts illustrating the data protection method provided in this embodiment of the invention;

[0053] Figure 2 This is a schematic diagram of the arrangement and hiding provided in the embodiments of the present invention;

[0054] Figure 3 This is a second schematic flowchart of the data protection method provided in this embodiment of the invention;

[0055] Figure 4 This is the third flowchart illustrating the data protection method provided in this embodiment of the invention;

[0056] Figure 5 This is the fourth flowchart illustrating the data protection method provided in this embodiment of the invention;

[0057] Figure 6 This is the fifth flowchart illustrating the data protection method provided in this embodiment of the invention;

[0058] Figure 7 This is the sixth flowchart illustrating the data protection method provided in this embodiment of the invention;

[0059] Figure 8 This is a schematic diagram of the structure of the coding model provided by the present invention;

[0060] Figure 9 This is a schematic diagram of the decoding model provided by the present invention;

[0061] Figure 10 This is the seventh flowchart illustrating the data protection method provided in this embodiment of the invention;

[0062] Figure 11 This is a schematic diagram of the structure of the data protection device provided in an embodiment of the present invention;

[0063] Figure 12 This is a schematic diagram of the physical structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation

[0064] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0065] Figure 1 This is one of the flowcharts illustrating the data protection method provided in this embodiment of the invention, such as... Figure 1 As shown, this data protection method includes the following steps:

[0066] Step 101: Acquire target data and carrier image.

[0067] The target data can be images, identity information, string information, or code information, etc.

[0068] For example, the target data is important data that the user needs to protect, and the carrier image is a picture used to carry the target data. The target data and carrier image can be obtained from the memory of the electronic device or received from other devices.

[0069] Step 102: Determine multiple QR code images based on the target data.

[0070] Each of the QR code images contains the target data. A QR code is a graphic that records data symbols by distributing specific geometric shapes in a two-dimensional plane. It cleverly utilizes the concept of "0" and "1" bit streams, which form the basis of computer logic, to represent textual and numerical information using several geometric shapes corresponding to binary. This information is automatically processed by image input devices or photoelectric scanning devices. QR codes share some common characteristics with barcode technology: each code system has its specific character set, each character occupies a certain width, and it has certain verification functions, etc.

[0071] For example, the target data is converted into a QR code image of a preset size through format conversion. This QR code image includes the specific content of the target data. Based on the preset size and the size of the carrier image, the target number of QR code images to be copied is determined. Then, the QR code images are copied to obtain the target number of identical QR code images. Alternatively, the target data can be converted into multiple QR code images of different sizes based on the size of the carrier image. Since QR code images can store a large amount of data information, applying QR codes in image steganography can increase the steganography capacity, that is, increase the capacity to hide target data. Moreover, the target data contained in the QR code image can be images, identification information, string information, or code information, thereby increasing the types of data that can be hidden.

[0072] It should be noted that the specific size of the QR code image can be set according to requirements, and this invention does not impose any limitations on it.

[0073] Step 103: Arrange multiple QR code images to obtain a secret image.

[0074] For example, when multiple QR code images containing target data are obtained, the multiple QR code images are arranged on a preset canvas to obtain a secret image, which is the image containing the target data.

[0075] It should be noted that the size of each QR code image must be smaller than the size of the carrier image, and the size of the secret image must be smaller than or equal to the size of the carrier image.

[0076] Step 104: Hide the secret image in the carrier image to obtain a secret image; the size of the secret image is the same as the size of the carrier image.

[0077] Among them, a hidden image is an image in which the target data has been concealed.

[0078] For example, when a secret image is obtained, it is covered by a carrier image to hide the secret image. In order to prevent the hidden target data from being discovered in the secret image, the size of the secret image needs to be the same as the size of the carrier image. This makes it easy for users to think that the secret image is the carrier image, and prevents users from using improper means to decode the secret image to obtain the target data. Figure 2 This is a schematic diagram of the arrangement and hiding provided in the embodiments of the present invention, such as... Figure 2 As shown, multiple identical QR codes are arranged on a canvas of a preset color to obtain a secret image, which is then hidden within a carrier image. Figure 2 In the image filled with diagonal lines; it should be noted that, Figure 2 In order to show that the secret image is covered by the carrier image, a portion of the secret image is moved out of the carrier image. In practical applications, the secret image is completely covered by the carrier image.

[0079] The data protection method provided in this invention first determines multiple QR code images containing the target data based on the target data, then determines a secret image based on the multiple QR code images, and finally hides the secret image in a carrier image to obtain a secret image of the same size as the carrier image, thus achieving protection of the target data. Because the secret image hides multiple QR code images containing the target data, even if the user performs interference operations such as partial obfuscation or cropping on the secret image, the target data can still be decoded based on the QR code images hidden in the unobfuscated or uncropped areas. This improves the anti-interference capability of the secret image decoding and further increases the success rate of secret image decoding.

[0080] Optionally, Figure 3 This is a second schematic flowchart of the data protection method provided in this embodiment of the invention, as shown below. Figure 3 As shown, step 103 above can be implemented through the following steps:

[0081] Step 1031: Generate a canvas of a preset color with the same size as the carrier image.

[0082] The default color can be gray because gray is the least likely to be noticed when it is hidden.

[0083] For example, a gray canvas of the same size as the carrier image is generated.

[0084] Step 1032: Based on the size of the canvas and the size of the QR code image, determine the target position for arranging each QR code image on the canvas.

[0085] The dimensions of each QR code image can be the same or different.

[0086] For example, the size of each QR code can be preset based on the size of the canvas. Assuming the canvas size is 100mm (millimeters) * 40mm, and the size of each QR code image is 20mm * 20mm, then less than or equal to 10 QR code images can be arranged on the canvas.

[0087] Step 1033: Arrange each QR code image on the canvas at intervals based on each target location to obtain the secret image.

[0088] Among them, "interval arrangement" means that there is a preset distance between two adjacent QR code images. This preset distance can be greater than or equal to zero, as long as it ensures that each QR code image arranged on the canvas does not overlap.

[0089] For example, when determining each target location, each QR code image can be pasted at intervals in the corresponding position on the canvas, thus obtaining a secret image containing multiple QR code images.

[0090] The data protection method provided in this invention arranges multiple QR code images containing target data at intervals on a canvas based on each target location to obtain a secret image. This achieves a unified arrangement of multiple QR code images, and since the secret image contains multiple identical QR code images, it can greatly improve the recall rate during decoding.

[0091] Optionally, at least two of the multiple QR code images are of different colors; Figure 4 This is the third flowchart illustrating the data protection method provided in this embodiment of the invention, as shown below. Figure 4 As shown, step 1033 above can be implemented in the following ways:

[0092] Step 10331: Determine the main color of each target location in the carrier image.

[0093] Among the multiple QR code images, there are at least two QR code images of different colors. The color of the QR code image includes a foreground color and a background color. In practical applications, the background color of each QR code image can be set to the same color, for example, gray; the foreground color of each QR code image can be set to a single color, for example, a single brown or a single purple, or the foreground color of the same QR code image can contain two or more similar colors.

[0094] For example, based on the target location of each obtained QR code image, the main color of each target location in the carrier image is identified using image recognition technology. For instance, if blue accounts for 90% and white accounts for 10% in the image corresponding to the target location, then blue is determined as the main color of the target location.

[0095] Step 10332: Based on the colors of the multiple QR code images, determine the target QR code image that matches the main color of each of the main images.

[0096] Specifically, a hidden color matching each of the main colors is searched in a preset list; and the QR code image that matches the hidden color among the multiple QR code images is determined as the target QR code image.

[0097] The preset list stores the correspondence between the main color and the hidden color. The correspondence between the main color and the hidden color is determined based on the difficulty of the hidden color to be discovered. For example, if the main color is blue and the corresponding hidden color is purple, then after the blue covers the purple, the purple color will not be easily discovered.

[0098] For example, when identifying the main color of each target location in the carrier image, the hidden color corresponding to each main color is searched in a preset list. Then, the QR code image that matches the hidden color among multiple QR code images is determined as the target QR code image. Here, the QR code image that matches the hidden color can be a QR code image with the same hidden color or a QR code image with a similar hidden color. For example, if the hidden color corresponding to the main color is purple, then the QR code image with purple as the foreground color is determined as the target QR code image.

[0099] Step 10333: Arrange each of the target QR code images at intervals in the corresponding target positions.

[0100] For example, when the target QR code image corresponding to each target location is determined, each target QR code image is pasted at intervals on the corresponding target location, thereby realizing the generation of the secret image.

[0101] The data protection method provided in this invention matches the main color of each target location in the carrier image with the color of the QR code image, and arranges each QR code image on the corresponding target location. This achieves preprocessing of multiple QR code images, so that the color of each target location in the encrypted image can effectively hide the QR code image with the matching color, thereby improving the concealment of the encrypted image.

[0102] Optionally, Figure 5 This is the fourth flowchart illustrating the data protection method provided in this embodiment of the invention, as shown below. Figure 5 As shown, step 104 above can be implemented through the following steps:

[0103] Step 1041: Input the carrier image and the secret image into the encoder to obtain the carrier image output by the encoder.

[0104] The encoder is trained based on carrier image samples and secret image samples.

[0105] For example, an encoder is pre-trained based on carrier image samples and secret image samples. The carrier image and secret image are then connected through the encoder's convolutional layer and input into the encoder. The encoder fuses the carrier image and secret image to obtain a carrier-secret image with the same size as the carrier image, which is output by the encoder. The secret image is hidden in the carrier image, making the carrier-secret image look the same as the carrier image.

[0106] It should be noted that the sizes of the carrier image and secret image input to the encoder need to match the number of downsampling layers and upsampling layers of the encoder. For example, if the encoder includes four downsampling layers and four upsampling layers, then the sizes of the carrier image and secret image input to the encoder must be multiples of 16. However, in practical applications, not every image meets this requirement. Therefore, in order to avoid scaling the input carrier image and secret image, when the size of the carrier image or secret image does not meet the multiple of 16 requirement, a padding operation is needed to expand the carrier image or secret image so that the size of the expanded carrier image and the expanded secret image both meet the multiple of 16 requirement, ensuring that a carrier image with the same size as the carrier image can be obtained.

[0107] The data protection method provided in this invention automatically fuses a carrier image and a secret image using a pre-trained encoder. By fusing the images, the secret image is hidden within the carrier image, achieving automatic hiding of the secret image with high efficiency.

[0108] Optionally, Figure 6 This is the fifth flowchart illustrating the data protection method provided in this embodiment of the invention, as shown below. Figure 6 As shown, after performing step 104 above, the data protection method further includes the following steps:

[0109] Step 105: Decode the encrypted image using a decoder to obtain the target data.

[0110] For example, after the encoder obtains the secret image through the method in any of the above embodiments, when it needs to extract the target data, it can send the secret image to other devices and extract the secret image from the secret image through the decoder of other devices, or it can extract the secret image from the secret image through the decoder in its own device, and then decode the QR code image in the secret image to finally obtain the target data contained in the QR code image.

[0111] It should be noted that when decoding the QR code images in the secret image, all QR code images in the secret image are decoded. For each QR code image, if decoding is successful, the target data in that QR code image and its coordinate position in the secret image are returned; if decoding fails, no data is returned. For example, if the secret image contains five QR code images, and four of them are successfully decoded, the coordinate positions of these four QR code images in the secret image and their corresponding target data are returned, while no data is returned for the QR code image that failed to be decoded.

[0112] It should be noted that the electronic device includes an encoder and a decoder. The encoder generates a coded image and sends it to other devices. The other devices then decode the received coded image to obtain the target data hidden within it. The electronic device can also receive coded images sent by other devices and decode them to obtain the target data hidden within them.

[0113] The data protection method provided in this invention sends a classified image to a decoder, and the decoder decodes the target data in the classified image. This method protects the target data when transmitting the classified image and can also decode the target data from the classified image.

[0114] Optionally, Figure 7 This is the sixth flowchart illustrating the data protection method provided in this embodiment of the invention, as shown below. Figure 7 As shown, this data protection method also includes the following encoder and decoder training steps:

[0115] Step 106: Create the encoding model and the decoding model.

[0116] It should be noted that the encoding model can be considered as the initial model of the encoder that needs to be trained, and the decoding model can be considered as the initial model of the decoder that needs to be trained. The optimal model obtained after training and optimization is the encoder and decoder that are needed.

[0117] For example, Figure 8 This is a schematic diagram of the structure of the coding model provided by the present invention, as shown below. Figure 8 As shown, the encoding model adopts a UNet-type network structure, including 4 upsampling layers and 4 downsampling layers. Each upsampling layer has a sampling factor of 2x; each downsampling layer has a sampling factor of 2x, ensuring that the image input to the encoding model and the image output by the encoding model are of the same size. Figure 8 In the image, solid arrows indicate downsampling, dashed arrows indicate upsampling, double-dotted arrows indicate concat operations (swapping), h represents the image height, w represents the image width, and the number above each image indicates the number of channels.

[0118] Figure 9 This is a schematic diagram of the decoding model provided by the present invention, as shown below. Figure 9 As shown, the decoding model only requires a few simple convolutional layers, without any upsampling or downsampling layers. After obtaining the secret image, the QR code image in the secret image can be decoded to extract the decoded information, that is, the target data. Figure 9 In the image, the number above each image indicates the number of channels.

[0119] Step 107: Input the carrier image sample and the secret image sample into the encoding model to obtain the carrier image sample output by the encoding model.

[0120] Step 108: Input the encrypted image sample into the decoding model to obtain the decrypted image sample output by the decoding model.

[0121] Step 109: Train the encoder and the decoder based on the carrier image sample, the secret image sample, the carrier image sample, and the decrypted image sample.

[0122] For example, a training set is obtained, and all images in the training set are fed into the encoding model in batches for computation. A portion of the images in one batch are used as carrier image samples, and another portion are used as secret image samples. Then, the carrier image samples and secret image samples are concatenated through the convolutional layer of the encoding model and input into the encoding model to obtain the secret image samples output by the encoding model. If no interference training is needed, the secret image samples output by the encoding model are directly input into the decoding model to obtain the decrypted image samples output by the decoding model. Finally, based on the analysis of the carrier image samples, secret image samples, secret image samples, and decrypted image samples, the model parameters of the encoding model and the decoding model are adjusted, and the next batch of training is carried out until the convergence condition is reached, resulting in the finally trained encoder and decoder.

[0123] The data protection method provided in this invention implements joint training of the encoding model and the decoding model based on carrier image samples and secret image samples, and finally obtains the trained encoder and decoder. The encoder is then used to fuse the secret image and the carrier image, and the decoder is used to decode the secret image.

[0124] Optionally, step 109 above can be implemented in the following ways:

[0125] A first loss function is determined based on the carrier image sample and the secret image sample, and a second loss function is determined based on the secret image sample and the decrypted image sample;

[0126] The model parameters of the encoding model are optimized based on the first loss function until the convergence condition is met, thus obtaining the encoder;

[0127] The model parameters of the decoding model are optimized based on the first loss function and the second loss function until the convergence condition is met, thus obtaining the decoder.

[0128] For example, a first loss function is determined based on the carrier image sample and the secret image sample to obtain a first error value between the carrier image sample and the secret image sample. A second error function is determined based on the secret image sample and the decrypted image sample to obtain a second error value between the secret image sample and the decrypted image sample. The first error value and the second error value are weighted and added together to obtain the total loss function of the entire network framework. The model parameters of the encoding model are adjusted based on the first loss function, and the model parameters of the decoding model are adjusted based on the total loss function. The next batch of training is carried out until the convergence condition is met and the training is completed. The final encoding model is used as the encoder, and the final decoding model is used as the decoder.

[0129] It should be noted that when training the encoding and decoding models, the encoder obtained from the above training can be used as a pre-trained encoder, and the decoder obtained from the above training can be used as a pre-trained decoder. A portion of the images in the training set can be selected as carrier image samples, and randomly generated QR code images can be used as secret image samples. The pre-trained encoder and pre-trained decoder can be trained again according to the above method, and the model parameters can be further fine-tuned to obtain the final encoder and decoder.

[0130] The data protection method provided in this invention optimizes the encoding and decoding models based on the constructed loss function, thereby improving the accuracy of the final encoder and decoder.

[0131] Optionally, Figure 10 This is the seventh flowchart illustrating the data protection method provided in this embodiment of the invention, as shown below. Figure 10 As shown, step 108 above can be implemented through the following steps:

[0132] Step 1081: Perform a jamming operation on the encrypted image sample to obtain a jammed encrypted image sample.

[0133] The interference operations include at least one of the following: smearing, cropping, compressing, zooming in, zooming out, Gaussian blurring, flipping, and rotating.

[0134] For example, in order to enable the trained decoder to successfully decode the encrypted image with added interference, an interference layer is added between the encoding model and the decoding model to perform interference operations such as smearing, cropping, compression, enlarging, shrinking, Gaussian blurring, flipping and rotating on the encrypted image output from the encoding model.

[0135] Step 1082: Input the jammed encrypted image sample into the decoding model to obtain the decrypted image sample output by the decoding model.

[0136] For example, a coded image sample with added interference is input into the decoding model, which then performs feature analysis and other processing on the coded image with added interference, ultimately obtaining a decrypted image sample output by the decoding model.

[0137] The data protection method provided in this invention adds an interference layer between the encoding model and the decoding model. The interference operation is performed on the secret image samples output from the encoding model, and the interference-encoded secret image is input into the decoding model. This enables the decoder that is finally trained to successfully decode the interference-encoded secret image, resist more types of interference, and thus improve the robustness of decoding.

[0138] Figure 11 This is a schematic diagram of the data protection device provided in an embodiment of the present invention, as shown below. Figure 11 As shown, the data protection device includes an acquisition unit 1101, a first determination unit 1102, an arrangement unit 1103, and a hiding unit 1104; wherein:

[0139] Acquisition unit 1101 is used to acquire target data and carrier image;

[0140] The first determining unit 1102 is used to determine a plurality of QR code images based on the target data; each QR code image contains the target data.

[0141] The arrangement unit 1103 is used to arrange multiple QR code images to obtain a secret image;

[0142] The hiding unit 1104 is used to hide the secret image in the carrier image to obtain a secret image; the size of the secret image is the same as the size of the carrier image.

[0143] The data protection device provided in this invention first determines multiple QR code images containing the target data based on the target data, then determines a secret image based on the multiple QR code images, and finally hides the secret image in a carrier image, resulting in a secret image of the same size as the carrier image, thus achieving protection of the target data. Because the secret image hides multiple QR code images containing the target data, even if the user performs interference operations such as partial obfuscation or cropping on the secret image, the target data can still be decoded based on the QR code images hidden in the unobfuscated or uncropped areas. This improves the anti-interference capability of the secret image decoding and further increases the success rate of secret image decoding.

[0144] Based on any of the above embodiments, the arrangement unit 1103 is specifically used for:

[0145] Generate a canvas of a preset color with the same size as the carrier image;

[0146] Based on the size of the canvas and the size of the QR code image, determine the target position for arranging each QR code image on the canvas;

[0147] The secret image is obtained by arranging each QR code image at intervals on the canvas based on each target location.

[0148] Based on any of the above embodiments, at least two of the multiple QR code images are of different colors; the arrangement unit 1103 is further specifically used for:

[0149] Determine the main color of each target location in the carrier image;

[0150] Based on the colors of the multiple QR code images, a target QR code image matching each of the main body colors is determined;

[0151] Each of the target QR code images is arranged at intervals at its corresponding target position.

[0152] Based on any of the above embodiments, the arrangement unit 1103 is further specifically used for:

[0153] Search a preset list for a hidden color that matches each of the main colors; the preset list stores the correspondence between main colors and hidden colors;

[0154] The QR code image that matches the hidden color among the multiple QR code images is identified as the target QR code image.

[0155] Based on any of the above embodiments, the hiding unit 1104 is specifically used for:

[0156] The carrier image and the secret image are input into the encoder to obtain the carrier image output by the encoder; the encoder is trained based on carrier image samples and secret image samples.

[0157] Based on any of the above embodiments, the device further includes:

[0158] The decoding unit is used to decode the encrypted image to obtain the target data.

[0159] Based on any of the above embodiments, the device further includes:

[0160] Create units to create encoding and decoding models;

[0161] The encoding unit is used to input the carrier image sample and the secret image sample into the encoding model to obtain the carrier image sample output by the encoding model;

[0162] The decoding unit is also used to input the encrypted image sample into the decoding model to obtain the decrypted image sample output by the decoding model;

[0163] The second determining unit is used to train the encoder and the decoder based on the carrier image sample, the secret image sample, the carrier image sample, and the decrypted image sample.

[0164] Based on any of the above embodiments, the second determining unit is specifically used for:

[0165] A first loss function is determined based on the carrier image sample and the secret image sample, and a second loss function is determined based on the secret image sample and the decrypted image sample;

[0166] The model parameters of the encoding model are optimized based on the first loss function until the convergence condition is met, thus obtaining the encoder;

[0167] The model parameters of the decoding model are optimized based on the first loss function and the second loss function until the convergence condition is met, thus obtaining the decoder.

[0168] Based on any of the above embodiments, the decoding unit is specifically used for:

[0169] The encrypted image sample is subjected to a perturbation operation to obtain a perturbed encrypted image sample;

[0170] The jammed encrypted image sample is input into the decoding model to obtain the decrypted image sample output by the decoding model;

[0171] The interference operations include at least one of the following: smearing, cropping, compressing, zooming in, zooming out, Gaussian blurring, flipping, and rotating.

[0172] Figure 12 This is a schematic diagram of the physical structure of the electronic device provided in the embodiments of the present invention, such as... Figure 12 As shown, the electronic device may include a processor 1210, a communications interface 1220, a memory 1230, and a communication bus 1240. The processor 1210, communications interface 1220, and memory 1230 communicate with each other via the communication bus 1240. The processor 1210 can call logical instructions from the memory 1230 to execute the following method: acquiring target data and a carrier image;

[0173] Multiple QR code images are determined based on the target data; each QR code image contains the target data.

[0174] Arrange multiple QR code images to obtain a secret image;

[0175] The secret image is hidden within the carrier image to obtain a secret image; the size of the secret image is the same as the size of the carrier image.

[0176] Furthermore, the logical instructions in the aforementioned memory 1230 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0177] On the other hand, the present invention also provides a computer program product, the computer program product including a computer program, the computer program being able to be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer is able to execute the data protection method provided by the above methods, the method including: acquiring target data and carrier image;

[0178] Based on the target data, a plurality of QR code images are determined; each of the QR code images contains the target data.

[0179] Arrange multiple QR code images to obtain a secret image;

[0180] The secret image is hidden within the carrier image to obtain a secret image; the size of the secret image is the same as the size of the carrier image.

[0181] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the data protection methods provided by the methods described above, the method comprising: acquiring target data and a carrier image;

[0182] Multiple QR code images are determined based on the target data; each QR code image contains the target data.

[0183] Arrange multiple QR code images to obtain a secret image;

[0184] The secret image is hidden within the carrier image to obtain a secret image; the size of the secret image is the same as the size of the carrier image.

[0185] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0186] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0187] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A data protection method, characterized in that, include: Acquire target data and carrier images; Multiple QR code images are determined based on the target data; each QR code image contains the specific content of the target data, and at least two of the multiple QR code images are of different colors; Generate a canvas of a preset color with the same size as the carrier image; Based on the size of the canvas and the size of the QR code image, determine the target position for arranging each QR code image on the canvas; Determine the main color of each target location in the carrier image; Based on the colors of the multiple QR code images, a target QR code image matching each of the main body colors is determined; Each of the target QR code images is arranged at intervals at its corresponding target position to obtain a secret image; The secret image is hidden within the carrier image to obtain a secret image; the size of the secret image is the same as the size of the carrier image.

2. The data protection method according to claim 1, characterized in that, The step of determining a target QR code image that matches the main color of each of the multiple QR code images includes: Search a preset list for a hidden color that matches each of the main colors; the preset list stores the correspondence between main colors and hidden colors; The QR code image that matches the hidden color among the multiple QR code images is identified as the target QR code image.

3. The data protection method according to claim 1 or 2, characterized in that, The step of hiding the secret image within the carrier image to obtain the secret image includes: The carrier image and the secret image are input into the encoder to obtain the carrier image output by the encoder; the encoder is trained based on carrier image samples and secret image samples.

4. The data protection method according to claim 3, characterized in that, After hiding the secret image within the carrier image to obtain the secret image, the method further includes: The target data is obtained by decoding the encrypted image using a decoder.

5. The data protection method according to claim 4, characterized in that, The training steps for the encoder and the decoder include: Create encoding and decoding models; The carrier image sample and the secret image sample are input into the coding model to obtain the carrier image sample output by the coding model; The encrypted image sample is input into the decoding model to obtain the decrypted image sample output by the decoding model; The encoder and the decoder are trained based on the carrier image sample, the secret image sample, the carrier image sample, and the decrypted image sample.

6. The data protection method according to claim 5, characterized in that, The training of the encoder and the decoder based on the carrier image sample, the secret image sample, the secret-carrying image sample, and the decrypted image sample includes: A first loss function is determined based on the carrier image sample and the secret image sample, and a second loss function is determined based on the secret image sample and the decrypted image sample; The model parameters of the encoding model are optimized based on the first loss function until the convergence condition is met, thus obtaining the encoder; The model parameters of the decoding model are optimized based on the first loss function and the second loss function until the convergence condition is met, thus obtaining the decoder.

7. The data protection method according to claim 5, characterized in that, The step of inputting the encrypted image sample into the decoding model to obtain the decrypted image sample output by the decoding model includes: The encrypted image sample is subjected to a perturbation operation to obtain a perturbed encrypted image sample; The jammed encrypted image sample is input into the decoding model to obtain the decrypted image sample output by the decoding model; The interference operations include at least one of the following: smearing, cropping, compressing, zooming in, zooming out, Gaussian blurring, flipping, and rotating.

8. A data protection device, characterized in that, include: The acquisition unit is used to acquire target data and carrier images; The first determining unit is used to determine multiple QR code images based on the target data; each QR code image contains the specific content of the target data, and at least two QR code images of different colors are among the multiple QR code images; An arrangement unit is used to generate a canvas of a preset color with the same size as the carrier image; determine the target position for arranging each QR code image on the canvas based on the size of the canvas and the size of the QR code image; determine the main color of each target position in the carrier image; determine a target QR code image matching each main color based on the colors of multiple QR code images; and arrange each target QR code image at intervals at the corresponding target position to obtain a secret image. A hiding unit is used to hide the secret image in the carrier image to obtain a secret image; the size of the secret image is the same as the size of the carrier image.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the data protection method as described in any one of claims 1 to 7.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the data protection method as described in any one of claims 1 to 7.

11. A computer program product having executable instructions stored thereon, characterized in that, When executed by the processor, this instruction causes the processor to implement the data protection method as described in any one of claims 1 to 7.