Image encryption method, device, electronic device and readable storage medium
By adding anti-noise and auxiliary noise to the image and fusion processing, the target encrypted image is generated, and the problems of low security of image encryption and high computing storage burden in the prior art are solved, thereby achieving efficient encryption of the image.
Patent Information
- Application Number
- CN202110830378.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-22
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2041-07-22
AI Technical Summary
Existing image encryption methods are low in security when faced with malicious programs and artificial intelligence technologies, and setting different keys for each image will increase the system's computing and storage burden.
By determining the target area in the image for masking processing, and adding anti-noise and auxiliary noise to the original image, the noise image is generated and fused with the original image to generate the target encrypted image, thereby improving the encryption security and efficiency of the image.
It effectively resists attacks from image recognition algorithms and prevents information leakage. At the same time, there is no need to set different keys for different images, which reduces the system's computing and storage requirements and improves the security and efficiency of image encryption.
Smart Images

Figure CN113486377B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an image encryption method, device, electronic device and readable storage medium. Background Art
[0002] With the continuous development of mobile Internet terminal devices, more and more information exchange depends on the transmission of terminal devices. When the screen content of the user's terminal device is photographed by others, or the real-time display of the screen is obtained by malicious applications on the terminal, many private data of the user will be leaked through the screen image.
[0003] In the related technologies, for the encryption of terminal images, some use a single key to encrypt images, which has low security and is often easily cracked by artificial intelligence technology. Some methods enhance the security of images by setting a different key for each image, but this is labor-intensive and imposes a heavy burden on the system's calculation and storage. Summary of the invention
[0004] The embodiments of the present application provide an image encryption method, device, electronic device and readable storage medium, which can enable the encrypted screen image to resist malicious programs and prevent malicious programs from interpreting user information.
[0005] In a first aspect, an embodiment of the present application provides an image encryption method, comprising:
[0006] Determine a target area where the content to be encrypted is located in the original image to be encrypted;
[0007] Performing mask processing on the target area to determine mask information of the target area;
[0008] Add adversarial noise and auxiliary noise to the original image to generate a noisy image;
[0009] The original image, the noise image and the mask information are fused to generate the target encrypted image.
[0010] In a second aspect, an embodiment of the present application provides an image encryption device, comprising:
[0011] A determination module, used to determine a target area where the content to be encrypted is located in the original image to be encrypted;
[0012] A mask module is used to perform mask processing on the target area and determine the mask information of the target area;
[0013] A noise adding module is used to add adversarial noise and auxiliary noise to the original image to generate a noisy image;
[0014] The generation module is used to fuse the original image, the noise image and the mask information to generate the target encrypted image.
[0015] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, and a program or instruction stored in the memory and running on the processor, which, when executed by the processor, implements the steps of the image encryption method provided in the first aspect.
[0016] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the image encryption method provided in the first aspect are implemented.
[0017] In a fifth aspect, an embodiment of the present application provides a chip, the chip including a processor and a communication interface, the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the steps of the image encryption method provided in the first aspect.
[0018] In the embodiment of the present application, the target area where the content to be encrypted is located in the original image to be encrypted is determined; the target area is masked to determine the mask information of the target area; adversarial noise and auxiliary noise are added to the original image to generate a noise image; the original image, the noise image and the mask information are fused to generate a target encrypted image. Thus, the adversarial noise and auxiliary noise contained in the target encrypted image are used to interfere with the image information on which the image recognition algorithm relies, causing the image recognition to fail and realizing the encryption of the image. Furthermore, while ensuring the encryption effect, there is no need to set different keys for different images, which greatly reduces the requirements for system calculation and storage, and improves the security and efficiency of image encryption. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 One of the flowcharts of the image encryption method according to an embodiment of the present application is shown;
[0020] Figure 2 A second flowchart of an image encryption method according to an embodiment of the present application is shown;
[0021] Figure 3 A third flowchart of an image encryption method according to an embodiment of the present application is shown;
[0022] Figure 4 A fourth flowchart of an image encryption method according to an embodiment of the present application is shown;
[0023] Figure 5 A fifth flowchart of an image encryption method according to an embodiment of the present application is shown;
[0024] Figure 6 A sixth flowchart of an image encryption method according to an embodiment of the present application is shown;
[0025] Figure 7 FIG7 shows a flowchart of an image encryption method according to an embodiment of the present application;
[0026] Figure 8 A schematic diagram of display of an electronic device according to an embodiment of the present application is shown;
[0027] Fig. 9 A structural block diagram of an image encryption device according to an embodiment of the present application is shown;
[0028] Fig.10 A structural block diagram of an electronic device according to an embodiment of the present application is shown;
[0029] Fig.11 A hardware structure block diagram of an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0030] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0031] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0032] Refer to the following Figures 1 to 11 An image encryption method, an image encryption device, an electronic device, and a readable storage medium are described according to some embodiments of the present application.
[0033] In one embodiment of the present application, Figure 1 One of the flowcharts of the image encryption method of an embodiment of the present application is shown, including:
[0034] Step 102, determining a target area where the content to be encrypted is located in the original image to be encrypted;
[0035] In this embodiment, encryption refers to encrypting the original image, making it difficult for most artificial intelligence image recognition algorithms based on the ResNet structure to parse the content displayed by the image, image EXIF (Exchangeable Image File) information, etc.
[0036] The original image may be a screen image currently displayed on the electronic device, or an image opened when the album application receives a request to view the image, or a captured image captured in a photo or video according to a shooting operation triggered by the user, which is not limited in the embodiments of the present application. The content to be encrypted may contain user privacy and needs to be encrypted. The content to be encrypted includes: text, graphics, symbols, charts and other information.
[0037] Furthermore, in the case of multiple original images, the original images may be normalized before encryption to unify the image size, so as to facilitate batch encryption of multiple original images. For example, the original image is converted into an image of 256×256 size. Moreover, the image processing steps include not only screening and size normalization, but also brightness adjustment, clarity adjustment, contrast adjustment, grayscale adjustment, mirroring, sharpening and other image processing steps, so as to accurately determine the target area.
[0038] Step 104, performing mask processing on the target area to determine mask information of the target area;
[0039] In this embodiment, mask information of the target area is determined by masking the target area, and the position of the content to be encrypted in the original image is marked with the mask information, so that the content to be encrypted in the original image can be encrypted separately. Therefore, during the encryption process, it is not necessary to identify the specific information in the content to be encrypted, but only to determine the position of the target area of the content to be encrypted, so as to realize the encryption of the specified content.
[0040] The mask information is an integer matrix of the original image size, and the element values of the matrix include 0 or 1.
[0041] Step 106, adding adversarial noise and auxiliary noise to the original image to generate a noisy image;
[0042] Among them, adversarial noise refers to the addition of additive noise to the image that does not affect the visual appearance. Adversarial noise is an adversarial disturbance that can effectively reduce the classification ability of the machine learning model, so that most of the images with adversarial noise are misclassified, achieving the effect of disturbing the data points, thereby interfering with the image information that the image recognition algorithm relies on without affecting people's visual perception, and preventing the image from being recognized and crawled by the recognition algorithm. Auxiliary noise includes moiré noise and / or random noise. Moiré is a high-frequency interference that occurs in the photosensitive elements of devices such as digital cameras or scanners, which will cause colorful high-frequency stripes to appear in the image. Since moiré is irregular, there is no obvious shape regularity. Generally speaking, the moiré generated when taking a photo forms multiple rings in the form of concentric circles. Random noise is also called background noise. Random noise refers to unnecessary or redundant interference information present in image data, which is accumulated by a large number of fluctuations that are randomly generated in time. Random noise is noise that cannot be predicted at a given moment.
[0043] In this embodiment, the noise image includes an adversarial noise image and an auxiliary noise image, and the auxiliary noise image includes a moiré noise image and / or a random noise image. Since the adversarial noise has a small visual disturbance on the image, although it can resist the attack of the intelligent recognition algorithm, it cannot prevent information leakage caused by manual viewing. To this end, on the basis of adding adversarial noise, auxiliary noise is further added to the original image, and the auxiliary noise is used to add a "blocking" effect to the original image. The target encrypted image cannot fully display the content in the original image, which can not only prevent information leakage caused by visual recognition, but also further interfere with the denoising effect of the artificial intelligence algorithm and improve the encryption effect of the original image.
[0044] Step 108, fusing the original image, the noise image and the mask information to generate a target encrypted image.
[0045] In this embodiment, the noise image, the original image and the mask information are subjected to signal-noise fusion processing, so that the noise image is used as an encryption key to encrypt the content to be encrypted in the original image, so that the fused target encrypted image contains adversarial noise and auxiliary noise. Thus, the adversarial noise contained in the target encrypted image interferes with the image information on which the image recognition algorithm depends, and the auxiliary noise is used to add a "masking" effect to the content to be encrypted in the original image to enhance the interference with the image recognition algorithm, so that the image recognition fails, and the encryption of the image is achieved. In addition, while protecting the privacy of the user from being leaked, there is no need to set different keys for different images, which greatly reduces the requirements for the calculation and storage of the system and improves the security and efficiency of image encryption. At the same time, the position of the non-target area in the target encrypted image can also present a visual effect similar to the original image, retaining as much non-privacy information in the original image as possible, and taking into account the convenience of user access on the basis of preventing privacy leakage.
[0046] Furthermore, the target encrypted image can be directly output to an output device of an electronic device for transmission or display.
[0047] It can be understood that the fusion of the original image and the noise image is essentially the superposition operation of the image pixel matrix.
[0048] Specifically, the image encryption method is applicable to electronic devices, including but not limited to mobile terminals, tablet computers, computers, laptop computers, wearable devices, vehicle-mounted terminals, etc.
[0049] In one embodiment of the present application, the noise image includes an anti-noise image and an auxiliary noise image; Figure 2 As shown, step 108, fusing the original image, the noise image and the mask information to generate a target encrypted image, includes:
[0050] Step 202, performing a superposition operation on the original image and the anti-noise image to generate a first image;
[0051] Step 204, performing an element-wise product operation on the auxiliary noise image and the mask information to generate a second image;
[0052] The element-wise entrywise product, i.e. the product of corresponding elements in two matrices of the same dimension, is also called the Hadamard product. Specifically, the Hadamard product of two m×n matrices A and B is defined as: ij The corresponding element b of matrix B ij The product of a ij ×b ijThe formed m×n matrix C. Among them, i=1, 2, ..., m; j=1, 2, ..., n. Since the adversarial noise image and the auxiliary noise image are both obtained based on the original image, the adversarial noise image and the auxiliary noise image have the same size matrix with the dimension of the original image, and the adversarial noise image, the auxiliary noise image and the original image can perform element-by-element product operations.
[0053] Step 206: Perform a superposition operation on the first image and the second image according to the first preset weight to generate a target encrypted image.
[0054] Among them, the first preset weight is used to indicate the proportion of the first image and the second image during the superposition operation. The superposition operation of the first image and the second image is C=a×A+b×B, a and b are the first preset weights, C is the matrix of the target encrypted image, A is the matrix of the first image, and B is the matrix of the second image. a can be the same as b, a and b can also be different, and the first preset weight can be reasonably set according to the user's encryption requirements. For example, a is set to 0.5, that is, the matrix element value of the first image is multiplied by 0.5 before the superposition operation is performed. In the case where the auxiliary noise image includes a moiré noise image and a random noise image, that is, the second image includes two images, the two images are matrix added to the first image, and the first preset weight (a, b1, b2) of each image is set to 0.33, then the matrix pixel value of each image accounts for one third when the superposition operation is performed, that is, the matrix pixel value of the target encrypted image is the average of the matrix pixel values of the two images included in the second image and the first image.
[0055] In this embodiment, the original image and the anti-noise image are superimposed to obtain a first image with anti-noise disturbance added, and the auxiliary noise image and the mask information are element-wise multiplied to obtain a second image with auxiliary noise added to the target area. Finally, the first image and the second image are superimposed according to the first preset weight to generate a final target encrypted image with both anti-noise disturbance and auxiliary noise disturbance. This allows the final target encrypted image to prevent some malicious programs or others from using artificial intelligence algorithms to steal private information on user terminals, thereby increasing the cost of malicious sources obtaining private information.
[0056] It can be understood that when the auxiliary noise is moiré noise, that is, only the moiré noise is added to the target area, the target area of the obtained target encrypted image presents the "occlusion" effect constructed by the moiré noise. When the auxiliary noise is random noise, that is, only the random noise is added to the target area, the target area of the obtained target encrypted image presents the "occlusion" effect constructed by the random noise. When the auxiliary noise is moiré noise and random noise, that is, the target area has both moiré noise and random noise, the target area of the obtained target encrypted image can present the "occlusion" effect constructed by the superposition of random noise and moiré noise.
[0057] In one embodiment of the present application, when the auxiliary noise image includes a random noise image and a moiré noise image, Figure 3 The fourth flowchart of the image encryption method of the embodiment of the present application is shown, including:
[0058] Step 302, dividing the target area into a first area and a second area according to the priority of the content to be encrypted;
[0059] The priority is related to the privacy of the content to be encrypted. The information in the content to be encrypted can be determined by the recognition model, and then the corresponding priority can be determined by the information. Alternatively, the priority of the content to be encrypted can be specified by the user.
[0060] Step 304, performing mask processing on the first area and the second area respectively to determine a first mask for the first area and a second mask for the second area;
[0061] In this embodiment, considering the different privacy levels of the information contained in the content to be encrypted, some information will expose the user's personal information, such as ID card number, bank password, etc., which requires a stronger encryption effect; some information is less private, such as location maps, company names, etc. Although this type of information is related to the user, in some scenarios, even if it is leaked, it will not cause adverse effects on the user. Therefore, by dividing the target area into a first area and a second area according to the priority of the content to be encrypted, and marking the positions of the first area and the second area in the original image by a first mask and a second mask, respectively, in the image encryption process, by adding different "masking" effects to the encrypted content with different privacy levels, the visual effect and security of the target encrypted image are taken into account, thereby improving the user experience.
[0062] For example, the original image includes text, graphics and blanks, and the text and graphics are the content to be encrypted. The text content position in the original image is identified, the original image is segmented, the text area (first area) is determined, and masks (first mask and second mask) representing the text area position (first area) and the non-text area position (second area) are generated. For example, the matrix element value of the position where the text area is located is 1, and the position where the text area is not detected, and the element value of the matrix is all zero.
[0063] Step 306, performing an element-wise product operation on one of the random noise image and the moiré noise image and the first mask to generate a first sub-image;
[0064] Step 308, performing an element-wise product operation on the other of the random noise image and the moiré noise image and the second mask to generate a second sub-image;
[0065] Step 310: Perform a superposition operation on the first sub-image and the second sub-image according to the second preset weight to generate a second image.
[0066] The second preset weight is used to indicate the proportion of the first sub-image and the second sub-image during the superposition operation, thereby controlling the encryption strength of the random noise and moiré noise in the second image.
[0067] In this embodiment, an element-by-element product operation is performed on one of the random noise image and the moiré noise image and the first mask, so that the first area of the obtained first sub-image retains the random noise or moiré noise. Similarly, an element-by-element product operation is performed on the random noise image and the other of the moiré noise images and the second mask, so that the second area of the generated second sub-image retains the other of the random noise or moiré noise. According to the second preset weight, the first sub-image and the second sub-image are subjected to signal-noise fusion processing to obtain the second image. Thus, random noise and moiré noise are added to the first area and the second area of the second image respectively, so that the encrypted content with different privacy levels has different "masking" effects, which not only ensures the visual effect of the target encrypted image, but also, by encrypting the original image with a variety of different noises, it can effectively enhance the complexity of some malicious programs or others using artificial intelligence algorithms to crack the target encrypted image, increase the cost of malicious sources to obtain privacy information, and thus take into account both visual effects and security, and enhance the user experience.
[0068] For example, Figure 8As shown, the mask of the position where the text area (first area) is located is 1, and the mask of the position where no text area (second area) is detected is all zero. The random noise matrix and the text area mask are element-wise multiplied, so that the first sub-image only retains the random noise in the text area, and the non-text area is a matrix with all zero pixel values, that is, no random noise is added to the first sub-image. The moiré pattern is element-wise multiplied with the non-text area mask, and the non-text area of the first sub-image retains the moiré pattern, and the text area has no moiré pattern; if the entire image is text content, it is a matrix with all zero pixel values, and no moiré noise is added to the second sub-image.
[0069] In one embodiment of the present application, Figure 4 As shown, step 302, dividing the target area into a first area and a second area according to the priority of the content to be encrypted, includes:
[0070] Step 402, displaying a setting interface;
[0071] The setting interface includes all possible types of content that may appear in the image, such as text, graphics, symbols, charts, etc.
[0072] Step 404, receiving a first input to the setting interface;
[0073] The first input includes but is not limited to click input, key input, fingerprint input, sliding input, and pressing input. Key input includes but is not limited to single-click input, double-click input, long-press input, and combination key input of the power key, volume key, and main menu key of the electronic device. Of course, the first input can also be other operations of the user on the electronic device. The embodiment of the present application does not specifically limit the operation method, and it can be any feasible method.
[0074] Step 406, in response to the first input, setting the priority of the content to be encrypted;
[0075] In this embodiment, in the setting interface of the system setting, different priorities can be configured for the content to be encrypted through the first input, that is, the user can set the privacy level of different types of content that may exist in the image. Specifically, the priority of the content that may appear in the image is set through the first input. When it is necessary to encrypt the content to be encrypted in the image, it is only necessary to find the priority corresponding to the type of the content to be encrypted.
[0076] For example, the setting interface displays two possible content types: "text" and "graphics". The user clicks "text" and a setting window appears near "text". The user can enter "text" in the setting window. The priority of the preset content type is 3. In the process of encrypting the original image, when it is identified that the content to be encrypted is text, the priority of the content to be encrypted is determined to be 3.
[0077] Step 408, taking the area where the to-be-encrypted content whose priority is greater than the preset priority is located as the first area;
[0078] Step 410: The area in the target area other than the first area is used as the second area.
[0079] In this embodiment, the preset priority is used as the basis for classifying the target content, and the area where the content to be encrypted with a priority greater than the preset priority is located is taken as the first area, and the area other than the first area in the target area is taken as the second area, and the second area is the area where the content to be encrypted with a priority less than or equal to the preset priority is located. In this way, the target area is divided, and different "masking" effects are added to the content to be encrypted with different privacy levels, so as to take into account the visual effect and security of the target encrypted image and improve the user experience.
[0080] In one embodiment of the present application, Figure 5 As shown, step 106, adding adversarial noise to the original image to generate a noisy image, includes:
[0081] Step 502, obtaining a preset anti-noise template corresponding to the original image;
[0082] Among them, the preset adversarial noise template is generated based on a preset sample image and a universal adversarial perturbation (UAP) algorithm.
[0083] Step 504: perform a superposition operation on the original image and the preset anti-noise template to generate an anti-noise image.
[0084] In this embodiment, since the UAP algorithm uses an iterative method to solve the optimal perturbation, which takes a long time and requires a high system computing power, a classification algorithm model on a server or other electronic device is used in advance, such as a VGG model, a ResNet model, and a MobileNetV3 model. For the classification task of the preset sample image, multiple rounds of iterative calculations are performed to obtain a preset adversarial noise template that makes the classification algorithm misrecognition rate reach 85%. In the process of encrypting the original image, the preset adversarial noise template corresponding to the original image is directly used to add adversarial noise to the original image. This reduces the computing power requirements of the electronic device performing the encryption process, saves time for solving the optimal perturbation, and improves the efficiency of image encryption.
[0085] In one embodiment of the present application, Figure 6 As shown, the auxiliary noise includes moiré noise. Step 106, adding the auxiliary noise to the original image to generate a noisy image, includes:
[0086] Step 602, inputting the original image into a preset moiré model to generate a first moiré noise image;
[0087] Step 604, processing the moiré noise in the first moiré noise image according to a preset offset parameter to generate a second moiré noise image;
[0088] Step 606: Perform a superposition operation on the first moiré noise image and the second moiré noise image to generate a moiré noise image.
[0089] In this embodiment, the original image is input into a preset moiré model so as to add moiré noise to the original image through the preset moiré model, thereby obtaining a first moiré noise image, wherein the first moiré noise image has moiré noise related to the preset moiré model. Further, the moiré noise in the first moiré noise image is modified according to a preset offset parameter, thereby obtaining a second moiré noise image having a different moiré noise from the first moiré noise image. By superimposing the moiré noise in the first moiré noise image and the second moiré noise image, the finally generated moiré noise image presents moiré in various directions or sizes, which is conducive to enhancing the interference of the moiré noise on the target content and improving the encryption effect of the original image, thereby effectively enhancing the interference with some malicious programs or others using artificial intelligence algorithms, thereby protecting the privacy of users from being leaked.
[0090] The preset offset parameter can be reasonably set according to the encryption strength of the moiré noise set by the user, and the preset offset parameter includes an offset direction and an offset amount. It can be understood that when the offset amount is 0, that is, no offset processing is performed on the moiré noise, the second moiré noise image is the same as the first moiré noise image.
[0091] For example, the artificial intelligence algorithm UNet and the pictures with moiré obtained by taking photos are used as training data to train a set of preset moiré models that can generate moiré noise on images. After the original image is input into the preset moiré model, the preset moiré model outputs a first moiré noise image with a single moiré noise. Based on the first moiré noise image, the moiré noise is rotated 180° clockwise (preset offset parameter) to form a new second moiré noise image. The second moiré noise image is superimposed on the first moiré noise image output by the model to obtain a moiré noise image with two moiré circles, that is, a two-way moiré noise image. Of course, the moiré noise can also be rotated 90° clockwise twice based on the first moiré noise image to obtain two second moiré noise images rotated 90° and 180°. When the two second moiré noise images are superimposed on the first moiré noise image, a three-way moiré noise image is formed.
[0092] In one embodiment of the present application, Figure 7 As shown, the auxiliary noise includes random noise. Step 106, adding the auxiliary noise to the original image to generate a noisy image, includes:
[0093] Step 702, performing frequency domain transformation operation on the original image to determine the frequency domain information of the original image;
[0094] Among them, frequency domain transformation operations include Fourier transform, discrete cosine transform, wavelet transform, etc.
[0095] Step 704, obtaining random noise corresponding to the frequency domain information;
[0096] Step 706, updating frequency domain information according to random noise;
[0097] Step 708, performing an inverse conversion operation on the original image after the frequency domain information is updated to generate a random noise image.
[0098] In this embodiment, the original image is transformed into the frequency domain (wavelet domain) using a frequency domain transformation operation, and the frequency domain information of the original image is determined. Random noise matching the frequency domain information is randomly generated, and the frequency domain information is updated according to the random noise to add random noise to the original image in the frequency domain. The original image after the frequency domain information is updated is subjected to an inverse transformation operation, and the image is converted into the spatial domain (the spatial domain of the image) by inverse transformation to obtain a random noise image with random noise. Compared with the method of adding random noise based on the image spatial domain, the method of adding random noise through the frequency domain is more concealed and more resistant to attacks, and can effectively strengthen the interference with some malicious programs or others using artificial intelligence algorithms, and protect the privacy of users from being leaked.
[0099] In one embodiment of the present application, Fig. 9 As shown, the image encryption device 900 includes: a determination module 902, which is used to determine the target area where the content to be encrypted is located in the original image to be encrypted; a mask module 904, which is used to perform mask processing on the target area and determine the mask information of the target area; a noise adding module 906, which is used to add adversarial noise and auxiliary noise to the original image to generate a noise image; and a generation module 908, which is used to fuse the original image, the noise image and the mask information to generate a target encrypted image.
[0100] In this embodiment, the adversarial noise and auxiliary noise contained in the target encrypted image can be used to interfere with the image information relied on by the image recognition algorithm, causing image recognition to fail, thereby achieving encryption of the image. Furthermore, while ensuring the encryption effect, there is no need to set different keys for different images, which greatly reduces the computing and storage requirements of the system and improves the security and efficiency of image encryption.
[0101] Optionally, the noise image includes an adversarial noise image and an auxiliary noise image; the generation module 908 is also used to perform a superposition operation on the original image and the adversarial noise image to generate a first image; perform an element-wise multiplication operation on the auxiliary noise image and the mask information to generate a second image; and perform a superposition operation on the first image and the second image according to a first preset weight to generate a target encrypted image.
[0102] Optionally, in the case where the auxiliary noise image includes a random noise image and a moiré noise image, the image encryption device 900 also includes: a segmentation module (not shown in the figure), the segmentation module is used to divide the target area into a first area and a second area according to the priority of the content to be encrypted; the mask module 904 is also used to perform mask processing on the first area and the second area respectively, and determine a first mask for the first area and a second mask for the second area; the generation module 908 is also used to perform element-wise multiplication operation on one of the random noise image and the moiré noise image, and the first mask to generate a first sub-image; perform element-wise multiplication operation on the other of the random noise image and the moiré noise image, and the second mask to generate a second sub-image; and perform superposition operation on the first sub-image and the second sub-image according to a second preset weight to generate a second image.
[0103] Optionally, the image encryption device 900 also includes: a display module (not shown in the figure), which is used to display a setting interface; a receiving module (not shown in the figure), which is used to receive a first input to the setting interface; a setting module (not shown in the figure), which is used to set the priority of the content to be encrypted in response to the first input; a segmentation module, which is also used to use the area where the content to be encrypted whose priority is greater than a preset priority is located as the first area; and the area in the target area other than the first area as the second area.
[0104] Optionally, the image encryption device 900 also includes: a first acquisition module (not shown in the figure), the first acquisition module is used to obtain a preset adversarial noise template corresponding to the original image, the preset adversarial noise template is generated based on a preset sample image and a general adversarial perturbation algorithm; the noise adding module 906 is also used to perform a superposition operation on the original image and the preset adversarial noise template to generate an adversarial noise image.
[0105] Optionally, the noise adding module 906 is also used to input the original image into a preset moiré model to generate a first moiré noise image; process the moiré noise in the first moiré noise image according to preset offset parameters to generate a second moiré noise image; and perform a superposition operation on the first moiré noise image and the second moiré noise image to generate a moiré noise image.
[0106] Optionally, the noise adding module 906 is also used to perform a frequency domain transform operation on the original image to determine the frequency domain information of the original image; the image encryption device 900 also includes: a second acquisition module (not shown in the figure), the second acquisition module is used to obtain the random noise corresponding to the frequency domain information; the noise adding module 906 is also used to update the frequency domain information according to the random noise; perform an inverse conversion operation on the original image after the frequency domain information is updated to generate a random noise image.
[0107] In this embodiment, each module of the image encryption device 900 implements the steps of the image encryption method in any embodiment of the first aspect when performing its respective functions. Therefore, the image encryption device 900 also includes all the beneficial effects of the image encryption method in any embodiment of the first aspect, which will not be repeated here.
[0108] The image encryption device in the embodiment of the present application is a device, and it can also be a component, integrated circuit, or chip in a terminal. The device can be a mobile electronic device or a non-mobile electronic device. Exemplarily, the mobile electronic device is a mobile phone, a tablet computer, a laptop computer, a handheld computer, a vehicle-mounted electronic device, a smart camera device, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and the non-mobile electronic device is a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV) or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.
[0109] The application management device in the embodiment of the present application is a device having an operating system. The operating system is an Android operating system, an iOS operating system, or other operating systems, which are not specifically limited in the embodiment of the present application.
[0110] In one embodiment of the present application, Fig.10 As shown, an electronic device 1000 is provided, including: a processor 1004, a memory 1002, and a program or instruction stored in the memory 1002 and running on the processor 1004. When the program or instruction is executed by the processor 1004, the steps of the image encryption method provided in any of the above embodiments are implemented. Therefore, the electronic device 1000 includes all the beneficial effects of the image encryption method provided in any of the above embodiments, which will not be repeated here.
[0111] It should be noted that the electronic devices in the embodiments of the present application include the above-mentioned mobile electronic devices and non-mobile electronic devices.
[0112] Fig.11 The hardware structure diagram of an electronic device 1100 for implementing an embodiment of the present application is shown in the following figure. The electronic device 1100 includes, but is not limited to, a radio frequency unit 1101, a network module 1102, an audio output unit 1103, an input unit 1104, a sensor 1105, a display unit 1106, a user input unit 1107, an interface unit 1108, a memory 1109, and a processor 1110.
[0113] Those skilled in the art will appreciate that the electronic device 1100 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 1110 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Fig.11 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0114] Among them, the processor 1110 is used to determine the target area where the content to be encrypted is located in the original image to be encrypted; perform mask processing on the target area to determine the mask information of the target area; add adversarial noise and auxiliary noise to the original image to generate a noise image; and perform fusion processing on the original image, the noise image and the mask information to generate a target encrypted image.
[0115] In this embodiment, the adversarial noise and auxiliary noise contained in the target encrypted image can be used to interfere with the image information relied on by the image recognition algorithm, causing image recognition to fail, thereby achieving encryption of the image. Furthermore, while ensuring the encryption effect, there is no need to set different keys for different images, which greatly reduces the computing and storage requirements of the system and improves the security and efficiency of image encryption.
[0116] Furthermore, the noise image includes an adversarial noise image and an auxiliary noise image; the processor 1110 is also used to perform a superposition operation on the original image and the adversarial noise image to generate a first image; perform an element-wise product operation on the auxiliary noise image and the mask information to generate a second image; and perform a superposition operation on the first image and the second image according to a first preset weight to generate a target encrypted image.
[0117] Furthermore, in the case where the auxiliary noise image includes a random noise image and a moiré noise image, the processor 1110 is also used to divide the target area into a first area and a second area according to the priority of the content to be encrypted; perform mask processing on the first area and the second area respectively to determine a first mask for the first area and a second mask for the second area; perform element-wise multiplication operation on one of the random noise image and the moiré noise image, and the first mask to generate a first sub-image; perform element-wise multiplication operation on the other of the random noise image and the moiré noise image, and the second mask to generate a second sub-image; and perform a superposition operation on the first sub-image and the second sub-image according to a second preset weight to generate a second image.
[0118] Furthermore, the display unit 1106 is used to display a setting interface; the user input unit 1107 is used to receive a first input to the setting interface; the processor 1110 is also used to set the priority of the content to be encrypted in response to the first input; the area where the content to be encrypted is located and the priority of the content to be encrypted is greater than the preset priority is used as the first area; and the area in the target area other than the first area is used as the second area.
[0119] Furthermore, the processor 1110 is also used to obtain a preset adversarial noise template corresponding to the original image, where the preset adversarial noise template is generated based on a preset sample image and a general adversarial perturbation algorithm; and perform a superposition operation on the original image and the preset adversarial noise template to generate an adversarial noise image.
[0120] Furthermore, the processor 1110 is also used to input the original image into a preset moiré model to generate a first moiré noise image; process the moiré noise in the first moiré noise image according to preset offset parameters to generate a second moiré noise image; and perform a superposition operation on the first moiré noise image and the second moiré noise image to generate a moiré noise image.
[0121] Furthermore, the processor 1110 is also used to perform a frequency domain transform operation on the original image to determine the frequency domain information of the original image; obtain the random noise corresponding to the frequency domain information; update the frequency domain information according to the random noise; and perform an inverse conversion operation on the original image after the frequency domain information is updated to generate a random noise image.
[0122] It should be understood that in the embodiment of the present application, the input unit 1104 may include a graphics processor (Graphics Processing Unit, GPU) 1141 and a microphone 1142, and the graphics processor 1141 processes the image data of the static picture or video obtained by the image capture device (such as a camera) in the video capture mode or the image capture mode. The display unit 1106 may include a display panel 1161, and the display panel 1161 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1107 includes a touch panel 1171 and other input devices 1172. The touch panel 1171 is also called a touch screen. The touch panel 1171 may include two parts: a touch detection device and a touch controller. Other input devices 1172 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which will not be repeated here. The memory 1109 can be used to store software programs and various data, including but not limited to applications and operating systems. The processor 1110 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 1110.
[0123] In one embodiment of the present application, a readable storage medium is provided, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the image encryption method provided in any of the above embodiments are implemented.
[0124] In this embodiment, reading the storage medium can implement each process of the image encryption method provided in the embodiment of the present application and can achieve the same technical effect. To avoid repetition, it will not be described here.
[0125] The processor is the processor in the communication device in the above embodiment. The read storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0126] An embodiment of the present application also provides a chip, which includes a processor and a communication interface. The communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned image encryption method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0127] It should be understood that the chip mentioned in the embodiments of the present application may also be referred to as a system-level chip, a system chip, a chip system, or a system-on-chip chip, etc.
[0128] It should be noted that, in this article, the term "comprises", "includes" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the method and device in the embodiment of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0129] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
[0130] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. An image encryption method, characterized in that: include: Determine a target area where the content to be encrypted is located in the original image to be encrypted; Performing mask processing on the target area to determine mask information of the target area, and using the mask information to mark the position of the content to be encrypted in the original image, so as to separately encrypt the content to be encrypted in the original image; Adding adversarial noise and auxiliary noise to the original image to generate a noisy image; Performing fusion processing on the original image, the noise image and the mask information to generate a target encrypted image; The noise image includes an anti-noise image and an auxiliary noise image; The fusing process of the original image, the noise image and the mask information to generate the target encrypted image includes: Performing a superposition operation on the original image and the anti-noise image to generate a first image; Performing an element-wise product operation on the auxiliary noise image and the mask information to generate a second image; According to a first preset weight, a superposition operation is performed on the first image and the second image to generate the target encrypted image.
2. The image encryption method according to claim 1, characterized in that: The performing mask processing on the target area to determine mask information of the target area includes: Dividing the target area into a first area and a second area according to the priority of the content to be encrypted; Performing mask processing on the first area and the second area respectively to determine a first mask of the first area and a second mask of the second area; The auxiliary noise image includes a random noise image and a moiré noise image; performing an element-wise product operation on the auxiliary noise image and the mask information to generate a second image includes: Performing an element-wise product operation on one of the random noise image and the moiré noise image and the first mask to generate a first sub-image; performing an element-wise product operation on the other of the random noise image and the moiré noise image and the second mask to generate a second sub-image; According to a second preset weight, a superposition operation is performed on the first sub-image and the second sub-image to generate the second image.
3. The image encryption method according to claim 1 or 2, characterized in that: The adding of adversarial noise to the original image to generate a noisy image comprises: Acquire a preset adversarial noise template corresponding to the original image, where the preset adversarial noise template is generated based on a preset sample image and a general adversarial perturbation algorithm; The original image and the preset anti-noise template are superimposed to generate an anti-noise image.
4. The image encryption method according to claim 1 or 2, characterized in that: The auxiliary noise includes moiré noise, and the adding of the auxiliary noise to the original image to generate a noise image includes: Inputting the original image into a preset moiré model to generate a first moiré noise image; Processing the moiré noise in the first moiré noise image according to a preset offset parameter to generate a second moiré noise image; A superposition operation is performed on the first moiré noise image and the second moiré noise image to generate a moiré noise image.
5. The image encryption method according to claim 1 or 2, characterized in that: The auxiliary noise includes random noise, and the adding of the auxiliary noise to the original image to generate a noise image includes: Performing a frequency domain transformation operation on the original image to determine the frequency domain information of the original image; Obtaining random noise corresponding to the frequency domain information; Updating the frequency domain information according to the random noise; An inverse conversion operation is performed on the original image after the frequency domain information is updated to generate a random noise image.
6. An image encryption device, characterized in that: include: A determination module, used to determine a target area where the content to be encrypted is located in the original image to be encrypted; A mask module, used to perform mask processing on the target area, determine mask information of the target area, and use the mask information to mark the position of the content to be encrypted in the original image, so as to separately encrypt the content to be encrypted in the original image; A noise adding module, used for adding adversarial noise and auxiliary noise to the original image to generate a noisy image; A generating module, used for fusing the original image, the noise image and the mask information to generate a target encrypted image; The noise image includes an anti-noise image and an auxiliary noise image; The generating module is further used to perform a superposition operation on the original image and the anti-noise image to generate a first image; Performing an element-wise product operation on the auxiliary noise image and the mask information to generate a second image; According to a first preset weight, a superposition operation is performed on the first image and the second image to generate the target encrypted image.
7. The image encryption device according to claim 6, characterized in that: The auxiliary noise image includes a random noise image and a moiré noise image, and the image encryption device further includes: A segmentation module, configured to divide the target area into a first area and a second area according to the priority of the content to be encrypted; The mask module is further used to perform mask processing on the first area and the second area respectively to determine a first mask of the first area and a second mask of the second area; The generating module is further configured to perform an element-wise product operation on one of the random noise image and the moiré noise image and the first mask to generate a first sub-image; performing an element-wise product operation on the other of the random noise image and the moiré noise image and the second mask to generate a second sub-image; According to a second preset weight, a superposition operation is performed on the first sub-image and the second sub-image to generate the second image.
8. The image encryption device according to claim 6 or 7, characterized in that: Also includes: A first acquisition module, used to acquire a preset adversarial noise template corresponding to the original image, wherein the preset adversarial noise template is generated based on a preset sample image and a general adversarial perturbation algorithm; The noise adding module is further used to perform a superposition operation on the original image and the preset anti-noise template to generate an anti-noise image.
9. The image encryption device according to claim 6 or 7, characterized in that: The noise adding module is further used to input the original image into a preset moiré model to generate a first moiré noise image; Processing the moiré noise in the first moiré noise image according to a preset offset parameter to generate a second moiré noise image; A superposition operation is performed on the first moiré noise image and the second moiré noise image to generate a moiré noise image.
10. The image encryption device according to claim 6 or 7, characterized in that: The noise adding module is further used to perform frequency domain transformation operation on the original image to determine the frequency domain information of the original image; The image encryption device also includes: A second acquisition module is used to acquire random noise corresponding to the frequency domain information; The noise adding module is further used to update the frequency domain information according to the random noise; An inverse conversion operation is performed on the original image after the frequency domain information is updated to generate a random noise image.
11. An electronic device, characterized in that: The method comprises a processor, a memory and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the image encryption method as described in any one of claims 1 to 5.
12. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by a processor, the steps of the image encryption method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Security improvement method based on generative adversarial samples in big data privacy protection
CN111768325A
Image encryption method and device, image decryption method and device, equipment and readable storage medium
CN112040086A