A method for encrypting JPEG color image based on chaos theory
By employing a JPEG color image encryption method based on chaos theory, which utilizes a pseudo-random key sequence to scramble, XOR, and recombine RSV pairs of image blocks, the problem of balancing compression performance and security in existing technologies is solved, achieving efficient image encryption.
Patent Information
- Application Number
- CN202310344856.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-03
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2043-04-03
AI Technical Summary
Existing JPEG image encryption methods struggle to improve encryption security while maintaining compression performance, especially since operations during the DCT transform and quantization stages can lead to either a loss of compression performance or a reduction in security.
A JPEG color image encryption method based on chaos theory is adopted. The encryption process is achieved by scrambling, XORing, symbol transformation and RSV pair recombination of image blocks through pseudo-random key sequence, combined with the DCT transformation, quantization and entropy coding stages of the JPEG compression standard.
It significantly improves encryption security without sacrificing compression performance, resists differential attacks, reduces the correlation between adjacent pixels, and reduces encryption time.
Smart Images

Figure BDA0004159244450000031 
Figure BDA0004159244450000033 
Figure BDA0004159244450000071
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of image encryption, and particularly relates to a JPEG color image encryption method based on chaos theory. BACKGROUND
[0002] With the rapid development of information technology, the Internet has become an indispensable part of people's daily life. At present, the common information transmission on the network is mainly the transmission of text, image, audio, video and other information. Among them, image as the most direct and convenient way of information transmission is widely used in the Internet and various fields. The widespread use of multimedia information has brought convenience to people to a certain extent, but also raised a series of problems. First, the circulation of a large amount of multimedia information brings security risks. For images, digital images containing a large amount of private information are obtained, tampered with and spread by unauthorized opponents. Image encryption as an effective means has been widely concerned. Second, the original data of multimedia information requires excessive storage space, and even the network cannot bear it. Therefore, under such background, the International Organization for Standardization has issued a series of multimedia compression standards, among which the most common lossy compression standard for images is JPEG (Joint Photographic Experts Group). Therefore, it is very important to study the high-security compressed format image encryption algorithm.
[0003] JPEG compression standard has been combined with encryption algorithm for many years. Considering the order of compression and encryption, JPEG image encryption is divided into three categories: encryption before compression, encryption within compression and encryption after compression. Among them, the encryption within compression which combines encryption and compression operation can be encrypted in the DCT (Discrete Cosine Transform) stage, quantization stage and entropy coding stage of JPEG compression standard. However, some existing JPEG image encryption methods belonging to encryption within compression lose compression performance at the cost of high security, or reduce security at the cost of better compression performance. Specifically, the existing JPEG image encryption methods have the following shortcomings:
[0004] (1) The JPEG image encryption method which only encrypts in the DCT stage and the quantization stage has good compression performance, but poor security;
[0005] (2) The JPEG image encryption method which changes the DCT transformation rule or the quantization table achieves high security, but due to the destruction of the correlation between adjacent pixels of the image in advance, the compression performance is seriously damaged;
[0006] (3) The encryption method of the JPEG image which adds the encryption step in the entropy coding stage will affect the coding and decoding process of the image, and in serious cases, it will cause the encrypted image to be unable to be normally read. In order to solve this problem, some data is often additionally added in the coding, but the compression performance is seriously affected.
[0007] Therefore, it is necessary to design a JPEG color image encryption method which can improve the encryption security while ensuring the compression performance. SUMMARY
[0008] In view of the problems existing in the prior art, the purpose of the present application is to provide a JPEG color image encryption method based on chaos theory, which belongs to compression-in encryption, and aims to ensure the compression performance while improving the encryption security.
[0009] The technical scheme of the present application is as follows:
[0010] A JPEG color image encryption method based on chaos theory, which comprises the following steps:
[0011] Step 1: obtaining a color plaintext image P to be encrypted, and generating a pseudo-random key sequence required in the encryption process through the plaintext image P and a Lorenz chaotic system;
[0012] Step 2: performing color space conversion on the color plaintext image P to obtain three components Y, Cb and Cr;
[0013] Step 3: dividing the Y component, the Cb component and the Cr component into image blocks with a size of 8x8;
[0014] Step 4: performing DCT transformation on each 8x8 image block in the Y component, the Cb component and the Cr component;
[0015] Step 5: performing scrambling operation on all 8x8 image blocks of the Y component, the Cb component and the Cr component after DCT transformation by means of the pseudo-random key sequence generated in step 1;
[0016] Step 6: performing quantization operation on all 8x8 image blocks of the three components after scrambling to generate two-dimensional matrices;
[0017] Step 7: converting each two-dimensional matrix into a one-dimensional array, and separating the DC coefficients and the AC coefficients of each two-dimensional matrix;
[0018] Step 8: performing exclusive OR operation on the DC coefficients in the three components by means of the pseudo-random key sequence generated in step 1;
[0019] Step 9: performing sign transformation on all non-zero AC coefficients;
[0020] Step 10: difference coding for DC coefficients and run-length coding for AC coefficients are converted into RSV pair form;
[0021] Step 11: reorganize the RSV pairs of three components respectively in the form of original 8x8 image block by using the pseudo-random key sequence generated in step 1;
[0022] Step 12: Huffman coding is performed on the DC coefficients and AC coefficients of three components respectively according to the Huffman coding table, so as to obtain the compressed and encrypted data stream;
[0023] Step 13: convert the compressed and encrypted data stream into an encrypted image.
[0024] Further, according to the JPEG color image encryption method based on chaos theory, the pseudo-random key sequence generation method in step 1 is: assuming that the obtained plaintext image P is an M-row N-column color image, taking P as input, generating a 256-bit random hash value H through a BLAKE-256 hash function, and converting H into 32 8-bit decimal forms: h1h2…h 32 Then use them to modify the initial values x0, y0, z0 of the Lorenz chaotic system, and the formula is as follows:
[0025]
[0026] Use the new initial values x'0, y'0, z'0 to iterate the Lorenz chaotic system for several times to generate three sequences, and then convert the values in the sequences into binary form to obtain the pseudo-random key sequences X, W, Z.
[0027] Further, according to the JPEG color image encryption method based on chaos theory, the scrambling operation method in step 5 is: first assume that the total number of 8x8 image blocks contained in the current component is n, and the number of bits obtained from the pseudo-random key sequence X for scrambling each image block is r, then the calculation formula is Next, number the 8x8 image blocks from left to right and from top to bottom, when the number of the current image block i≤n, obtain r bits from X and convert them into decimal, assign j to them, then exchange the ith 8x8 block and the jth 8x8 block, and finally remove the first r bits from X. Loop the above process until the nth image block is executed.
[0028] Further, according to the JPEG color image encryption method based on chaos theory, in step 7, each two-dimensional matrix is converted into a one-dimensional array through Zigzag coding.
[0029] Furthermore, according to the JPEG color image encryption method based on chaos theory, the XOR operation in step 8 is implemented using the pseudo-random key sequence W generated in step 1. This requires performing the following processes on the Y component, Cb component, and Cr component respectively: First, four binary digits are sequentially extracted from the pseudo-random key sequence W and converted to decimal to generate a new key sequence Wdc = {Wdc1, Wdc2, ..., Wdc...}. n}, where Wdc i represents the decimal number converted from the i-th group of four binary numbers in W, and n is the number of 8×8 image blocks contained in the current component; then, according to the order in which the DC coefficients appear after the block scrambling, the DC coefficients and the corresponding values in Wdc are XORed according to Equation (2);
[0030]
[0031] Where i = 1, 2, ..., n, dc i Let be the value of the i-th DC coefficient.
[0032] Furthermore, according to the JPEG color image encryption method based on chaos theory, in step 9, all non-zero AC coefficients are sign-transformed according to equation (3);
[0033] ac k = (-1)×ac k (3)
[0034] Where k is the index of the current non-zero AC coefficient, representing the k-th non-zero AC coefficient; ac k This is the current value of the AC coefficient.
[0035] Furthermore, according to the JPEG color image encryption method based on chaos theory, in step 11, image blocks with all AC coefficients equal to 0 are named zero-value blocks, and the RSV pairs of these image blocks only contain the EOB identifier (0, 0); image blocks with non-zero AC coefficients are named non-zero blocks, and these image blocks contain non-zero RSV pairs; then the recombination operation of the RSV pairs of the three components in units of the original 8×8 image blocks includes:
[0036] Step 11.1: Preprocess the pseudo-random key sequence Z;
[0037] Each time, five binary digits are taken from Z and converted to decimal, for a total of... Groups, forming new sequences Where n is the number of image patches contained in the current component;
[0038] Step 11.2: Remove the EOB identifier of all non-zero blocks, and divide all image blocks: if the total number of image blocks n is even, divide all image blocks into two parts equally, and mark the two parts as B1 and B2; if the total number of image blocks n is odd, first put the last image block into a third part B3, and then divide the remaining n-1 image blocks into two parts equally, and mark the two parts as B1 and B2;
[0039] Step 11.3: Connect the RSV pairs of the corresponding two image blocks in B1 and B2 respectively, and perform cyclic shift, and then re-allocate to the two image blocks;
[0040] Step 11.4: If the number of image blocks n is odd, then process the image block temporarily stored in B3 separately: if the image block is a zero-value block, keep the original value unchanged; if the image block is a non-zero block, perform cyclic shift on all RSV pairs in the block according to the same method as step 11.3;
[0041] Step 11.5: Add an EOB identifier to the recombined non-zero block.
[0042] Further, according to the JPEG color image encryption method based on chaos theory, the method of cyclic shift in step 11.3 is:
[0043] According to the order of the image block labels, take one image block from B1 as the first image block, and take one image block from B2 as the second image block, and make the following judgments:
[0044] (1) If both image blocks are zero-value blocks, keep the original values unchanged;
[0045] (2) If one of the two image blocks is a zero-value block and the other is a non-zero block, exchange the positions of the two image blocks, and then perform right cyclic shift on all RSV pairs of the new non-zero block, and the displacement of the cyclic shift is controlled by the value of the corresponding subscript in the sequence Zac, and the label of the first image block is the subscript of the required Zac;
[0046] (3) If both image blocks are non-zero blocks, first record the number of RSV pairs in the first image block, denoted as m, and the number of RSV pairs in the second image block, denoted as d, then connect all the RSV pairs of the two image blocks together and perform a cyclic shift, and the rule of the cyclic shift is the same as that in (2); then re-allocate the RSV pairs to the two image blocks, and since there are only 63 AC coefficients in each image block, attention should be paid to the problem that the number of AC coefficients in the image blocks exceeds the upper limit 63 when re-allocating, therefore, a value T is set to record the difference between the number of RSV pairs newly allocated to the first block and m, and the initial value of T is 0; the re-allocation rule is as follows: first, allocate the first m RSV pairs to the first image block, and the last d RSV pairs to the second image block, if the number of AC coefficients in both image blocks does not exceed the upper limit, then directly allocate; if the number of AC coefficients in the first image block exceeds the upper limit, then reduce the number of RSV pairs allocated to the first image block, in the order of m-1, m-2,..., until the number of AC coefficients in the first image block does not exceed the upper limit, assuming that the number of RSV pairs allocated to the first image block at this time is p, then the value of T at this time is p-m; if the number of AC coefficients in the second image block exceeds the upper limit, then reduce the number of RSV pairs allocated to the second image block, in the order of d-1, d-2,..., until the number of AC coefficients in the second image block does not exceed the upper limit, assuming that the number of RSV pairs allocated to the first image block at this time is p, then the value of T at this time is p-m; convert T into the form of RSV pairs as well, and the correspondence between the value of T and the RSV pairs is in accordance with the order of the variable-length integer coding table in the JPEG compression principle; finally, add the RSV pairs corresponding to T to the end of the first image block;
[0047] Repeat the above process until all image blocks in B1 and B2 complete the above process.
[0048] Compared with the prior art, the technical scheme provided by the present application has the following beneficial effects:
[0049] (1) In the JPEG compression principle, both the DCT transformation stage and the quantization stage are in units of image blocks, and if the pixel distribution within the image block is destroyed before the quantization stage, the compression performance will be severely lost. Therefore, the present method proposes block scrambling in the DCT transformation stage, which only scrambles in units of image blocks and does not affect the compression performance.
[0050] (2) XOR operation between the DC (Direct Current) coefficient and the pseudo-random key sequence can not only effectively protect the value of the DC coefficient and improve the encryption security, but also has simple operation and can reduce the encryption time.
[0051] (3) The non-zero AC (Alternating Current) coefficients are sign transformed, which does not change the distribution relationship between the zero-value AC coefficients and the non-zero-value AC coefficients, does not affect the entropy coding, and thus does not lose compression performance.
[0052] (4) The RSV (Run Size Value) is proposed for recombination in the entropy coding stage, which effectively reduces the correlation between adjacent pixels, and thus improves the encryption security, and does not add too much data compared with the existing scheme, and effectively reduces the influence on the compression performance. BRIEF DESCRIPTION OF DRAWINGS
[0053] In order to more clearly illustrate the specific ways in the embodiments of the present application, the related drawings involved in the embodiments will be briefly described below, and the following drawings are only preferred embodiments of the present application, and other drawings can be obtained according to these drawings without creative changes for those skilled in the art.
[0054] Figure 1 The flowchart of the JPEG color image encryption method based on chaos theory in the present embodiment;
[0055] Figure 2 The process example diagram of the RSV recombination in the present embodiment;
[0056] Figure 3 The test encryption and decryption effect diagram of the present embodiment, wherein (a) is the plaintext image of the house image House; (b) is the encrypted image of the house image House; (c) is the decrypted image of the house image House; (d) is the plaintext image of the mandrill image Mandrill; (e) is the encrypted image of the mandrill image Mandrill; (f) is the decrypted image of the mandrill image Mandrill; (g) is the plaintext image of the satellite image Aerial; (h) is the encrypted image of the satellite image Aerial; (i) is the decrypted image of the satellite image Aerial;
[0057] Figure 4 The key sensitivity analysis test diagram of the present embodiment, wherein (a) is the decrypted image obtained by using the correct key for decryption; (b) is the decrypted image obtained by using the slightly modified key for decryption;
[0058] Figure 5The adjacent pixel distribution diagram of the Mandrill plaintext image and the encrypted image of the present embodiment, wherein (a) is the plaintext image of the Mandrill image; (b) is the adjacent pixel distribution diagram of (a) on the R channel; (c) is the adjacent pixel distribution diagram of (a) on the G channel; (d) is the adjacent pixel distribution diagram of (a) on the B channel; (e) is the encrypted image of the Mandrill image; (f) is the adjacent pixel distribution diagram of (e) on the R channel; (g) is the adjacent pixel distribution diagram of (e) on the G channel; and (h) is the adjacent pixel distribution diagram of (e) on the B channel. DETAILED DESCRIPTION
[0059] For the purpose of facilitating the understanding of the present application, the present application will be described in more detail below with reference to the relevant drawings. The drawings show the preferred embodiments of the present application. However, the present application can be realized in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive.
[0060] Figure 1 is a flowchart of the JPEG color image encryption method based on chaos theory of the present embodiment, which comprises the following steps:
[0061] Step 1: obtaining a color plaintext image P to be encrypted, and generating a pseudo-random key sequence required in the encryption process by using the plaintext image P, a hash function and a Lorenz chaotic system;
[0062] In the present embodiment, a plaintext image P to be encrypted is obtained, and it is assumed that P is a color image with M rows and N columns. By taking P as the input, a 256-bit random hash value H is generated by a BLAKE-256 hash function, and H is converted into 32 8-bit decimal forms: h1h2…h 32 Then, the initial values x0, y0, z0 of the Lorenz chaotic system are modified by using them, and the formula is as follows:
[0063]
[0064] The Lorenz chaotic system is iterated 10000 times by using the new initial values x'0, y'0, z'0, three sequences are generated, and the values in the sequences are converted into binary form to obtain the pseudo-random key sequences X, W and Z, which are used to control the subsequent encryption process.
[0065] Step 2: performing color space conversion on the color plaintext image P to obtain three components Y, Cb and Cr;
[0066] According to the JPEG compression principle, if the plaintext image is a color image, first, color space conversion is performed to convert the RGB color space into YCbCr (Y refers to the luminance component, Cb refers to the blue chrominance component, and Cr refers to the red chrominance component) color space, and the Y space, Cb space, and Cr space are separated, so that a color image is converted into Y component, Cb component, and Cr component.
[0067] Step 3: The Y component, Cb component, and Cr component are each divided into image blocks with a size of 8x8;
[0068] According to the JPEG compression principle, the image needs to be divided into image blocks with a pixel size of 8x8, and these image blocks are processed individually throughout the compression process.
[0069] Step 4: DCT transformation is performed on each 8x8 image block in the Y component, Cb component, and Cr component;
[0070] According to the JPEG compression principle, the image needs to be converted to the frequency domain range through DCT to remove high-frequency components in the image and obtain a higher compression ratio. After DCT transformation, each 8x8 image block becomes an 8x8 floating-point matrix, where the first data is the direct current data DC, and the following 63 data are alternating current data AC.
[0071] Step 5: The pseudo-random key sequence generated in step 1 is used to perform a scrambling operation on all 8x8 image blocks in the Y component, Cb component, and Cr component after DCT transformation;
[0072] After DCT transformation, the first step of image encryption in this embodiment is block scrambling, which is achieved with the pseudo-random key sequence X generated in step 1. The following specific process of block scrambling is performed on the Y component, Cb component, and Cr component respectively.
[0073] First, assume that the total number of 8x8 image blocks contained in the current component is n, and the number of bits required to be obtained from the pseudo-random key sequence X for scrambling each image block is r, then the calculation formula is Next, the 8x8 image blocks are numbered from left to right and from top to bottom. When the number of the current image block i≤n, r bits are obtained from X and converted to decimal, and j is assigned, then the ith 8x8 block and the jth 8x8 block are exchanged, and finally the first r bits are removed from X. The above process is executed in a loop until the nth image block has executed the above process.
[0074] Step 6: Quantization operation is performed on all 8x8 image blocks of the three components after scrambling to generate a two-dimensional matrix;
[0075] In this implementation, quantization is the result of dividing the pixel value by the corresponding value in the quantization table. The JPEG compression principle provides two standard quantization tables, used to process the luminance component Y and the chrominance components Cb and Cr, respectively. After quantization, each 8×8 floating-point matrix is converted into a two-dimensional integer matrix.
[0076] Step 7: Convert each two-dimensional matrix into a one-dimensional array using Zigzag encoding, and separate the DC coefficients and AC coefficients of each two-dimensional matrix;
[0077] After quantization, 0 is more likely to appear in the lower right corner of the two-dimensional matrix. Therefore, in order to make more 0 appear consecutively, this implementation adopts Zigzag encoding. The two-dimensional matrix is converted into a one-dimensional array in the order from the upper left corner to the lower right corner. The first data in each one-dimensional array is the DC coefficient, and the remaining 63 data are the AC coefficients.
[0078] Step 8: Using the pseudo-random key sequence generated in Step 1, perform an XOR operation on the DC coefficients of the three components respectively;
[0079] The XOR operation is implemented using the pseudo-random key sequence W generated in step 1. The following processes are required for the Y, Cb, and Cr components respectively. First, four binary digits are sequentially extracted from the pseudo-random key sequence W and converted to decimal to generate a new key sequence Wdc = {Wdc1, Wdc2, ..., Wdc...}. n}, where Wdc i This represents the decimal number converted from the i-th group of four binary digits in W. n has the same meaning as n in step 5, representing the number of 8×8 image blocks contained in the current component. Then, the DC coefficients are XORed with their corresponding values in Wdc according to the order in which they appear after block scrambling. The specific calculation formula is as follows:
[0080]
[0081] Where i = 1, 2, ..., n, dc i Let be the value of the i-th DC coefficient.
[0082] Step 9: Perform sign transformation on all non-zero AC coefficients;
[0083] Because the AC coefficients contain many zero values, and to avoid affecting the compression ratio of JPEG, this operation is performed on non-zero AC coefficients. The specific calculation formula is as follows:
[0084] ac k = (-1)×ac k (3)
[0085] where k is the index of the current non-zero AC coefficient, representing the current kth non-zero AC coefficient; ac k is the value of the current AC coefficient.
[0086] Step 10: difference coding for DC coefficients and run length coding for AC coefficients are converted into the form of RSV pairs;
[0087] According to the JPEG compression principle, the DC is subjected to DPCM (Differential Pulse Code Modulation), that is, the difference between each DC value and the previous DC value in the same image component is coded. The AC coefficients are subjected to RLC (Run Length Coding), in which the repeated consecutive characters in a string are replaced by two bytes, converted into the form of RSV pairs.
[0088] Step 11: using the pseudo-random key sequence generated in step 1, the RSV pairs of the three components are reorganized in the original 8x8 image block as the unit;
[0089] The RSV pair reorganization is controlled by the pseudo-random key sequence Z generated in step 1, and the following processes are required for the Y component, the Cb component and the Cr component. In order to better describe this step, first make the following definitions: the image block whose AC coefficients are all 0 is called zero-value block, that is, the RSV pair of the image block only has the EOB (End-of-block) identifier (0, 0); the image block whose AC coefficients are non-zero is called non-zero block, that is, the image block contains non-zero RSV pairs. Figure 2 The following are the specific steps of the RSV pair reorganization process in this embodiment:
[0090] Step 11.1: pre-processing the pseudo-random key sequence Z;
[0091] Each time five binary numbers are taken out from Z and converted into decimal numbers, a total of n-4 decimal numbers are obtained. The n-4 decimal numbers are divided into n-4 groups, and the n-4 groups are combined to form a new sequence where n is the number of image blocks contained in the current component, which has the same meaning as in step 5.
[0092] Step 11.2: removing the EOB identifier of all non-zero blocks, and dividing all image blocks: if the total number of image blocks n is even, all image blocks are evenly divided into two parts, which are marked as B1 and B2; if the total number of image blocks n is odd, all image blocks are divided into three parts, which are marked as B1, B2 and B3;
[0093] Firstly, remove the EOB identifier of all non-zero blocks. Then label all image blocks in the order from left to right and from top to bottom. If the total number of image blocks n is even, divide all image blocks into two parts averagely, the first n / 2 image blocks are placed in the first part B1 and the last n / 2 image blocks are placed in the second part B2; if the total number of image blocks n is odd, place the last image block in the third part B3, then process the rest n-1 image blocks, divide the rest n-1 image blocks into two parts averagely, the first (n-1) / 2 image blocks are placed in the first part B1 and the last (n-1) / 2 image blocks are placed in the second part B2.
[0094] Step 11.3: connect the RSV pairs of the corresponding two image blocks in B1 and B2 together and perform cyclic shift, then re-allocate to the two image blocks;
[0095] According to the label order of image blocks, take one image block from B1 as the first image block and take one image block from B2 as the second image block, and make the following judgment:
[0096] (1) If both of the two image blocks are zero value blocks, keep the original value unchanged;
[0097] (2) If one of the two image blocks is a zero value block and the other is a non-zero block, exchange the positions of the two image blocks, then perform cyclic shift on all RSV pairs of the new non-zero block, the cyclic shift adopted in this embodiment is right cyclic shift, the displacement of the cyclic shift is controlled by the value of the corresponding subscript in sequence Zac, the label of the first image block is the subscript of Zac needed.
[0098] (3) If both image blocks are non-zero blocks, first record the number of RSV pairs in the first image block, denoted as m, and the number of RSV pairs in the second image block, denoted as d, then concatenate all the RSV pairs of the two image blocks and perform a circular shift, the rule of which is the same as (2). Then re-allocate the RSV pairs to the two image blocks. Since there are only 63 AC coefficients in each image block, attention should be paid to the problem that the number of AC coefficients exceeds the upper limit 63 when re-allocating. Therefore, a value T is set to record the difference between the number of RSV pairs newly allocated to the first block and m, and the initial value of T is 0. The re-allocation rule is as follows: first, allocate the first m RSV pairs to the first image block, and the last d RSV pairs to the second image block. If the number of AC coefficients in both image blocks does not exceed the upper limit, directly allocate; if the number of AC coefficients in the first image block exceeds the upper limit, reduce the number of RSV pairs allocated to the first image block in the order of m-1, m-2,..., until the number of AC coefficients in the first image block does not exceed the upper limit. Suppose that the number of RSV pairs allocated to the first image block at this time is p, then the value of T at this time is p-m; if the number of AC coefficients in the second image block exceeds the upper limit, reduce the number of RSV pairs allocated to the second image block in the order of d-1, d-2,..., until the number of AC coefficients in the second image block does not exceed the upper limit. Suppose that the number of RSV pairs allocated to the first image block at this time is p, then the value of T at this time is p-m. Convert T into the form of RSV pairs, and the correspondence between the value of T and the RSV pairs is according to the order of the variable-length integer coding table in the JPEG compression principle. Finally, add the RSV pairs corresponding to T to the end of the first image block.
[0099] Repeat the above process until all image blocks in B1 and B2 complete the above process.
[0100] Step 11.4: If the number of image blocks n is odd, then process the image block temporarily stored in B3 separately;
[0101] If the image block is a zero-value block, keep the original value unchanged; if the image block is a non-zero block, perform a circular shift on all RSV pairs in the block, and the rule of the circular shift is the same as (2) in step 11.3.
[0102] Step 11.5: Add EOB identifiers to the reorganized non-zero blocks;
[0103] If the number of AC coefficients contained in the non-zero block does not reach the upper limit value, add an EOB identifier (0, 0) at the end of the block; if the number of AC coefficients contained in the non-zero block just reaches the upper limit value, do not add an additional EOB identifier.
[0104] Step 12: Huffman coding is performed on the DC coefficients and AC coefficients of the three components respectively according to the Huffman coding table, so as to obtain the compressed encrypted data stream;
[0105] The last step of JPEG compression is to perform Huffman coding on the data, and the basic principle is to adjust the coding length of the elements in the data according to the frequency of use of the elements, so as to obtain higher compression ratio. The principle of JPEG compression provides four Huffman coding tables, different Huffman coding tables are used for DC coefficients and AC coefficients, and different Huffman coding tables are used for luminance component Y and chrominance components Cb and Cr. After Huffman coding, the compressed encrypted data stream is obtained.
[0106] Step 13: converting the compressed encrypted data stream into an encrypted image E;
[0107] The compressed encrypted data stream is converted into an encrypted image E according to the format of the JPEG file, and the encrypted image E is output.
[0108] In order not to lose generality, the present embodiment uses color images of various specifications for image encryption and decryption, including house image House (256x256), mandrill image Mandrill (512x512), and satellite image Aerial (1024x1024). The encryption and decryption effects of the images are shown in Figure 3 It can be seen from Figure 3 that the encrypted image does not identify any plaintext information, and the correct plaintext image can be obtained after decryption.
[0109] In order to evaluate the effectiveness of the method of the present application, the present embodiment uses Figure 3 three images for performance evaluation. The specific content of the performance evaluation is as follows.
[0110] Figure 4 For the key sensitivity analysis test image of the present embodiment, the correct key key (x0=-16, y0=-21, z0=33) and the slightly different key key1 (x0=-16.00000000000001, y0=-21, z0=33) are used to decrypt the encrypted image of the mandrill image Mandrill respectively. It can be found that even if the encryption and decryption keys are slightly different, the correct decrypted image cannot be obtained.
[0111] Table 1 NPCR and UACI detection results of the present embodiment
[0112]
[0113] The ideal values of NPCR and UACI are 99.6094% and 33.4635% respectively, and the closer the calculated results of NPCR and UACI of a method are to the ideal values, the stronger the ability of the method to resist differential attacks. As can be seen from Table 1, the encryption method proposed in the present application has a certain degree of defense capability against differential attacks.
[0114] Table 2: Adjacent pixel correlation
[0115] Image Horizontal Vertical Diagonal House 0.4581 0.1199 0.1013 Mandrill 0.0797 0.0376 0.0165 Aerial 0.3573 0.1488 0.1190
[0116] Generally, the adjacent pixel correlation of a plaintext image is close to 1, and the adjacent pixel correlation of an encrypted image should be close to 0. As can be seen from Table 2, the adjacent pixel correlation of the encrypted image obtained by the present embodiment is low, further proving that the present embodiment has good diffusion effect.
[0117] In order to more clearly and intuitively see the distribution of adjacent pixels of an image, the present embodiment takes the Mandrill plaintext image and the encrypted image obtained by the encryption method as examples, and randomly selects 5000 pairs of adjacent pixels on the R, G and B channels respectively to draw the adjacent pixel correlation diagram, as shown in Figure 5 As can be seen from Figure 5 , the distribution of the 5000 pairs of adjacent pixels in the R, G and B channels of the encrypted image is relatively uniform, which shows that the present embodiment effectively reduces the adjacent pixel correlation of the image and improves the encryption security.
[0118] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that; it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement to part or all of the technical features; thus, these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope defined by the claims of the present application.
Claims
1. A JPEG color image encryption method based on chaos theory, characterized in that, The method includes the following steps: Step 1: Obtain a color plaintext image P to be encrypted, and generate the pseudo-random key sequence required for the encryption process using the plaintext image P and the Lorenz chaotic system; Step 2: Perform color space conversion on the color plaintext image P to obtain three components Y, Cb and Cr; Step 3: Divide the Y component, Cb component, and Cr component into image blocks of size 8×8; Step 4: Perform DCT transformation on each 8×8 image block in the Y component, Cb component, and Cr component; Step 5: Using the pseudo-random key sequence generated in Step 1, scramble all 8×8 image blocks in the Y, Cb, and Cr components after DCT transformation. Step 6: Perform quantization operations on all 8×8 image blocks of the scrambled three components to generate a two-dimensional matrix; Step 7: Convert each two-dimensional matrix into a one-dimensional array and separate the DC coefficients and AC coefficients of each two-dimensional matrix; Step 8: Using the pseudo-random key sequence generated in Step 1, perform an XOR operation on the DC coefficients of the three components respectively; Step 9: Perform sign transformation on all non-zero AC coefficients; Step 10: Perform differential encoding on the DC coefficients and run-length encoding on the AC coefficients to convert them into RSV pairs; Step 11: Using the pseudo-random key sequence generated in Step 1, reassemble the RSV pairs of the three components in units of the original 8×8 image blocks. Step 12: Perform Huffman coding on the DC and AC coefficients of the three components according to the Huffman coding table to obtain the compressed encrypted data stream; Step 13: Convert the compressed encrypted data stream into an encrypted image; The pseudo-random key sequence generation method described in step 1 is as follows: Assuming the acquired plaintext image P is an M-row N-column color image, P is used as input, and a 256-bit random hash value H is generated through the BLAKE-256 hash function. H is then converted into 32 8-bit decimal numbers: h1h2…h 32 Then, these are used to modify the initial values x0, y0, and z0 of the Lorenz chaotic system, as shown in the following formula: Use the new initial value x ' 0, y ' 0, z ' The Lorenz chaotic system is iterated several times to generate three sequences. The values in the sequences are then converted into binary form to obtain pseudo-random key sequences X, W, and Z. The XOR operation described in step 8 is implemented using the pseudo-random key sequence W generated in step 1. This requires performing the following processes on the Y, Cb, and Cr components respectively: First, extract four binary digits sequentially from the pseudo-random key sequence W and convert them to decimal to generate a new key sequence Wdc = {Wdc1, Wdc2, ..., Wdc...}. n }, where Wdc i represents the decimal number converted from the i-th group of four binary numbers in W, and n is the number of 8×8 image blocks contained in the current component; then, according to the order in which the DC coefficients appear after the block scrambling, the DC coefficients and the corresponding values in Wdc are XORed according to Equation (2); Where i = 1, 2, ..., n, dc i Let be the value of the i-th DC coefficient.
2. The JPEG color image encryption method based on chaos theory according to claim 1, characterized in that, The scrambling operation method described in step 5 is as follows: First, assume that the total number of 8×8 image blocks contained in the current component is n, and the number of bits required to scramble each image block from the pseudo-random key sequence X is r. The calculation formula is: Next, number the 8×8 image blocks sequentially from left to right and from top to bottom. When the current image block number i≤n, obtain r bits from X and convert them to decimal, assign them to j, then swap the i-th 8×8 block and the j-th 8×8 block, and finally remove the first r bits from X. Repeat the above process until the n-th image block has completed the above process.
3. The JPEG color image encryption method based on chaos theory according to claim 1, characterized in that, In step 7, each two-dimensional matrix is converted into a one-dimensional array using Zigzag encoding.
4. The JPEG color image encryption method based on chaos theory according to claim 1, characterized in that, In step 9, the sign of all non-zero AC coefficients is transformed according to equation (3); and k =(-1)×ac k (3) Where k is the index of the current non-zero AC coefficient, representing the k-th non-zero AC coefficient; ac k This is the current value of the AC coefficient.
5. The JPEG color image encryption method based on chaos theory according to claim 1, characterized in that, In step 11, image blocks with all AC coefficients equal to 0 are named zero-value blocks, and the RSV pairs of these blocks only contain the EOB identifier (0,0); image blocks with non-zero AC coefficients are named non-zero blocks, and these blocks contain non-zero RSV pairs; the recombination operation of the RSV pairs of the three components in units of the original 8×8 image blocks includes: Step 11.1: Preprocess the pseudo-random key sequence Z; Each time, five binary digits are taken from Z and converted to decimal, for a total of... Groups, forming new sequences Where n is the number of image patches contained in the current component; Step 11.2: Remove the EOB identifiers from all non-zero blocks and divide all image blocks: If the total number of image blocks n is even, divide all image blocks into two equal parts and label them B1 and B2; if the total number of image blocks n is odd, first place the last image block in the third part B3, and then divide the remaining n-1 image blocks into two equal parts and label them B1 and B2. Step 11.3: Connect the RSV pairs of the two corresponding image blocks in B1 and B2 together, perform a cyclic shift, and then redistribute them to the two image blocks; Step 11.4: If the number of image blocks n is odd, then process the image blocks temporarily stored in B3 separately: if the image block is a zero-value block, keep the original value unchanged; if the image block is a non-zero block, then perform a cyclic shift on all RSV pairs in the block in the same way as in Step 11.
3. Step 11.5: Add an EOB identifier to the recombined non-zero blocks.
6. The JPEG color image encryption method based on chaos theory according to claim 5, characterized in that, The cyclic shift method described in step 11.3 is as follows: Based on the image block numbering order, take an image block from B1 and designate it as the first image block, and take an image block from B2 and designate it as the second image block. Then, make the following judgment: (1) If both image patches are zero-value patches, then keep the original values unchanged; (2) If one of the two image blocks is a zero value block and the other is a non-zero block, then the two image blocks are swapped, and then all RSV pairs of the new non-zero block are cyclically shifted to the right. The displacement of the cyclic shift is controlled by the value of the corresponding index in the sequence Zac. The label of the first image block is the index of the required Zac. (3) If both image blocks are non-zero blocks, first record the number of RSV pairs in the first image block, denoted as m, and the number of RSV pairs in the second image block, denoted as d. Then connect all RSV pairs of the two image blocks together and perform a circular shift. The circular shift rule is the same as (2). Then redistribute these RSV pairs to the two image blocks. Since there are only 63 AC coefficients in each image block, when redistributing, we need to pay attention to the problem that the number of AC coefficients of the image block exceeds the upper limit of 63. Therefore, we set a value T to record the difference between the number of RSV pairs newly assigned to the first block and m. The initial value of T is 0. The redistribution rules are as follows: First, allocate the first m RSV pairs to the first image block, and the last d RSV pairs to the second image block. If the number of AC coefficients in both image blocks does not exceed the upper limit, then the redistribution proceeds directly. If the number of AC coefficients in the first image block exceeds the upper limit, then reduce the number of RSV pairs allocated to the first image block, decreasing in the order of m-1, m-2, ... until the number of AC coefficients in the first image block does not exceed the upper limit. Assuming the number of RSV pairs allocated to the first image block is p, then the value of T at this point is pm. If the number of AC coefficients in the second image block exceeds the upper limit... If the upper limit is exceeded, the number of RSV pairs allocated to the second image block is reduced, decreasing in the order of d-1, d-2, ... until the number of AC coefficients in the second image block does not exceed the upper limit. Assuming the number of RSV pairs allocated to the first image block is p, then the value of T is pm. T is also converted into RSV pairs, and the correspondence between the value of T and the RSV pairs is determined according to the order of the variable-length integer encoding table in the JPEG compression principle. Finally, the RSV pair corresponding to T is added to the end of the first image block. The above process is repeated until all image blocks in B1 and B2 have completed the above process.
Citation Information
Patent Citations
JPEG (Joint Photographic Experts Group) image high-precision reservation thumbnail encryption method
CN115630390A