An image encryption method, device, equipment and medium

CN117156178BActive Publication Date: 2026-08-21HISENSE GRP HLDG CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210567448.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-23
Publication Date
2026-08-21
Estimated Expiration
2042-05-23

AI Technical Summary

Technical Problem

[0004]本申请提供了一种图像加密方法、装置、设备及介质,用以解决现有技术中基于传统加密算法加密的加密图像的安全性不高,影响用户的体验的问题

Benefits of technology

[0014]在本申请实施例中,获得待加密的第一图像对应的第一图像矩阵,其中,第一图像矩阵中的各个元素为第一图像中包含的各个像素点对应的像素值,采用随机生成的混沌序列中的元素对第一图像矩阵中的对应的元素进行加密,获得第二图像矩阵,将第二图像矩阵对应的图像,确定为对第一图像加密后的第二图像。由于本申请实施例中,待加密的第一图像对应的第一图像矩阵中的每个元素都基于混沌序列中对应的元素进行加密了,因此可以有效的提升对该第一图像进行加密后获得的第二图像的安全性,并提高了用户的体验。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117156178B_ABST
    Figure CN117156178B_ABST
Patent Text Reader

Abstract

The application discloses an image encryption method, device, equipment and medium. In the embodiment of the application, a first image matrix corresponding to a first image to be encrypted is obtained, wherein each element in the first image matrix is a pixel value corresponding to each pixel point contained in the first image. An element in a randomly generated chaotic sequence is used to encrypt a corresponding element in the first image matrix to obtain a second image matrix. The image corresponding to the second image matrix is determined as a second image after the first image is encrypted. Since each element in the first image matrix corresponding to the first image to be encrypted is encrypted based on a corresponding element in the chaotic sequence in the embodiment of the application, the security of the second image obtained after the first image is encrypted can be effectively improved, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, and in particular to an image encryption method, apparatus, device, and medium. Background Technology

[0002] With the development of science and technology, image transmission has become increasingly common, such as uploading and downloading images. People's requirements for security during image transmission have also greatly increased. However, images encrypted using traditional encryption algorithms are relatively easy to recover, resulting in low security and impacting user experience.

[0003] Therefore, how to improve the security of encrypted images is a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0004] This application provides an image encryption method, apparatus, device, and medium to solve the problem that encrypted images based on traditional encryption algorithms in the prior art have low security and affect the user experience.

[0005] In a first aspect, embodiments of this application provide an image encryption method, the method comprising:

[0006] Obtain a first image matrix corresponding to the first image to be encrypted, wherein each element in the first image matrix is ​​the pixel value corresponding to each pixel point contained in the first image;

[0007] The corresponding elements in the first image matrix are encrypted using elements from a randomly generated chaotic sequence to obtain the second image matrix;

[0008] The image corresponding to the second image matrix is ​​determined as the second image after encrypting the first image.

[0009] Secondly, embodiments of this application provide an image encryption device, the device comprising:

[0010] The acquisition module is used to obtain a first image matrix corresponding to a first image to be encrypted, wherein each element in the first image matrix is ​​the pixel value corresponding to each pixel point contained in the first image; and to encrypt the corresponding elements in the first image matrix using elements from a randomly generated chaotic sequence to obtain a second image matrix.

[0011] The determining module is used to determine the image corresponding to the second image matrix as the second image encrypted from the first image.

[0012] Thirdly, embodiments of this application also provide an electronic device, which includes at least a processor and a memory, wherein the processor is used to execute a computer program stored in the memory to implement the steps of any of the image encryption methods described above.

[0013] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the image encryption methods described above.

[0014] In this embodiment, a first image matrix corresponding to a first image to be encrypted is obtained. Each element in the first image matrix represents the pixel value of each pixel in the first image. Elements in the first image matrix are encrypted using elements from a randomly generated chaotic sequence to obtain a second image matrix. The image corresponding to the second image matrix is ​​then identified as the second image obtained by encrypting the first image. Since each element in the first image matrix corresponding to the first image to be encrypted is encrypted based on the corresponding element in the chaotic sequence in this embodiment, the security of the second image obtained after encrypting the first image is effectively improved, and the user experience is enhanced. Attached Figure Description

[0015] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 This application provides a schematic diagram of an image encryption process.

[0017] Figure 2 A schematic diagram showing a first image provided for some embodiments of this application;

[0018] Figure 3 A schematic diagram showing a first image matrix corresponding to a first image provided in some embodiments of this application;

[0019] Figure 4 A schematic diagram showing a first image matrix provided for some embodiments of this application;

[0020] Figure 5 A schematic diagram illustrating a chaotic sequence provided for some embodiments of this application;

[0021] Figure 6 A schematic diagram showing a second image matrix provided for some embodiments of this application;

[0022] Figure 7 A schematic diagram illustrating a process for determining a second image matrix provided in some embodiments of this application;

[0023] Figure 8 A schematic diagram illustrating the determination of a third target element based on a 2×2 matrix, provided for some embodiments of this application;

[0024] Figure 9 This is a schematic diagram illustrating the determination of a third target element based on a 3×3 matrix, provided for some embodiments of this application.

[0025] Figure 10 This is a schematic diagram illustrating the determination of a third target element based on a 4×4 matrix, provided for some embodiments of this application.

[0026] Figure 11 A schematic diagram showing how a square containing a third target element is determined based on a 2×2 matrix, according to some embodiments of this application;

[0027] Figure 12 This is a schematic diagram illustrating how a square containing a third target element is determined based on a 3×3 matrix, according to some embodiments of this application.

[0028] Figure 13 This application provides a schematic diagram of a square containing a third target element based on a 4×4 matrix, according to some embodiments of the present application.

[0029] Figure 14 A schematic diagram showing the squares corresponding to an odd-order matrix provided in some embodiments of this application;

[0030] Figure 15 A schematic diagram showing the sorting result corresponding to the elements in an odd matrix, provided for some embodiments of this application;

[0031] Figure 16 A schematic diagram showing the squares corresponding to an even-order matrix provided in some embodiments of this application;

[0032] Figure 17 A schematic diagram showing the sorting result of elements in an even-order matrix provided in some embodiments of this application;

[0033] Figure 18a A schematic diagram of an image encryption device structure provided in some embodiments of this application;

[0034] Figure 18b This is a schematic diagram of another image encryption device structure provided in some embodiments of this application;

[0035] Figure 19 This is a schematic diagram of the structure of an electronic device provided for some embodiments of this application. Detailed Implementation

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

[0037] In this embodiment of the application, a first image matrix corresponding to a first image to be encrypted is obtained, wherein each element in the first image matrix is ​​the pixel value corresponding to each pixel point contained in the first image. The corresponding elements in the first image matrix are encrypted using elements in a randomly generated chaotic sequence to obtain a second image matrix, wherein each element in the chaotic sequence is not completely identical. The image corresponding to the second image matrix is ​​determined as the second image after encrypting the first image.

