Image scrambling method based on binary bidirectional zigzag transformation
By using an image scrambling method based on binary bidirectional zigzag transform to change the position of all pixels in an image, the problem of insufficient image information security in traditional zigzag scrambling methods is solved, achieving higher security and resistance to attacks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-24
- Publication Date
- 2026-03-20
AI Technical Summary
Traditional zigzag scrambling methods cannot change the positions of the first and last pixels of an image, resulting in insufficient security of image information.
An image scrambling method based on binary bidirectional zigzag transform is adopted. The grayscale image is converted into a binary matrix, sorted according to the number of 1s, and then bidirectionally zigzag scrambled to generate a decimal matrix, thereby changing the position of all pixels.
It effectively changes the position of all pixels in the image, enhances image security, reduces the correlation between adjacent pixels, and strengthens resistance to statistical attacks.
Smart Images

Figure CN116599649B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image scrambling, and particularly relates to an image scrambling method based on binary bidirectional zigzag transformation. BACKGROUND
[0002] The rapid popularity of the Internet has become an important symbol of the information age. Nowadays, anyone can publish any information at any location, and the dissemination of digital images has become more widespread, and the image information security problem has also become more concerned. In order to ensure the security of the image, image encryption technology can be used to encrypt and decrypt the sending end and the receiving end of the image, and the encryption technology based on spatial domain scrambling is a relatively mature encryption technology, and the operation is simple and the effect is good, which is widely used in image encryption processing. The scrambling of the image is to make the originally meaningful image into a chaotic image according to a certain rule, and hide the original information, so that the image is encrypted and protected, and even if the image is acquired by others, without the key, anyone cannot obtain any information of the image, thereby greatly enhancing the security of the image.
[0003] The zigzag transformation-based scrambling is a relatively traditional scrambling algorithm, and is also widely applied. The following will introduce the traditional zigzag scrambling method.
[0004] The traditional zigzag scrambling refers to scanning from the first coordinate of the image in a zigzag line, until all the pixel points are scanned, then arranging the pixels in a one-dimensional sequence according to the scanning order, and then restoring the one-dimensional sequence into a two-dimensional image matrix according to a certain order, so that the image pixel coordinates are scrambled, and the effect of encrypting the image is achieved. However, this scrambling method cannot change the positions of the first and last pixel points of the image, thereby it is difficult to guarantee the security of the image information. SUMMARY
[0005] The present application provides an image scrambling method based on binary bidirectional zigzag transformation, and the scrambling algorithm comprises the following steps:
[0006] (1) reading in a gray-scale image with a size of N*N, converting the value of each pixel point of the gray-scale image from decimal to binary, that is, converting an original decimal matrix I into eight binary matrices I1, I2…I8;
[0007] (2) sorting the eight binary matrices according to the number of 1 contained in each matrix, taking the one containing the most 1 as the first matrix plane, and taking the one containing the least 1 as the last binary plane, and the method is as shown in the following formula:
[0008] b i =sum(Ii = 1), i = 1, 2...8 (1.1)
[0009] a = [b1, b2,... b8] (1.2)
[0010] c = sort(a, 'descend') (1.3)
[0011] cell = [I1, I2,... I8] (1.4)
[0012] cell' = cell(:, c) (1.5)
[0013] where, b i represents the number of 1 in I i , a represents the set of b i , formula (1.3) represents sorting a in descending order, c represents the obtained order, cell is the set of I i , cell' is the new binary matrix set of cell obtained according to the order of c;
[0014] (3) After sorting the binary matrix, it is I'1, I'2,... I'8, I'1 and I'8 are a group, I'2 and I'7 are a group, I'3 and I'6 are a group, I'4 and I'5 are a group, every two groups are zigzag scrambled, taking the first group as an example, starting from the point of I'1, scanning according to the zigzag shape from the center point to the top left corner, and then to the (1, 1) point of I'8, scanning according to the zigzag shape from the top left corner to the center point, until the point of I'8 ends, and a one-dimensional sequence d1 is obtained according to the scanning order, and then starting from the point of I'1, scanning according to the zigzag shape from the center point to the top right corner, and then to the (N, N) point of I'8, scanning according to the zigzag shape from the bottom right corner to the center point, until the point of I'8 ends, and a one-dimensional sequence d2 is obtained according to the scanning order, and each group is scanned according to this rule to obtain the final eight one-dimensional sequences, which are d1, d2... d8 respectively;
[0015] (4) Arrange the eight one-dimensional sequences into an 8xN binary matrix, and then arrange it into a one-dimensional binary sequence of 1x8N 2 in column priority order;
[0016] (5) Uniformly divide the one-dimensional binary sequence in (4) into 8 segments, each with i = N 2 , respectively e1, e2... e8, and generate a decimal sequence according to formula (1.6):
[0017] y(i) = e1(i)*27 +e2(i)*2 6 +…+e8(i)*2 0 (1.6)
[0018] Wherein, y represents the decimal sequence, finally, y is rearranged into N*N two-dimensional decimal matrix x according to column priority, and the matrix is the scrambled image matrix. All the above steps are reversible operations, and the decryption image restoration process is the inverse operation of the above process, so that the decrypted image can be obtained.
[0019] As preferred, the application can change the positions of all pixel points of the image, thereby guaranteeing the security of image encryption.
[0020] As preferred, the application combines the gray scale transformation and the position transformation, and proposes to scramble the image from the binary plane, thereby increasing the information entropy of the scrambled image and enhancing the image anti-statistical attack ability.
[0021] As preferred, the application zigzag scans the image from two directions, thereby greatly reducing the correlation between adjacent pixels of the image.
[0022] The application combines the gray scale transformation and the position transformation, and proposes an image scrambling method based on binary bidirectional zigzag transformation. The experimental results and method analysis show that the application has achieved good results in visual effect, scrambling degree and anti-attack ability. BRIEF DESCRIPTION OF DRAWINGS
[0023] The application will be further described in detail below in combination with the drawings and embodiments:
[0024] Figure 1 It is a scrambling schematic diagram of the image scrambling method based on binary bidirectional zigzag transformation.
[0025] Figure 2 It is a plaintext image of the image scrambling method based on binary bidirectional zigzag transformation.
[0026] Figure 3 It is a scrambled image and a decrypted image of the image scrambling method based on binary bidirectional zigzag transformation.
[0027] Figure 4 It is a correlation analysis diagram of the image scrambling method based on binary bidirectional zigzag transformation before and after image scrambling, wherein (a), (b) and (c) are respectively the horizontal direction, vertical direction and diagonal direction pixel distribution of the image before scrambling, (d), (e) and (f) are respectively the horizontal direction, vertical direction and diagonal direction pixel distribution of the image after scrambling.
[0028] Figure 5The decrypted image after adding noise to the scrambled image of a scrambling method based on binary bidirectional zigzag transformation, (a), (b) and (c) are the decrypted images after adding salt noise of 0.05, 0.1 and 0.2 respectively;
[0029] Figure 6 The decrypted image after cutting the scrambled image of a scrambling method based on binary bidirectional zigzag transformation, (a), (b) and (c) are the decrypted images after cutting 1 / 64, 1 / 16 and 1 / 8 respectively; DETAILED DESCRIPTION
[0030] The application will be further described in detail below in combination with the implementation examples, and the specific steps are as follows:
[0031] The application takes a "House" gray image with a size of 256*256 (unit: pixel) as an example, that is, a plaintext image, and the scrambling process is as follows:
[0032] (1) read in a gray image with a size of N*N, convert each pixel point value of the gray image from decimal to binary, that is, convert an original decimal matrix I into eight binary matrices I1, I2…I8;
[0033] (2) sort the eight binary matrices according to the number of 1 contained in each matrix, and take the one containing the most 1 as the first matrix plane, and the one containing the least 1 as the last binary plane;
[0034] (3) after sorting the binary matrices, I'1, I'2, …I'8, I'1 and I'8 are a group, I'2 and I'7 are a group, I'3 and I'6 are a group, and I'4 and I'5 are a group, each two groups are zigzag scrambled, and the first group is taken as an example, starting from the point of I'1, scanning according to the zigzag shape from the center point to the upper left corner, and then to the point of I'8, scanning according to the zigzag shape from the upper left corner to the center point, until the point of I'8, and according to the scanning order, a one-dimensional sequence d1 is obtained, and then starting from the point of I'1, scanning according to the zigzag shape from the center point to the upper right corner, and then to the (N, N) point of I'8, scanning according to the zigzag shape from the lower right corner to the center point, until the
[0035] (4) arrange the eight one-dimensional sequences into an 8*N binary matrix, and then arrange it into a one-dimensional binary sequence of 1*8N 2 according to the column-first order;
[0036] (5) Divide the one-dimensional binary sequence in (4) into 8 segments, with each segment containing i = N segments. 2 Let the values be e1, e2, ..., e8, and let y(i) = e1(i) * 2. 7 +e2(i)*2 6 +…+e8(i)*2 0 Generate a decimal sequence, where y represents the decimal sequence. Finally, rearrange y in column-major order to form an N×N two-dimensional decimal matrix x, which is the scrambled image matrix. All the above steps are reversible operations, and the encrypted image restoration process is the inverse operation of the above process, thus obtaining the decrypted image.
[0037] To verify that the present invention has excellent image scrambling capabilities, the effectiveness of the proposed invention will be tested from aspects such as scrambled image effect diagrams, correlation between adjacent pixels, and robustness tests.
[0038] 1. Image scrambled effect diagram
[0039] Plaintext images that need to be transmitted often convey a lot of image information. However, scrambled images appear as white noise. When an attacker tries to obtain the image information, they can only obtain the white noise and cannot determine what image information was being transmitted. This effectively protects the transmitted image information. Therefore, for a qualified scrambling algorithm, the primary goal is to encrypt a white noise image. Figure 3 It can be seen that the present invention meets the requirements of a qualified scrambling algorithm.
[0040] 2. Correlation between adjacent pixels
[0041] Generally, adjacent pixels in an image exhibit high correlation in their horizontal, vertical, and diagonal directions. This allows attackers to analyze the image's encryption algorithm using this characteristic, thereby cracking the image. Therefore, correlation analysis between adjacent pixels can also be used to measure the security of a scrambling method; a qualified scrambling method should be able to eliminate the correlation between pixels. Typically, the correlation between adjacent pixels in an image is visually represented by a correlation coefficient and a pixel distribution map. The formula for calculating the correlation coefficient is as follows:
[0042]
[0043] Where, x i ,y i This represents the pixel value of the i-th pixel, N is the number of samples, and E(x) and D(x) represent the expectation and variance of x. Taking the "House" image as an example, the table below shows the correlation coefficients in three directions of the image before and after scrambling according to this invention. Figure 4The correlation analysis graph of adjacent pixels before and after the scrambling is provided. From the table and the graph, the correlation coefficients of the pixels in each direction of the scrambled image are very small, very close to 0, and the pixel distribution is very uniform, which shows that the application can effectively reduce the correlation of adjacent pixels of the image.
[0044]
[0045] 3. Robustness
[0046] For the scrambled image, it is required to have certain attack resistance to effectively prevent the scrambled image from being attacked and damaged, so that it is difficult to repair when the image is recovered. In order to effectively verify the defense capability of the application to noise and cutting attack, the "House" image is tested, and different salt and pepper noise 0.05, 0.1, 0.2 and cutting 1 / 64, 1 / 16 and 1 / 8 are selected to test the application, as shown in Figure 5 and Figure 6 According to the result diagram, the application has good anti-noise and anti-cutting performance, that is, good robustness.
[0047] The embodiments of the application are described in detail above in combination with the drawings, but the application is not limited to the above embodiments, and various changes can be made within the knowledge range of those skilled in the art without departing from the purpose of the application.
Claims
1. An image scrambling method based on binary bidirectional zigzag transform, characterized in that, include: The process includes converting a 2D grayscale image into 8 binary image matrices, sorting the binary image matrices, bidirectional zigzag scanning, 1D sequence rearrangement, and image matrix restoration. By inputting a grayscale image of size N×N, the image is scrambled and restored to achieve the effects of encrypting the image and fully restoring the image. The bidirectional zigzag scan includes: sorting the binary matrix into I1', I2', ..., I8', grouping I1' and I8' together, I2' and I7' together, I3' and I6' together, and I4' and I5' together, and then performing bidirectional zigzag scrambling on each pair. The rule for the first group scan is: starting from I1'... Start scanning from the center point in a zigzag pattern, moving from the center point to the top left corner, then to point (1,1) of I8', and continue scanning in a zigzag pattern from the top left corner back to the center point until I8'... End, obtain the one-dimensional sequence d1 according to the scanning order, and then from I1' Start scanning from the center point in a zigzag pattern, moving towards the upper right corner, then to point (N,N) of I8'. Continue scanning in a zigzag pattern from the lower right corner towards the center point until I8'... The point ends, and a one-dimensional sequence d2 is obtained according to the scanning order. Each group is scanned according to this rule to obtain the final eight one-dimensional sequences, namely d1, d2, ..., d8.
2. The image scrambling method based on binary bidirectional zigzag transform according to claim 1, characterized in that, The conversion of the two-dimensional grayscale image into an 8-binary image matrix includes: Read in a grayscale image, convert the value of each pixel in the grayscale image from decimal to binary, and convert the original decimal matrix I into eight binary matrices I1, I2, ..., I8.
3. The image scrambling method based on binary bidirectional zigzag transform according to claim 1, characterized in that, The binary image matrix sorting includes: The binary matrices are sorted according to the number of 1s they contain. The matrix with the most 1s is the first binary image matrix plane, and the matrix with the fewest 1s is the last binary image matrix plane.
4. The image scrambling method based on binary bidirectional zigzag transform according to claim 1, characterized in that, The one-dimensional sequence rearrangement includes: Arrange the eight one-dimensional sequences into an 8×N binary matrix, and then arrange them into a 1×8N matrix in column-major order. 2 A one-dimensional binary sequence.
5. The image scrambling method based on binary bidirectional zigzag transform according to claim 4, characterized in that, The image matrix restoration includes: Divide the rearranged one-dimensional binary sequence into 8 segments, with each segment containing i=N segments. 2 Let the values be e1, e2, ..., e8, and let y(i) = e1(i). 2 7 +e2(i) 2 6 +…+e8(i) 2 0 Generate a decimal sequence, where y represents the decimal sequence. Finally, rearrange y in column order to form an N×N two-dimensional decimal matrix x, which is the scrambled image matrix. All the above steps are reversible operations. The encrypted image restoration process is the inverse operation of all the above steps. The decrypted image is obtained through the encrypted image restoration process.