Image encryption method based on neural network multi-feature map
The multi-feature image encryption method through neural networks solves the problems of low efficiency and insufficient security of traditional technology, and achieves an efficient and secure image encryption and decryption process, which is suitable for modern data security needs.
Patent Information
- Application Number
- CN202411244305.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-10-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional image encryption technology is inefficient and insecure when faced with massive data and complex algorithms, making it difficult to meet the needs of modern society for data security.
Using a multi-feature image encryption method based on neural networks, the original image is down-sampled 4 times through the encoding network to generate 4 feature images, which are saved in matrix form. During decryption, up-sampling and addition are performed through the decoding network, and gradually restored Original image.
It improves the efficiency and security of image encryption, optimizes image storage space, and meets the image data security needs in the era of artificial intelligence and big data.
Smart Images

Figure CN118764570A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image information security technology, and in particular to an image encryption method based on a neural network multi-feature graph. Background Art
[0002] In today's era, with the rapid development of artificial intelligence technology and the widespread application of big data technology, image data has become an important carrier of information transmission and communication. Whether in the fields of social media, e-commerce or intelligent monitoring, the use of image data has shown explosive growth. However, this surge in data volume has also brought about a series of security issues, especially the confidentiality and privacy of image data. Traditional image encryption technology often has problems such as low efficiency and insufficient security when facing the challenges of massive data and complex algorithms, and it is difficult to meet the needs of modern society for data security. Summary of the invention
[0003] In order to solve the above-mentioned problems in the prior art, the present invention provides an image encryption method based on a neural network multi-feature graph.
[0004] An image encryption method based on a neural network multi-feature map comprises the following steps: Encryption: fill or crop the original image to the threshold size, downsample each modified image 4 times through the encoding network to obtain 4 feature images, save the generated 4 feature images in the form of a matrix, and obtain the encrypted file; Decryption: Read the encrypted file through the Python library, pass the feature image into the decoding network input port, upsample the feature image, add it to the previous scale feature image on the channel, output the final image, and splice or cut the output image to get the original image.
[0005] Furthermore, the encryption specifically includes: Step 101: The size of the original image X is adjusted by filling and cutting to obtain one or more images with the same size as the threshold, and the size of the original image is recorded; Step 102: All the images obtained in step 101 are passed into the encoding network, and each image is downsampled 4 times to obtain the feature images X at 4 different levels of the image. 1,0 , X 2,0 , X 3,0 and X 4,0 ; Step 103: Save all the obtained feature images as encrypted files.
[0006] Furthermore, the decryption specifically includes: Step 201: Read the encrypted file through the Python library, pass the feature images in the file to the decoding network input port, and decode the feature images X 4,0 After upsampling and feature image X 3,0 Add to get image X 3,1 ; Step 202: For feature image X 3,0 After upsampling and feature image X 2,0 Add together to get X 2,1 , for image X 3,1 After upsampling, it is then compared with image X 2,1 and feature image X 2,0 Add to get image X 2,2 ; Step 203: For feature image X 2,0 After upsampling and feature image X 1,0 Add to get image X 1,1 , for image X 2,1 After upsampling, it is then combined with image X 1,1 and feature image X 1,0 Add to get image X 1.2 ; for image X 2,2 After upsampling, it is then compared with image X 1,2 、ImageX 1,1 And the feature image X 1,0 Add to get image X 1,3 ; Step 204: For feature image X 1,0 After upsampling, add the original image X to get image X 0,1 , for image X 1.1 After upsampling, it is then combined with image X 0,1 Add to the original image X to get image X 0,2 , for image X 1.2 After upsampling, it is then combined with image X 0.2 、ImageX 0,1 And the original image X is added to get image X 0,3 , for image X 1.3 After upsampling, it is then combined with image X 0.3 、ImageX 0.2 、ImageX 0,1 And the original image X is added to get image X 0,4 ; Output image X 0,4 .
[0007] Furthermore, the filling and cutting method of step 101 is specifically as follows: Step 101: Determine whether the size of the original image X meets the threshold; Step 102: If the length or width of the original image X is greater than the threshold, the original image X is padded according to a multiple of the threshold, and then segmented according to the threshold value to obtain a plurality of segmented images; Step 103: If both the length and the width of the original image X are smaller than the threshold, the original image X is padded to the threshold size to obtain a padded image.
[0008] Furthermore, the image scale of the input encoding network is (3, H, W), and the obtained feature image X 1,0 is (64, H / 2, W / 2), feature image X 2,0 is (128, H / 2, W / 2), feature image X 3,0 is (256, H / 4, W / 4) and feature image X 4,0 It is (512, H / 8, W / 8), where the first digit of the scale represents the number of channels, H represents the height of the image, and W represents the width of the image.
[0009] Furthermore, the downsampling reduces the spatial dimension of the feature map and increases the number of channel dimensions through a layer of convolution + RELU activation layer + maximum pooling layer.
[0010] Furthermore, downsampling is performed by converting the decryption process output image X 0,1 、ImageX 0,2 、ImageX 0,3 and image X 0,4 , and the original image X is used for loss, and the weight of the network model is obtained through multiple rounds of training.
[0011] Furthermore, the loss formula is:
[0012] in, is the total loss, L1 is the image X 0,1 The loss of L2 is the image X 0,2 The loss of L3 is the image X 0,3 The loss of L4 is the image X 0,4 The loss, λ1, λ2, λ3, λ4 are the weights corresponding to each loss.
[0013] Furthermore, the upsampling is: , in, is the upsampled feature map The pixel value at the position (x, y) with a depth of d; is the pixel value at position (i, j) in the original feature map F with a depth of d; It is the corresponding element in the upsampling kernel. The upsampling kernel defines how to map the pixel values of the original feature map to the pixel values of the upsampled feature map. H is the image height and W is the image width.
[0014] Beneficial effects of the invention: The invention provides a new type of image encryption technology to cope with the image data security challenges in the era of artificial intelligence and big data. The invention combines advanced artificial intelligence algorithms and optimizes the encryption process through coding and decoding structures, deep learning and other methods, aiming to improve the efficiency and security of image encryption while increasing image storage space. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] Figure 1 is a flow chart of the method of the present invention; Figure 2 This is a schematic diagram of filling and cutting; Figure 3 Schematic diagram of obtaining characteristic images during encryption and decryption process. DETAILED DESCRIPTION
[0016] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0017] Example 1: Reference Figure 1 , an image encryption method based on a neural network multi-feature map, comprising the following steps: 1. Encryption: fill or crop the original image to the threshold size, downsample each modified image 4 times through the encoding network to obtain 4 feature images, save the generated 4 feature images in the form of a matrix, and obtain the encrypted file; the details are as follows: Step 101: The original image X is resized by filling and cutting to obtain one or more images that meet the threshold size, and the images are marked; The filling and cutting method is specifically as follows: determine whether the size of the original image X meets the threshold; if the length or width of the original image X is greater than the threshold, fill the original image X according to a multiple of the threshold, and then divide it according to the threshold size to obtain multiple divided images; if the length and width of the original image X are both smaller than the threshold, fill the original image X to the threshold size to obtain a filled image.
[0018] For example, the threshold is set to 960 in length and 640 in width. If the original image is 1280X960 and larger than the threshold, the image is padded to 1920X1280 (the padded pixel value is 128) and then cut into 4 pieces. Figure 2 As shown. At the same time, remember the original image size for later calculation of how much is filled. If the length and width of the original image are less than the threshold, fill the original image to the threshold size.
[0019] Step 102: All the images obtained in step 101 are passed into the encoding network, and each image is downsampled 4 times to obtain the feature images X at 4 different levels of the image. 1,0 , X 2,0 , X 3,0 and X 4,0 ; The image scale passed into the encoding network is (3, H, W), and the feature image obtained is X 1,0 is (64, H / 2, W / 2), feature image X 2,0 is (128, H / 2, W / 2), feature image X 3,0 is (256, H / 4, W / 4) and feature image X 4,0 It is (512, H / 8, W / 8), where the first digit of the scale represents the number of channels, H represents the height of the image, and W represents the width of the image.
[0020] Among them, downsampling reduces the spatial dimension of the feature map and increases the number of channel dimensions through a layer of convolution + RELU activation layer + maximum pooling layer.
[0021] Convolutional layer, using depthwise separable convolution (in two steps, depthwise convolution and pointwise convolution) Depthwise Convolution: formula:
[0022] Among them, I C is the cth channel in image I, is the convolution kernel associated with channel c. For example, a 3×3 convolution layer is used to reduce the image size by half.
[0023] Point-wise convolution: formula:
[0024] Among them, i is the i-th channel of the output feature map, ∗ represents element-wise multiplication, is the weight of the cth input channel corresponding to output channel i.
[0025] advantage: 1. Reduce the number of parameters 2. Reduced computational effort 3. Maintain nonlinear expression capabilities Activation layer (Prelu):
[0026] Where x is the input feature. max() and min() represent the maximum and minimum functions, respectively. a is a learnable parameter, which is usually initialized to a small positive number (such as 0.01 or 0.1) at the beginning of training, so that PReLU has a non-zero gradient even when x<0, thus avoiding the problem of "dead" units.
[0027] Pooling layer (max pooling layer):
[0028] Where m and n are the indices in the output feature map P. a and b are the indices when the pooling window slides. S is the step size of the pooling window. K is the size of the pooling window. H and W are the height and width of the input feature map F, respectively. max() means taking the maximum value within a given window.
[0029] Step 103: Save all the obtained feature images, which are the key information for restoring the image; 2. Decryption: Read the encrypted file through the Python library, pass the feature image into the decoding network input port, upsample the feature image, add it to the previous scale feature image on the channel, output the final image, and splice or cut the output image to get the original image; Figure 3 As shown in the figure, the down arrow indicates downsampling, and the up arrow indicates upsampling. When upsampling to obtain a feature image, it is necessary to upsample the feature image of the next layer and add all the feature images before the right arrow. The details are as follows: The feature images read from the file are passed into the decoding network input port respectively, and the feature images X 4,0 After upsampling and feature image X 3,0 Add to get image X 3,1 ; For the feature image X 3,0 After upsampling and feature image X 2,0 Add together to get X 2,1 , for image X 3,1 After upsampling, it is then compared with image X 2,1 and feature image X 2,0 Add to get image X 2,2 ; For the feature image X 2,0 After upsampling and feature image X 1,0 Add to get image X 1,1 , for image X 2,1 After upsampling, it is then combined with image X 1,1 and feature image X 1,0 Add to get image X 1.2 ; for image X 2,2 After upsampling, it is then compared with image X1,2 、ImageX 1,1 And the feature image X 1,0 Add to get image X 1,3 ; For the feature image X 1,0 After upsampling, add the original image X to get image X 0,1 , for image X 1.1 After upsampling, it is then combined with image X 0,1 Add to the original image X to get image X 0,2 , for image X 1.2 After upsampling, it is then combined with image X 0.2 、ImageX 0,1 And the original image X is added to get image X 0,3 , for image X 1.3 After upsampling, it is then combined with image X 0.3 、ImageX 0.2 、ImageX 0,1 And the original image X is added to get image X 0,4 ; Output image X 0,4 The above addition is pixel addition.
[0030] Downsampling is done by taking the image X output by the decryption process 0,1 、ImageX 0,2 、ImageX 0,3 and image X 0,4 , and the original image X is used for loss, and the weight of the network model is obtained through multiple rounds of training.
[0031] The loss formula is: , in, is the total loss, L1 is the image X 0,1 The loss of L2 is the image X 0,2 The loss of L3 is the image X 0,3 The loss of L4 is the image X 0,4 The loss, λ1, λ2, λ3, λ4 are the weights corresponding to each loss.
[0032] The upsampling is: , in, is the upsampled feature map The pixel value at the position (x, y) with a depth of d; is the pixel value at position (i, j) in the original feature map F with a depth of d; It is the corresponding element in the upsampling kernel. The upsampling kernel defines how to map the pixel values of the original feature map to the pixel values of the upsampled feature map. H is the image height and W is the image width.
[0033] In this embodiment, the four generated feature images are saved in the form of a matrix and saved together with the padded and segmented images in JSON. The size of the original image is recorded at the same time. The JSON file is read through the Python library, and the decrypted output images are spliced or cut to obtain the original image. For example, the generated four feature maps at different levels are saved in the form of a matrix, and the filled images are also recorded and saved in JSON.
[0034] The format is as follows: a 1280x960 original image and a json file.
[0035] Assume that the original image is cut into 4 images, and the original image is filled {1:{feature_img:[...]} ,2:{feature_img:[...]} ,3:{feature_img:[...]} ,4:{feature_img:[...]} ,original_image_size:[1280,960]} Among them, feature_img records the feature map of the recognition image in a list format. There are 4 levels of feature maps in the list. Each feature map is saved in the form of a numpy matrix. original_image_size represents the original image size.
[0036] To decode, you need the JSON file and the model weights of the network decoding part. So even if the JSON file is stolen, you can't use the data without the weights and model architecture.
[0037] Use Python to read the JSON file, extract the feature_img of each picture, and put these feature maps into the decoding network part in turn, that is, Figure 1 X in 1,0 , X 2,0 , X 3,0 , X 4,0 , then take the output X 0,4 , this is the original picture.
[0038] Get the original image of each cut image in the above way, stitch all the cut images into the original image, and then cut it to get the original image according to the original_image_size saved in JSON.
[0039] In the description of the embodiments of the present invention, the terms "first", "second", "third", and "fourth" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first", "second", "third", and "fourth" may explicitly or implicitly include one or more of the features. In the description of the present invention, unless otherwise specified, "multiple" means two or more.
[0040] In the description of the embodiments of the present invention, specific features, structures, materials or characteristics may be combined in a suitable manner in any one or more embodiments or examples.
[0041] In the description of the embodiments of the present invention, it should be understood that "-" and "~" represent the range between two values, and the range includes the endpoints. For example: "AB" represents a range greater than or equal to A and less than or equal to B. "A~B" represents a range greater than or equal to A and less than or equal to B.
[0042] In the description of the embodiments of the present invention, the term "and / or" herein is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " herein generally indicates that the associated objects before and after are in an "or" relationship.
[0043] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. An image encryption method based on neural network multi-feature graph, characterized in that: The following steps are involved: Encryption: fill or crop the original image to the threshold size, downsample each modified image 4 times through the encoding network to obtain 4 feature images, save the generated 4 feature images in the form of a matrix, and obtain the encrypted file; Decryption: Read the encrypted file through the Python library, pass the feature image into the decoding network input port, upsample the feature image, add it to the previous scale feature image on the channel, output the final image, and splice or cut the output image to get the original image.
2. The image encryption method based on neural network multi-feature graph according to claim 1 is characterized in that: The encryption specifically includes: Step 101: The size of the original image X is adjusted by filling and cutting to obtain one or more images with the same size as the threshold, and the size of the original image is recorded; Step 102: All the images obtained in step 101 are passed into the encoding network, and each image is downsampled 4 times to obtain the feature images X at 4 different levels of the image. 1,0 , X 2,0 , X 3,0 and X 4,0 ; Step 103: Save all the obtained feature images as encrypted files.
3. The image encryption method based on neural network multi-feature graph according to claim 2 is characterized in that: The decryption specifically includes: Step 201: Read the encrypted file through the Python library, pass the feature images in the file to the decoding network input port, and decode the feature images X 4,0 After upsampling and feature image X 3,0 Add to get image X 3,1 ; Step 202: For feature image X 3,0 After upsampling and feature image X 2,0 Add together to get X 2,1 , for image X 3,1 After upsampling, it is then compared with image X 2,1 and feature image X 2,0 Add to get image X 2,2 ; Step 203: For feature image X 2,0 After upsampling and feature image X 1,0 Add to get image X 1,1 , for image X 2,1 After upsampling, it is then combined with image X 1,1 and feature image X 1,0 Add together to get image X 1.2 ; For image X 2,2 After upsampling, it is then compared with image X 1,2 、ImageX 1,1 And the feature image X 1,0 Add to get image X 1,3 ; Step 204: For feature image X 1,0 After upsampling, add the original image X to get image X 0,1 , for image X 1.1 After upsampling, it is then combined with image X 0,1 Add to the original image X to get image X 0,2 , for image X 1.2 After upsampling, it is then combined with image X 0.2 、ImageX 0,1 And the original image X is added to get image X 0,3 , for image X 1.3 After upsampling, it is then combined with image X 0.3 、ImageX 0.2 、ImageX 0,1 And the original image X is added to get image X 0,4 ; Output image X 0,4 .
4. The image encryption method based on neural network multi-feature graph according to claim 2 is characterized in that: The filling and cutting method of step 101 is specifically as follows: Step 101: Determine whether the size of the original image X meets the threshold; Step 102: If the length or width of the original image X is greater than the threshold, the original image X is padded according to a multiple of the threshold, and then segmented according to the threshold value to obtain a plurality of segmented images; Step 103: If both the length and the width of the original image X are smaller than the threshold, the original image X is padded to the threshold size to obtain a padded image.
5. The image encryption method based on neural network multi-feature graph according to claim 2 is characterized in that: The image scale of the input encoding network is (3, H, W), and the obtained feature image X 1,0 is (64, H / 2, W / 2), feature image X 2,0 is (128, H / 2, W / 2), feature image X 3,0 is (256, H / 4, W / 4) and feature image X 4,0 It is (512, H / 8, W / 8), where the first digit of the scale represents the number of channels, H represents the height of the image, and W represents the width of the image.
6. The image encryption method based on neural network multi-feature graph according to claim 1 is characterized in that: The downsampling reduces the spatial dimension of the feature map and increases the number of channel dimensions through a layer of convolution + RELU activation layer + maximum pooling layer.
7. The image encryption method based on neural network multi-feature graph according to claim 3 is characterized in that: Downsampling is done by taking the output image X of the decryption process 0,1 、ImageX 0,2 、ImageX 0,3 and image X 0,4 , and the original image X is used for loss, and the weight of the network model is obtained through multiple rounds of training.
8. The image encryption method based on neural network multi-feature graph according to claim 7 is characterized in that: The loss formula is: , in, is the total loss, L1 is the image X 0,1 The loss of L2 is the image X 0,2 The loss of L3 is the image X 0,3 The loss of L4 is the image X 0,4 The loss, λ1, λ2, λ3, λ4 are the weights corresponding to each loss.
9. The image encryption method based on neural network multi-feature graph according to claim 1 is characterized in that: The upsampling is: , in, is the upsampled feature map The pixel value at the position (x, y) with a depth of d; is the pixel value at position (i, j) in the original feature map F with a depth of d; It is the corresponding element in the upsampling kernel. The upsampling kernel defines how to map the pixel values of the original feature map to the pixel values of the upsampled feature map. H is the image height and W is the image width.
Citation Information
Patent Citations
Color image encryption compression and super-division reconstruction system and method
CN113660386A
Agile image encryption method based on deep learning
CN113992810A
Dual encryption and decryption method based on generative adversarial network and high-dimensional chaotic system
CN118301259A