[0038] To improve the security of encrypted images and enhance the user experience, this application provides an image encryption method, apparatus, device, and medium.

[0039] Figure 1 This application provides a schematic diagram of an image encryption process, which includes the following steps:

[0040] S101: Obtain the first image matrix corresponding to the first image to be encrypted, wherein each element in the first image matrix is ​​the pixel value corresponding to each pixel point contained in the first image.

[0041] The image encryption method provided in this application is applied to electronic devices, such as smart terminals, PCs, or servers.

[0042] In this embodiment of the application, in order to determine which image to encrypt, the electronic device first obtains a first image to be encrypted. The first image to be encrypted can be in various formats such as RGB image, RGBA image, YUV image and CMYB image. For ease of description, the first image to be encrypted will be described as an RGBA image in the following description.

[0043] To encrypt the first image to be encrypted, the electronic device determines a first image matrix corresponding to the first image based on the pixel values ​​corresponding to each pixel in the first image. This matrix is ​​used for subsequent encryption of the pixel values ​​corresponding to each pixel in the first image. Each element in the first image matrix represents the pixel value corresponding to each pixel in the first image. The number of elements in the first image matrix is ​​equal to the number of pixels in the first image, and the number of elements in each row and each column of the first image matrix is ​​equal to the number of pixels in each row and each column of the first image.

[0044] Figure 2 This is a schematic diagram showing a first image provided for some embodiments of this application. Figure 3 This is a schematic diagram showing a first image matrix corresponding to a first image, provided for some embodiments of this application.

[0045] The first image is a 2×2 image containing four pixels: pixel A, pixel B, pixel C, and pixel D. Pixel A has a value of 'a', pixel B has a value of 'b', pixel C has a value of 'c', and pixel D has a value of 'd'. Figure 2 As shown.

[0046] The first image matrix corresponding to the 2×2 first image is a 2×2 matrix. The element in the first row and first column of this first image matrix represents the pixel value of pixel A, i.e., 'a'; the element in the first row and second column represents the pixel value of pixel B, i.e., 'b'; the element in the second row and first column represents the pixel value of pixel C, i.e., 'c'; and the element in the second row and second column represents the pixel value of pixel D, i.e., 'd', and so on. Figure 3 As shown.

[0047] S102: Encrypt the corresponding elements in the first image matrix using elements from a randomly generated chaotic sequence to obtain the second image matrix.

[0048] In this embodiment, to encrypt the first image to be encrypted, the electronic device can pre-generate a chaotic sequence, where each element in the chaotic sequence is a randomly generated random number. Then, the elements in the randomly generated chaotic sequence are used to encrypt the corresponding elements in the first image matrix to obtain a second image matrix. That is, for each element in the second image matrix, the element is obtained by encrypting the element in the first image matrix that is located at the same position as the first element. Specifically, for each element in the first image matrix, based on the corresponding element in the randomly generated chaotic sequence, the elements in the first image matrix are modified so that the modified elements are different from the unmodified elements, thus achieving encryption of the elements in the first image matrix.

[0049] To ensure encryption security, elements in the chaotic sequence can be used to encrypt corresponding elements in the first image matrix. Therefore, to ensure complete encryption, in this embodiment, the number of elements in the chaotic sequence is not less than the number of elements in the first image matrix. The more elements in the first image matrix, the more elements the randomly generated chaotic sequence contains. For example, if the first image matrix is ​​a 5×5 matrix, the number of elements in the randomly generated chaotic sequence is not less than 25.

[0050] Figure 4 This is a schematic diagram showing a first image matrix provided in some embodiments of this application. Figure 5 The diagram illustrates a chaotic sequence as provided in some embodiments of this application. Figure 6 This is a schematic diagram showing a second image matrix provided for some embodiments of this application.

[0051] The first image matrix is ​​a 4×4 matrix, and x in the first image matrix ij This represents the element corresponding to the i-th row and j-th column, where i and j both take values ​​greater than or equal to 1 and less than or equal to 4. For example, x 11 The element corresponding to the first row and first column, x 34 For the element corresponding to the 3rd row and 4th column, etc., specifically as follows: Figure 4 As shown.

[0052] Sort the rows of the first image matrix from top to bottom, with the top rows appearing first. Then, for each row, sort the elements within that row from left to right, with the leftmost elements appearing first. The final sorted result is x. 11 x 12 x 13 x 14 x 21x 22 ...x 31 x 32 x 33 x 34 .

[0053] Since the first image matrix contains 16 elements, the chaotic sequence only needs to contain 16 elements. Specifically, the elements in the chaotic sequence are a1, a2, a3, a4, a5, a6...a 13 a 14 a 15 a 16 .

[0054] Starting from the first element of the chaotic sequence, and following the sorting order of elements in the first image matrix, the corresponding elements in the first image matrix are encrypted sequentially according to each element of the chaotic sequence to obtain the second image matrix. Here, x in the second image matrix... ij [a i+j [a] is the (i+j)th element a in the basic chaotic sequence. i+j The element x in the i-th row and j-th column of the first image matrix ij Obtained after encryption.

[0055] S103: The image corresponding to the second image matrix is ​​determined as the second image after the first image is encrypted.

[0056] In this embodiment of the application, the second image matrix obtained by encrypting the elements in the first image matrix is ​​the matrix of the second image obtained by encrypting the first image.

[0057] In this embodiment of the application, each element in the first image matrix corresponding to the first image to be encrypted can be encrypted based on the elements in the randomly generated chaotic sequence. Therefore, the security of the second image obtained after encrypting the first image can be effectively improved, thus enhancing the user experience.

[0058] To improve the security of encrypted images and enhance the user experience, based on the above embodiments, in this embodiment, elements from a randomly generated chaotic sequence are used to encrypt corresponding elements in the first image matrix to obtain a second image matrix, including:

[0059] The first image is converted into an image for each channel of a preset format;

[0060] For an image of at least one channel, a chaotic sequence corresponding to the image of that channel is randomly generated; and the elements in the first image matrix corresponding to the image of that channel are encrypted according to the elements in the chaotic sequence to obtain a candidate second image matrix.

[0061] The second image matrix is ​​obtained based on the candidate second image matrix corresponding to the image of the at least one channel.

[0062] In this embodiment of the application, in order to encrypt the elements in the first image matrix using the elements in the randomly generated chaotic sequence to obtain the second image matrix, in one possible implementation, the elements in the first image matrix corresponding to the first image can be directly encrypted based on the elements in the randomly generated chaotic sequence to obtain the second image matrix.

[0063] To enhance encryption security, in another possible implementation, the first image can be first converted into images for each channel of a preset format. For example, if the first image is an RGBA image, it can be converted into images for the R, G, B, and A channels respectively. Then, a randomly generated chaotic sequence is used to encrypt the images for each channel. Specifically, elements from the randomly generated chaotic sequence are used to encrypt the elements in the first image matrix corresponding to the R channel image; elements from the randomly generated chaotic sequence are used to encrypt the elements in the first image matrix corresponding to the G channel image; elements from the randomly generated chaotic sequence are used to encrypt the elements in the first image matrix corresponding to the B channel image; and elements from the randomly generated chaotic sequence are used to encrypt the elements in the first image matrix corresponding to the A channel image.

[0064] To further enhance encryption security, in this embodiment, a chaotic sequence corresponding to the image of at least one channel can be randomly generated, and the corresponding elements in the first image matrix corresponding to the image of that channel can be encrypted according to the elements in the chaotic sequence corresponding to the image of that channel to obtain a candidate second image matrix. Finally, a second image matrix is ​​obtained based on the candidate second image matrix corresponding to the image of at least one channel.

[0065] Specifically, when obtaining the second image matrix based on the candidate second image matrix corresponding to at least one channel's image, first determine whether to encrypt the first image matrix corresponding to all channels' images to obtain the candidate second image matrix corresponding to all channels' images. If so, since each candidate second image matrix has the same size, the second image matrix can be obtained for each candidate second image matrix. Specifically, for each element in the second image matrix, this element is determined based on the corresponding element in the candidate second image matrix corresponding to all channels' images. If not, since each candidate second image matrix has the same size and is also the same size as the first image matrix, the second image matrix can be obtained for each candidate second image matrix and the first image matrix. Specifically, for each element in the second image matrix, this element is determined based on the corresponding element in the first image matrix of all unencrypted channels' images and the corresponding element in the candidate second image matrix of all encrypted channels' images.

[0066] For example, if the first image is an RGBA image, after converting the first image into an R-channel image, a G-channel image, a B-channel image, and an A-channel image respectively, a chaotic sequence corresponding to the R-channel image can be randomly generated based on the R-channel image. Then, the elements in the first image matrix corresponding to the R-channel image can be encrypted according to the elements in the chaotic sequence corresponding to the R-channel image to obtain a candidate second image matrix corresponding to the R-channel image. Finally, the second image matrix is ​​determined based on the candidate second image matrix corresponding to the R-channel image, the first image matrix corresponding to the G-channel image, the first image matrix corresponding to the B-channel image, and the first image matrix corresponding to the A-channel image.

[0067] For example, if the first image is an RGBA image, after converting the first image into images with R channels, G channels, B channels, and A channels respectively, a chaotic sequence corresponding to the image of each channel can be randomly generated. Then, based on the elements in the chaotic sequence corresponding to the image of that channel, the corresponding elements in the first image matrix corresponding to that channel are encrypted to obtain the candidate second image matrix corresponding to that channel. That is, the candidate second image matrices corresponding to the images with R channels, G channels, B channels, and A channels are obtained respectively. Then, based on the candidate second image matrices corresponding to the images with R channels, G channels, B channels, and A channels, the second image matrix is ​​determined.

[0068] When determining the second image matrix based on multiple candidate second image matrices, or based on multiple candidate second image matrices and multiple first image matrices, for ease of description, both the candidate second image matrices and the first image matrices are referred to as the first matrix, and the second image matrix is ​​referred to as the second matrix. When determining the second matrix based on multiple first matrices, for each channel, since each element in the first matrix corresponding to the image of that channel is the pixel value of the pixel corresponding to that channel, for each pixel, after performing a preset calculation on the pixel value corresponding to the pixel in each channel image, the pixel value corresponding to that pixel in the multi-channel image (the image corresponding to the second matrix) can be obtained. For example, for each pixel, the pixel value corresponding to the pixel in the R channel image is 'a', the pixel value corresponding to the pixel in the G channel image is 'b', and the pixel value corresponding to the pixel in the B channel image is 'c', then the pixel value corresponding to the pixel in the RGB image is 'a*0.30+b*0.59+c*0.1'. The format of the image corresponding to the second matrix is ​​different, and the preset operation for determining the second matrix is ​​also different. The process of determining the second matrix based on the first matrix and the preset operation is existing technology and will not be described in detail here.

[0069] Figure 7 This application provides a schematic diagram of a process for determining a second image matrix in some embodiments. The following is a description of the process. Figure 7 Please provide an explanation.

[0070] First, the first image is converted into an image of each channel in a preset format. Then, based on each channel, a chaotic sequence corresponding to the image of that channel is generated. In parallel, the elements in the first image matrix corresponding to each channel are encrypted according to the elements in the chaotic sequence corresponding to each channel image to obtain the candidate second image matrix corresponding to each channel image. Finally, the second image matrix is ​​determined based on the candidate second image matrix corresponding to each channel image.

[0071] To generate chaotic sequences corresponding to each channel, based on the above embodiments, in this embodiment, the step of randomly generating chaotic sequences corresponding to the images of at least one channel includes:

[0072] Randomly initialize the element at the first position in the chaotic sequence corresponding to each channel of the image;

[0073] For each position other than the first position in the chaotic sequence corresponding to the image of each channel, the element at the other position is determined based on the first target element at the target position in the chaotic sequence corresponding to the image of that channel that is located before and adjacent to that other position, and the second target element at the target position in the chaotic sequence corresponding to the image of the target channel; wherein, the target channel is the channel that is determined after the channel according to the order of the pre-saved channels.

[0074] In this embodiment of the application, in order to generate the chaotic sequence corresponding to the image of each channel, the element at the first position in the chaotic sequence corresponding to the image of each channel can be randomly initialized first, and then the elements at other positions in the chaotic sequence corresponding to the image of each channel can be determined in turn.

[0075] To determine the elements at other positions in the chaotic sequence corresponding to each channel's image, for each other position in the chaotic sequence corresponding to each channel's image (excluding the first position), the elements at that other position can be determined based on the first target element at the target position in the chaotic sequence corresponding to that channel's image, which is located before and adjacent to that other position, and the second target element at that target position in the chaotic sequence corresponding to the target channel's image; wherein, the target channel is the channel that follows the channel determined according to the pre-saved order of each channel.

[0076] The order of the pre-saved channels can be R channel, G channel, B channel, A channel, or A channel, R channel, B channel, G channel, etc. There are no restrictions on the order of the pre-saved channels.

[0077] It should be noted that when determining the elements at other positions in the chaotic sequence corresponding to the last channel in the pre-saved order of the channels, any other channel can be determined as the channel after the last channel. For example, the first channel in the pre-saved order of the channels can be determined as the channel after the last channel, so as to subsequently determine the elements at other positions in the chaotic sequence corresponding to the last channel.

[0078] If the pre-saved channels are in the order of R channel, G channel, B channel, and A channel, then after randomly initializing the first element of the chaotic sequence corresponding to the image of R channel, the first element of the chaotic sequence corresponding to the image of G channel, the first element of the chaotic sequence corresponding to the image of B channel, and the first element of the chaotic sequence corresponding to the image of A channel, the second element of the chaotic sequence corresponding to R channel is determined based on the first element of the chaotic sequence corresponding to R channel and the first element of the chaotic sequence corresponding to G channel; the second element of the chaotic sequence corresponding to G channel is determined based on the first element of the chaotic sequence corresponding to G channel and the first element of the chaotic sequence corresponding to B channel, and so on. Specifically, the process of determining the other elements in the chaotic sequence corresponding to each channel is similar and will not be explained here.

[0079] In this embodiment of the application, the chaotic sequence corresponding to each channel's image can be determined in the following manner:

[0080]

[0081] Where x1(k+1) is the (k+1)th element of the first channel in the pre-saved order of the channels, x1(k) is the kth element of the first channel in the pre-saved order of the channels, x2(k+1) is the (k+1)th element of the second channel in the pre-saved order of the channels, x2(k) is the kth element of the second channel in the pre-saved order of the channels, x3(k+1) is the (k+1)th element of the third channel in the pre-saved order of the channels, x3(k) is the kth element of the third channel in the pre-saved order of the channels, x4(k+1) is the (k+1)th element of the fourth channel in the pre-saved order of the channels, and x4(k) is the kth element of the fourth channel in the pre-saved order of the channels.

[0082] The preset parameter values ​​for generating the chaotic sequence are as follows:

[0083] γ1=2, β1=2, ω1=1, α1=1.5; γ2=4, β2=2, ω2=1, α2=1.5;

[0084] γ3=6, β3=3, ω3=1, α3=1.5; γ4=3, β4=5, ω4=1, α4=1.5;

[0085] The first element in the chaotic sequence corresponding to each channel is: x1(0) = 0.5; x2(0) = 0.4; x3(0) = 0.3; x4(0) = 0.2.

[0086] To facilitate subsequent encryption of the first image, based on the above embodiments, in this embodiment of the application, after randomly generating the chaotic sequence corresponding to the image of the channel, and before encrypting the corresponding elements in the first image matrix corresponding to the image of the channel according to the elements in the chaotic sequence to obtain the candidate second image matrix, the method further includes:

[0087] For each element in the chaotic sequence, the element is rounded down according to the element and a preset rounding down algorithm, and the result of the rounding down process is updated to the element.

[0088] In this embodiment, for each channel, the chaotic sequence corresponding to the image of that channel may contain elements that are decimals. If there are elements that are decimals, it is not convenient to encrypt the first image later. Therefore, in this embodiment, after randomly generating the chaotic sequence corresponding to the image of that channel, each element in the chaotic sequence can be rounded down according to the element and a preset rounding down algorithm, and the result of the rounding down process can be updated to the element so that each element in the chaotic sequence is an integer.

[0089] Specifically, the process of rounding down each element in the chaotic sequence can be as follows:

[0090]

[0091] Where, x i (k) The k-th element in channel i; floor represents the floor operation. The integer obtained by rounding down the k-th element in channel i.

[0092] To facilitate subsequent encryption of the first image, based on the above embodiments, in this embodiment of the application, after updating the element with the result of the floor function, the method further includes:

[0093] For each element in the chaotic sequence, a modulo operation is performed on the element based on the number of bits corresponding to the first image, and the result obtained after the modulo operation is updated to the element.

[0094] In this embodiment, since a randomly generated chaotic sequence may contain elements with very large values, and since a typical image is 8 bits, the upper limit of the pixel value of an image is usually 255, i.e., 2^35. 8 -1. To facilitate calculation, we can also perform a modulo operation on each element in the chaotic sequence and update the element obtained after the modulo operation.

[0095] Specifically, the process of performing a modulo operation on each element in the chaotic sequence can be as follows:

[0096]

[0097] Where, x i (k) The k-th element in channel i; mod is the modulo operation. The value is obtained by performing a modulo operation on the k-th element in channel i, and bit represents the number of bits in the image.

[0098] To obtain a candidate second image matrix, based on the above embodiments, in this embodiment, the step of encrypting the corresponding elements in the first image matrix corresponding to the image of that channel according to the elements in the chaotic sequence to obtain the candidate second image matrix includes:

[0099] For each element in the first image matrix corresponding to the image of the channel, the target index position in the chaotic sequence corresponding to the first target position is determined according to the first target position of the element in the first image matrix corresponding to the image of the channel and the preset index formula; the modified element is determined according to the element, the element corresponding to the target index position in the chaotic sequence corresponding to the image of the channel, and the preset adjustment function.

[0100] The candidate second image matrix is ​​determined based on each modified element in the first image matrix corresponding to the image of that channel.

[0101] In this embodiment of the application, when encrypting the elements in the first image matrix corresponding to the image of a channel based on the elements in the chaotic sequence corresponding to the image of that channel, in one possible implementation, the first image matrix corresponding to the image of that channel can be converted into a target vector in a preset order. Then, for each element in the chaotic sequence corresponding to that channel, the element corresponding to the target position in the target vector is determined based on the target position of the element, and the element is used to encrypt the element corresponding to the target position in the vector.

[0102] The process of determining the pre-set order can be as follows: First, sort the rows of the first image matrix corresponding to the image of that channel. Specifically, this can be done by sorting the rows of the first image matrix corresponding to the image of that channel from top to bottom, bottom to top, etc. Based on the sorting result, each element in each row is then used as an element of the target vector in a left-to-right order. Alternatively, the process of determining the pre-set order can be as follows: First, sort the columns of the first image matrix corresponding to the image of that channel. Specifically, this can be done by sorting the columns of the first image matrix corresponding to the image of that channel from left to right, right to left, etc. Based on the sorting result, each element in each column is then used as an element of the target vector in a top-to-bottom order.

[0103] To enhance encryption security, in another possible implementation, an index formula can be pre-set. For each element in the first image matrix corresponding to the image of the channel, based on the first target position of the element in the first image matrix corresponding to the image of the channel and the preset index formula, the target index position in the chaotic sequence corresponding to the first target position is determined. Based on the element, the element corresponding to the target index position in the chaotic sequence corresponding to the image of the channel, and the preset adjustment function, the modified element is determined. Based on each modified element in the first image matrix corresponding to the image of the channel, the candidate second image matrix is ​​determined.

[0104] The position of the element in the first image matrix corresponding to the channel serves as a unique identifier. Specifically, the first image matrix corresponding to the channel's image can be pre-converted into a target vector. For each element, its target position is determined based on its position within the target vector. For example, if the element is the 5th component in the target vector, its target position is determined to be 5. The process of converting the first image matrix corresponding to the channel's image into a target vector has been described in the above embodiments and will not be repeated here.

[0105] For example, for the first element in the first image matrix corresponding to the image of this channel, if the first target position corresponding to the first element is 1 (the first component in the target vector), then according to the first target position and the preset index formula, the target index position is determined to be 20. Then, according to the first element, the element corresponding to the 20th element in the chaotic sequence corresponding to the image of this channel, and the preset adjustment function, the modified first element is determined.

[0106] In this embodiment, the index formulas for different channels can be the same or different. To improve encryption security, different index formulas can be preset for different channels. Specifically, the index formulas for each channel can be:

[0107]

[0108]

[0109]

[0110] key4(k)=floor[cos(k)×10000]

[0111] Here, key1(k) is the index formula corresponding to the first channel in the pre-saved order of the channels, key2(k) is the index formula corresponding to the second channel in the pre-saved order of the channels, key3(k) is the index formula corresponding to the third channel in the pre-saved order of the channels, and key4(k) is the index formula corresponding to the fourth channel in the pre-saved order of the channels, where k represents the k-th element in the target vector.

[0112] In this embodiment of the application, the preset adjustment function can be:

[0113]

[0114] in, For the element with position information k in the first image matrix corresponding to the modified image of the i-th channel, I i,k The element with position information k in the first image matrix corresponding to the image of the i-th channel before the change. This refers to the element at the target index position in the chaotic sequence corresponding to the image of this channel, where the target index position is key. i(k) It is determined based on the location information k and the preset index formula.

[0115] To further enhance encryption security, in this embodiment of the application, the preset adjustment function may also be:

[0116]

[0117] in, For the element with position information k in the first image matrix corresponding to the modified image of the i-th channel, I i,k The element with position information k in the first image matrix corresponding to the image of the i-th channel before the change. Let key be the element at the target index position in the chaotic sequence corresponding to the image of the i-th channel. i(k) This is determined based on the location information k and a preset index formula. The element corresponding to the target index position in the chaotic sequence corresponding to the image of the (i+1)th channel that is adjacent to the i-th channel and follows the i-th channel in the pre-saved order of each channel.

[0118] To improve the security of image encryption, based on the above embodiments, in this embodiment, determining the image corresponding to the second image matrix as the second image obtained after encrypting the first image includes:

[0119] Based on the preset scrambling rules, each element in the second image matrix is ​​scrambled;

[0120] The image corresponding to the image matrix obtained after scrambling is identified as the second image obtained by encrypting the first image.

[0121] In this application embodiment, in order to obtain a second image after encrypting the first image, in one possible implementation, each element in the first image matrix corresponding to the first image to be encrypted can be modified (encrypted) based on the elements in the randomly generated chaotic sequence. After obtaining the second image matrix, the image corresponding to the second image matrix can be directly determined as the second image after encrypting the first image.

[0122] In another possible implementation, to improve encryption security, each element in the second image matrix can be scrambled based on a preset scrambling rule, and the image corresponding to the scrambled image matrix can be determined as the second image obtained after encrypting the first image.

[0123] In order to scramble the elements in the second image matrix, based on the above embodiments, in this embodiment, scrambling the elements in the second image matrix according to a preset scrambling rule includes:

[0124] Determine the center position of the second image matrix and set the center position as the origin of the coordinate system;

[0125] Determine each third target element in the second image matrix that starts from the origin of the coordinate system and is located in a preset direction;

[0126] With the origin of the coordinate system as the center, and each of the third target elements as vertices, determine each square;

[0127] The following processing is performed sequentially according to the size of the square: each element located on the square is sequentially placed in each corresponding empty position in the empty matrix in a set order, wherein the empty matrix is ​​the same size as the second image matrix;

[0128] The adjusted idle matrix is ​​then updated to the second image matrix.

[0129] In this embodiment of the application, in order to scramble the elements in the second image matrix, one possible implementation is to replace the element in the i-th row and j-th column of the second image matrix with the element in the j-th row and i-th column, thereby scrambling the elements in the second image matrix.

[0130] In another possible implementation, the center position of the second image matrix can be determined and set as the origin of the coordinate system. If the second image matrix is ​​an odd-order matrix, an element exists at its center; if the second image matrix is ​​an even-order matrix, no element exists at its center. Then, each third target element in the second image matrix, originating from the origin and located in a preset direction, is determined. Finally, squares are defined with the origin as the center and each third target element as a vertex. Based on these squares, the elements in the second image matrix are scrambled. The preset direction can be any one of the following: the upper-left direction originating from the origin, the upper-right direction originating from the origin, the lower-left direction originating from the origin, or the lower-right direction originating from the origin. If the matrix is ​​a 2×2 matrix or a 3×3 matrix, then there is one third target element starting from the origin and located in the preset direction. If the matrix is ​​neither a 2×2 matrix nor a 3×3 matrix, then there are at least two third target elements starting from the origin and located in the preset direction.

[0131] Figure 8 A schematic diagram illustrating the determination of a third target element based on a 2×2 matrix, provided in some embodiments of this application. Figure 9 A schematic diagram illustrating the determination of a third target element based on a 3×3 matrix, provided for some embodiments of this application. Figure 10 This application provides a schematic diagram illustrating the determination of a third target element based on a 4×4 matrix, as shown in some embodiments. Figure 8 , Figure 9 as well as Figure 10 Please provide an explanation.

[0132] The explanation is based on the preset direction of the upper left, and this... Figure 8 , Figure 9 as well as Figure 10 The circles in the matrix represent the elements in the matrix.

[0133] Figure 8 The origin of the coordinate system in the 2×2 matrix is ​​A. Based on this 2×2 matrix, there is only one third target element, which is B. Figure 9 The origin of the coordinate system in the 3×3 matrix is ​​C. Based on this 3×3 matrix, the third target element is determined to be only one element, which is D. Figure 10 The origin of the coordinate system in the 4×4 matrix is ​​E. Based on this 4×4 matrix, the third target element is determined to be two elements, namely F and G.

[0134] To facilitate arranging the elements of the second image matrix within a square, before determining the origin, first determine if the second image matrix is ​​a square matrix. If it is, then determine the center position of the second image matrix as the origin, then determine each third target element in the second image matrix that is located in a preset direction with the origin as the starting point, and then determine each square with the origin as the center and each third target element as the vertex. If the second image matrix is ​​not a square matrix, then first convert the second image matrix into a square matrix and update the second image matrix with the square matrix, then determine the center position of the second image matrix as the origin, then determine each third target element in the second image matrix that is located in a preset direction with the origin as the starting point, and then determine each square with the origin as the center and each third target element as the vertex.

[0135] The second image matrix can be converted into a square matrix by adding elements with preset values, where the preset values ​​can be 0, etc. For example, if the second image matrix is ​​a 2×3 matrix, an element can be added before the first row of elements in the second image matrix, and the elements in the added row can all be 0, and an element can also be added after the second row of elements in the second image matrix, and the elements in the added row can all be 0, etc.

[0136] Figure 11 This application provides a schematic diagram illustrating how a square containing a third target element is determined based on a 2×2 matrix, according to some embodiments of the present application. Figure 12 This application provides a schematic diagram illustrating how a square containing a third target element is determined based on a 3×3 matrix, according to some embodiments of the present application. Figure 13 This application provides a schematic diagram illustrating the determination of the square containing the third target element based on a 4×4 matrix, as shown in some embodiments. The diagram is now being discussed. Figure 11 , Figure 12 as well as Figure 13 Please provide an explanation.

[0137] Figure 11 In the 2×2 matrix, the square containing the determined third target element is square 1. (Figure) Figure 12 In a 3×3 matrix, the square containing the determined third target element is square 2. Figure 13 In a 4×4 matrix, the squares containing the determined third target element are square 3 and square 4.

[0138] To facilitate the scrambling of elements in the second image matrix, in this embodiment, a free matrix can be pre-set, wherein the free matrix is ​​the same size as the second image matrix. Then, the following processing is performed sequentially according to the size of the squares: each element located on the square is sequentially placed in its corresponding free position in the free matrix according to a predetermined order. Specifically, each element located on each square can be sorted according to its size and a predetermined order, and then, based on the sorting result, each element is sequentially placed in its corresponding free position in the free matrix. Specifically, if the origin contains an element, the element at the origin is first placed in its corresponding free position in the free matrix, and then each element on the square is sequentially placed in its corresponding free position in the free matrix according to the predetermined order; if the origin does not contain an element, each element on the square is directly placed in its corresponding free position in the free matrix according to the predetermined order.

[0139] In one possible implementation, the elements in each square can be sorted sequentially in a clockwise direction, from smallest to largest, and then, based on the sorting result, each element can be placed in its corresponding empty position in the empty matrix.

[0140] In another possible implementation, the elements in each square can be sorted in descending order of size and in a counter-clockwise direction. Then, based on the sorting results, each element can be placed in its corresponding empty position in the empty matrix.

[0141] Figure 14 This is a schematic diagram showing the squares corresponding to an odd-order matrix provided in some embodiments of this application. Figure 15 This is a schematic diagram showing the sorting result of elements in an odd-numbered matrix, provided in some embodiments of this application. Figure 16 This is a schematic diagram showing the squares corresponding to an even-order matrix provided in some embodiments of this application. Figure 17 This application provides a schematic diagram showing the sorting result of elements in an even-order matrix according to some embodiments. The following is a description of the display of the sorting result of elements in an even-order matrix. Figure 14 , Figure 15 , Figure 16as well as Figure 17 Please provide an explanation.

[0142] Taking a 7th-order matrix as an example, where the center of the 7th-order matrix contains its elements, and using the center of the 7th-order matrix as the origin and the upper left corner as the preset direction, three third target elements are determined. For each third target element, three squares containing that third target element are determined, such as... Figure 14 As shown.

[0143] The elements in each square are sorted in ascending order and counter-clockwise. The resulting value represents the element's position in the sorted matrix. For example, the element in the 7th row and 7th column of a 7th-order matrix has the value 47. Figure 15 As shown.

[0144] Taking an even-order 6th-order matrix as an example, where the center of the 6th-order matrix does not contain any elements of the matrix, and using the center of the 6th-order matrix as the origin and the upper left corner as the preset direction, three third target elements are determined. For each third target element, three squares containing that third target element are determined, such as... Figure 16 As shown.

[0145] The elements in each square are sorted in ascending order and counter-clockwise. The resulting value represents the element's position in the sorted matrix. For example, the element in the 4th row and 6th column of a 6th-order matrix has the value 36. Figure 17 As shown.

[0146] Since the second image matrix is ​​not a square matrix, this application converts the second image matrix into a square matrix by adding elements with preset values. Therefore, when each element located on the square is sequentially set in each corresponding empty position in the empty matrix, if an element with an added preset value is encountered, the element with the added preset value can be skipped directly, and other elements that are not the added preset value can be added to the corresponding empty position. The adjusted empty matrix is ​​then updated to the second image matrix to ensure that the size of the updated second image matrix is ​​the same as the size of the first image matrix corresponding to the first image to be encrypted.

[0147] Figure 18a This application provides a schematic diagram of the structure of an image encryption device according to some embodiments. The device includes:

[0148] The acquisition module 1801 is used to obtain a first image matrix corresponding to a first image to be encrypted, wherein each element in the first image matrix is ​​a pixel value corresponding to each pixel point contained in the first image; and to encrypt the corresponding elements in the first image matrix using elements in a randomly generated chaotic sequence to obtain a second image matrix.

[0149] The determining module 1802 is used to determine the image corresponding to the second image matrix as the second image encrypted from the first image.

[0150] Figure 18b The schematic diagram shows another image encryption device structure provided in some embodiments of this application. Based on the above embodiments, the device further includes:

[0151] In one possible implementation, the acquisition module 1801 is specifically used to convert the first image into an image of each channel in a preset format; for the image of at least one channel, randomly generate a chaotic sequence corresponding to the image of that channel; and encrypt the corresponding elements in the first image matrix corresponding to the image of that channel according to the elements in the chaotic sequence to obtain a candidate second image matrix; and obtain the second image matrix according to the candidate second image matrix corresponding to the image of at least one channel.

[0152] In one possible implementation, the acquisition module 1801 is specifically used to randomly initialize the element at the first position in the chaotic sequence corresponding to the image of each channel; for each other position in the chaotic sequence corresponding to the image of each channel other than the first position, the element at the other position is determined based on the first target element at the target position in the chaotic sequence corresponding to the image of that channel that is located before and adjacent to that other position, and the second target element at the target position in the chaotic sequence corresponding to the image of the target channel; wherein, the target channel is the channel that is determined after the channel according to the order of the pre-saved channels.

[0153] In one possible implementation, the device further includes:

[0154] The update module 1803 is used to perform a floor function on each element in the chaotic sequence, based on the element and a preset floor function algorithm, and update the element with the result of the floor function.

[0155] In one possible implementation, the update module 1803 is further configured to perform a modulo operation on each element in the chaotic sequence based on the number of bits corresponding to the first image, and update the element with the result obtained after the modulo operation.

[0156] In one possible implementation, the acquisition module 1801 is specifically used to, for each element in the first image matrix corresponding to the image of the channel, determine the target index position in the chaotic sequence corresponding to the first target position based on the first target position of the element in the first image matrix corresponding to the image of the channel and a preset index formula; determine the modified element based on the element, the element corresponding to the target index position in the chaotic sequence corresponding to the image of the channel, and a preset adjustment function; and determine the candidate second image matrix based on each modified element in the first image matrix corresponding to the image of the channel.

[0157] In one possible implementation, the determining module 1802 is specifically used to scramble each element in the second image matrix based on a preset scrambling rule; and to determine the image corresponding to the scrambled image matrix as the second image obtained after encrypting the first image.

[0158] In one possible implementation, the determining module 1802 is specifically used to determine the center position of the second image matrix and define the center position as the origin of the coordinate system; determine each third target element in the second image matrix that starts from the origin of the coordinate system and is located in a preset direction; determine each square with the origin of the coordinate system as the center and each third target element as a vertex; and perform the following processing according to the size of the squares: according to a set order, set each element located on the square in each corresponding empty position in the empty matrix, wherein the empty matrix is ​​the same size as the second image matrix; and update the adjusted empty matrix to the second image matrix.

[0159] Based on the above embodiments, some embodiments of this application also provide an electronic device, such as... Figure 19 As shown, it includes: processor 1901, communication interface 1902, memory 1903 and communication bus 1904, wherein processor 1901, communication interface 1902 and memory 1903 communicate with each other through communication bus 1904.

[0160] The memory 1903 stores a computer program, which, when executed by the processor 1901, causes the processor 1901 to perform the following steps:

[0161] Obtain a first image matrix corresponding to the first image to be encrypted, wherein each element in the first image matrix is ​​the pixel value corresponding to each pixel point contained in the first image;

[0162] The corresponding elements in the first image matrix are encrypted using elements from a randomly generated chaotic sequence to obtain the second image matrix;

[0163] The image corresponding to the second image matrix is ​​determined as the second image after encrypting the first image.

[0164] Further, the processor 1901 is specifically configured to convert the first image into an image of each channel in a preset format; for an image of at least one channel, randomly generate a chaotic sequence corresponding to the image of that channel; and encrypt the corresponding elements in the first image matrix corresponding to the image of that channel according to the elements in the chaotic sequence to obtain a candidate second image matrix; and obtain the second image matrix according to the candidate second image matrix corresponding to the image of at least one channel.

[0165] Further, the processor 1901 is specifically configured to randomly initialize the element at the first position in the chaotic sequence corresponding to the image of each channel; for each other position in the chaotic sequence corresponding to the image of each channel other than the first position, based on the first target element at the target position in the chaotic sequence corresponding to the image of that channel that is located before and adjacent to that other position, and the second target element at the target position in the chaotic sequence corresponding to the image of the target channel; wherein, the target channel is the channel that is determined after the channel according to the order of the pre-saved channels.

[0166] Furthermore, the processor 1901 is also configured to perform a floor function on each element in the chaotic sequence, based on the element and a preset floor function algorithm, and update the element with the result of the floor function.

[0167] Furthermore, the processor 1901 is also configured to perform a modulo operation on each element in the chaotic sequence according to the number of bits corresponding to the first image, and update the element with the result obtained after the modulo operation.

[0168] Further, the processor 1901 is specifically configured to, for each element in the first image matrix corresponding to the image of the channel, determine the target index position in the chaotic sequence corresponding to the first target position based on the first target position of the element in the first image matrix corresponding to the image of the channel and a preset index formula; determine the modified element based on the element, the element corresponding to the target index position in the chaotic sequence corresponding to the image of the channel, and a preset adjustment function; and determine the candidate second image matrix based on each modified element in the first image matrix corresponding to the image of the channel.

[0169] Furthermore, the processor 1901 is specifically used to scramble each element in the second image matrix based on a preset scrambling rule; and to determine the image corresponding to the scrambled image matrix as the second image obtained by encrypting the first image.

[0170] Further, the processor 1901 is specifically configured to determine the center position of the second image matrix and define the center position as the origin of the coordinate system; determine each third target element in the second image matrix that starts from the origin of the coordinate system and is located in a preset direction; define each square with the origin of the coordinate system as the center and each third target element as a vertex; and perform the following processing according to the size of the squares: in a set order, set each element located on the square in each corresponding empty position in the empty matrix, wherein the empty matrix is ​​the same size as the second image matrix; and update the adjusted empty matrix to the second image matrix.

[0171] The communication bus mentioned in the above server can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0172] Communication interface 1902 is used for communication between the above-mentioned electronic device and other devices.

[0173] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0174] The processors mentioned above can be general-purpose processors, including central processing units, network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits, field-programmable gate arrays or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0175] Based on the above embodiments, some embodiments of this application also provide a computer-readable storage medium storing a computer program executable by an electronic device. When the program is run on the electronic device, the electronic device performs the following steps:

[0176] Obtain a first image matrix corresponding to the first image to be encrypted, wherein each element in the first image matrix is ​​the pixel value corresponding to each pixel point contained in the first image;

[0177] The corresponding elements in the first image matrix are encrypted using elements from a randomly generated chaotic sequence to obtain the second image matrix;

[0178] The image corresponding to the second image matrix is ​​determined as the second image after encrypting the first image.

[0179] Furthermore, the second image matrix is ​​obtained by encrypting corresponding elements in the first image matrix using elements from a randomly generated chaotic sequence:

[0180] The first image is converted into an image for each channel of a preset format;

[0181] For an image of at least one channel, a chaotic sequence corresponding to the image of that channel is randomly generated; and the elements in the first image matrix corresponding to the image of that channel are encrypted according to the elements in the chaotic sequence to obtain a candidate second image matrix.

[0182] The second image matrix is ​​obtained based on the candidate second image matrix corresponding to the image of the at least one channel.

[0183] Furthermore, the step of randomly generating a chaotic sequence corresponding to the image of at least one channel includes:

[0184] Randomly initialize the element at the first position in the chaotic sequence corresponding to each channel of the image;

[0185] For each position other than the first position in the chaotic sequence corresponding to the image of each channel, the element at the other position is determined based on the first target element at the target position in the chaotic sequence corresponding to the image of that channel that is located before and adjacent to that other position, and the second target element at the target position in the chaotic sequence corresponding to the image of the target channel; wherein, the target channel is the channel that is determined after the channel according to the order of the pre-saved channels.

[0186] Furthermore, after randomly generating the chaotic sequence corresponding to the image of that channel, and before encrypting the corresponding elements in the first image matrix corresponding to the image of that channel based on the elements in the chaotic sequence to obtain the candidate second image matrix, the method further includes:

[0187] For each element in the chaotic sequence, the element is rounded down according to the element and a preset rounding down algorithm, and the result of the rounding down process is updated to the element.

[0188] Furthermore, after updating the element with the result of the floor function, the method further includes:

[0189] For each element in the chaotic sequence, a modulo operation is performed on the element based on the number of bits corresponding to the first image, and the result obtained after the modulo operation is updated to the element.

[0190] Further, the step of encrypting the corresponding elements in the first image matrix corresponding to the image of the channel based on the elements in the chaotic sequence to obtain the candidate second image matrix includes:

[0191] For each element in the first image matrix corresponding to the image of the channel, the target index position in the chaotic sequence corresponding to the first target position is determined according to the first target position of the element in the first image matrix corresponding to the image of the channel and the preset index formula; the modified element is determined according to the element, the element corresponding to the target index position in the chaotic sequence corresponding to the image of the channel, and the preset adjustment function.

[0192] The candidate second image matrix is ​​determined based on each modified element in the first image matrix corresponding to the image of that channel.

[0193] Further, determining the image corresponding to the second image matrix as the second image obtained after encrypting the first image includes:

[0194] Based on the preset scrambling rules, each element in the second image matrix is ​​scrambled;

[0195] The image corresponding to the image matrix obtained after scrambling is identified as the second image obtained by encrypting the first image.

[0196] Furthermore, the scrambling of each element in the second image matrix based on the preset scrambling rules includes:

[0197] Determine the center position of the second image matrix and set the center position as the origin of the coordinate system;

[0198] Determine each third target element in the second image matrix that starts from the origin of the coordinate system and is located in a preset direction;

[0199] With the origin of the coordinate system as the center, and each third target element as a vertex, determine each square;

[0200] The following processing is performed sequentially according to the size of the square: each element located on the square is sequentially placed in each corresponding empty position in the empty matrix in a set order, wherein the empty matrix is ​​the same size as the second image matrix;

[0201] The adjusted idle matrix is ​​then updated to the second image matrix.

[0202] In this embodiment of the application, each element in the first image matrix corresponding to the first image to be encrypted is encrypted based on the corresponding element in the chaotic sequence. Therefore, the security of the second image obtained after encrypting the first image can be effectively improved, and the user experience can be enhanced.

[0203] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0204] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0205] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1The function specified in one or more boxes.

[0206] These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable apparatus for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0207] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. An image encryption method, characterized in that, The method includes: Obtain a first image matrix corresponding to the first image to be encrypted, wherein each element in the first image matrix is ​​the pixel value corresponding to each pixel point contained in the first image; The corresponding elements in the first image matrix are encrypted using elements from a randomly generated chaotic sequence to obtain the second image matrix; The image corresponding to the second image matrix is ​​determined as the second image after the first image is encrypted; The method of encrypting corresponding elements in the first image matrix using elements from a randomly generated chaotic sequence to obtain the second image matrix includes: The first image is converted into an image for each channel of a preset format; For an image of at least one channel, a chaotic sequence corresponding to the image of that channel is randomly generated; and the elements in the first image matrix corresponding to the image of that channel are encrypted according to the elements in the chaotic sequence to obtain a candidate second image matrix. The second image matrix is ​​obtained based on the candidate second image matrix corresponding to the image of the at least one channel; Wherein, for an image of at least one channel, randomly generating a chaotic sequence corresponding to that channel's image includes: Randomly initialize the first element in the chaotic sequence corresponding to each channel's image; For each position other than the first position in the chaotic sequence corresponding to the image of each channel, the element at the other position is determined based on the first target element at the target position in the chaotic sequence corresponding to the image of that channel that is located before and adjacent to that other position, and the second target element at the target position in the chaotic sequence corresponding to the image of the target channel; wherein, the target channel is the channel that is determined after the channel according to the order of the pre-saved channels.

2. The method according to claim 1, characterized in that, After randomly generating the chaotic sequence corresponding to the image of the channel, and before encrypting the corresponding elements in the first image matrix corresponding to the image of the channel based on the elements in the chaotic sequence to obtain the candidate second image matrix, the method further includes: For each element in the chaotic sequence, the element is rounded down according to the element and a preset rounding down algorithm, and the result of the rounding down process is updated to the element.

3. The method according to claim 1, characterized in that, The step of encrypting the corresponding elements in the first image matrix corresponding to the image of the channel based on the elements in the chaotic sequence to obtain the candidate second image matrix includes: For each element in the first image matrix corresponding to the image of the channel, the target index position in the chaotic sequence corresponding to the first target position is determined according to the first target position of the element in the first image matrix corresponding to the image of the channel and the preset index formula; the modified element is determined according to the element, the element corresponding to the target index position in the chaotic sequence corresponding to the image of the channel, and the preset adjustment function. The candidate second image matrix is ​​determined based on each modified element in the first image matrix corresponding to the image of that channel.

4. The method according to claim 1, characterized in that, The step of determining the image corresponding to the second image matrix as the second image obtained after encrypting the first image includes: Based on the preset scrambling rules, each element in the second image matrix is ​​scrambled; The image corresponding to the image matrix obtained after scrambling is identified as the second image obtained after encrypting the first image.

5. The method according to claim 4, characterized in that, The scrambling of each element in the second image matrix based on the preset scrambling rules includes: Determine the center position of the second image matrix and set the center position as the origin of the coordinate system; Determine each third target element in the second image matrix that starts from the origin of the coordinate system and is located in a preset direction; With the origin of the coordinate system as the center, and each of the third target elements as vertices, determine each square; The following processing is performed sequentially according to the size of the square: each element located on the square is sequentially placed in each corresponding empty position in the empty matrix in a set order, wherein the empty matrix is ​​the same size as the second image matrix; The adjusted idle matrix is ​​then updated to the second image matrix.

6. An image encryption device, characterized in that, The device includes: The acquisition module is used to obtain a first image matrix corresponding to a first image to be encrypted, wherein each element in the first image matrix is ​​the pixel value corresponding to each pixel point contained in the first image; and to encrypt the corresponding elements in the first image matrix using elements from a randomly generated chaotic sequence to obtain a second image matrix. The determining module is used to determine the image corresponding to the second image matrix as the second image encrypted from the first image; The method of encrypting corresponding elements in the first image matrix using elements from a randomly generated chaotic sequence to obtain the second image matrix includes: The first image is converted into an image for each channel of a preset format; For an image of at least one channel, a chaotic sequence corresponding to the image of that channel is randomly generated; and the elements in the first image matrix corresponding to the image of that channel are encrypted according to the elements in the chaotic sequence to obtain a candidate second image matrix. The second image matrix is ​​obtained based on the candidate second image matrix corresponding to the image of the at least one channel; Wherein, for an image of at least one channel, randomly generating a chaotic sequence corresponding to that channel's image includes: Randomly initialize the first element in the chaotic sequence corresponding to each channel's image; For each position other than the first position in the chaotic sequence corresponding to the image of each channel, the element at the other position is determined based on the first target element at the target position in the chaotic sequence corresponding to the image of that channel that is located before and adjacent to that other position, and the second target element at the target position in the chaotic sequence corresponding to the image of the target channel; wherein, the target channel is the channel that is determined after the channel according to the order of the pre-saved channels.

7. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory being used to store program instructions, and the processor being used to execute the computer program stored in the memory to implement the steps of the image encryption method according to any one of claims 1-5.

8. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements the steps of the image encryption method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Chaotic sequence and DNA mutation image encryption method and device

    CN112084514A