Reversible data hiding method based on quadtree coding and block subdivision
Through quad-tree encoding and block resegment technology, combined with median edge predictor and hierarchical quad-tree encoding, the problems of low embedding rate and insufficient image concealment in the existing technology are solved, and efficient data hiding and lossless recovery are achieved .
Patent Information
- Application Number
- CN202411077840.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-07
- Publication Date
- 2024-11-22
AI Technical Summary
In the existing reversible data hiding methods, the embedding rate is low, the image is not hidden enough, and the image cannot be recovered losslessly.
Using a method based on quad-tree encoding and block re-division, the prediction error is calculated through the median edge predictor, an error position map is generated for spatial compression, and the bit plane is compressed by hierarchical quad-tree encoding to free up free space for Data hiding, encrypting and decrypting using encryption keys and data hiding keys to ensure data security and reversibility.
It improves the embedding rate of data concealment, enhances the concealment of images, and realizes lossless image recovery, solving the problems of low embedding rate and inability to recover losslessly.
Smart Images

Figure CN119011736A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of reversible data hiding methods, and in particular relates to a reversible data hiding method based on quadtree coding and block redivision. Background Art
[0002] With the gradual development of the Internet, images, as an important part of information media, play a vital role in the interaction of Internet information. The security of their transmission and storage has also received widespread attention. While people rely on the Internet, they also face the problem of network information being intercepted and stolen. Considering the accuracy and security of information during image transmission, data hiding technology is proposed.
[0003] Taking advantage of the insensitivity of human sensory organs to digital signals and digital redundancy in images and audios, additional information is embedded in them for transmission, making it impossible for observers to detect effective information, thereby solving security issues such as copyright protection and covert communications. In practical applications, some fields such as medicine and military have higher requirements for the recovery of carrier images, so reversible data hiding technology has been proposed. With its unique advantages, this technology can embed additional information in the overlay layer of multimedia data and ensure accurate information extraction and complete recovery of the original overlay layer without losing any data.
[0004] However, the existing technology has the problems of low data embedding rate, insufficient concealment of the image after data hiding, poor chaotic characteristics of the algorithm, and inability to restore the image losslessly. Therefore, it is very necessary to comprehensively improve and innovate a more complete and more secure reversible data hiding method. Summary of the invention
[0005] The purpose of the present invention is to provide a reversible data hiding method based on quadtree coding and block redivision, which solves the problems of low embedding rate and inability to restore images losslessly in existing reversible data hiding methods.
[0006] The technical solution adopted by the present invention is: a reversible data hiding method based on quadtree coding and block redivision, which obtains prediction values according to the adjacent pixels of a pixel, calculates the prediction error, and replaces the original image with the error position map for spatial compression. The prediction error bit plane is compressed using hierarchical quadtree coding. For areas that do not use quadtree coding, it is divided into blocks of size 4×4, and the embeddable blocks are optimally identified to free up free space. The combined blocks are classified and the encryption key K is used in the error position map. e After encryption and embedding auxiliary data, the encrypted image I is obtained e , and for image I e Each pixel in the data is hidden by the key K d Hide the key K through datad Losslessly extract secret data through encryption key K e The specific steps to restore the image are as follows:
[0007] The present invention is also characterized in that:
[0008] The present invention is based on a reversible data hiding method based on quadtree coding and block redivision, and is specifically implemented according to the following steps:
[0009] Step 1: Replace the original image with the error position map for spatial compression
[0010] For an M*N original grayscale image, its prediction value is calculated according to the median edge predictor MED; the predicted pixel value is calculated using the median edge predictor MED, for each pixel, the MED predictor uses the left pixel, the upper pixel, and the right pixel to calculate the prediction value, and the error value is obtained by subtracting the original pixel value from the predicted value, and an error position map is generated according to the corresponding error and bit plane decomposition is performed to generate 8 bit planes, and the 8 bit planes include the lowest bit plane LSB, and the high bit planes arranged from low to high, that is, the first to seventh bit planes;
[0011] Step 2: The bit plane obtained in step 1 is segmented into multiple blocks by quadtree, and then the available leaf nodes whose pixels are pure color blocks are identified and hierarchically encoded. Finally, the path encoding of the compressed leaf nodes is used to free up the embedding space.
[0012] Step 3: After quadtree segmentation and encoding of the first to seventh bit planes, there are still unprocessed parts of the image after quadtree segmentation. The unprocessed parts are processed twice, and good blocks are selected for subsequent embedding in combination with the optimal block recognition strategy; finally, an image with free space is obtained;
[0013] Step 4: Use the encryption key K on the freed-up image e Encryption; free up space for images with I v Then use the encryption key K e Generate a pseudo-random matrix q of size M×N pixels, and then convert it into a binary sequence, using q k (i,j) represents, with k = 0, 1, 2, ..., 7, perform encryption operation, use scrambling key k s For secret data I e Scramble the image to get the encrypted image.
[0014] Step 5: Perform data hiding in the least significant bit plane LSB. The secret data is hidden using the data key K before embedding. d Encrypt and scramble; reverse the scrambled encrypted image to the encrypted image Then, the auxiliary information on the lowest bit plane LSB of the encrypted image is extracted, and the auxiliary information is used to restore the image, and all the embeddable spaces of the high bit plane are obtained, and the high bit plane is the bit plane other than the lowest bit plane LSB; the secret data is embedded in the space vacated by the high bit plane; finally, the image is scrambled and encrypted to obtain the scrambled encrypted image and send it to the receiver;
[0015] Step 6: The receiver has the key K d and K s , the embedded data can be obtained from the scrambled encrypted image When the legitimate recipient obtains K s After that, the encrypted image is obtained by inverse scrambling; then, the bit stream of the embedded secret data is directly extracted from the high-order plane of the encrypted image with embedded data, and K d Recover the original content of the secret data.
[0016] Furthermore, the formula for calculating the predicted value of a pixel in step 1 is shown in (1):
[0017]
[0018] Among them, x is the original pixel, is the predicted value of the pixel in row i and column j;
[0019] Calculate the prediction error value of the pixel according to formula (2);
[0020]
[0021] Where, e is the prediction error value;
[0022] For a grayscale image of size M*N, its pixel value range is [0, 255], and each pixel value requires 8 bits to store. Therefore, for an error value, when it is greater than or equal to "128" or less than or equal to "-128", if the sign bit is retained, the pixel value will overflow. The overflow pixel problem can be solved according to formula (3);
[0023]
[0024] Where e is the prediction error value.
[0025] Furthermore, step 2 is specifically as follows:
[0026] From the first bit plane to the seventh bit plane of the error position map, perform quadtree partitioning: divide each bit plane into four square blocks with a block size of 2 n-1 ×2 n-1Then, process each block from left to right and from top to bottom. For the four blocks after segmentation, if the pixels in the blocks are the same, stop segmentation and continue to analyze the next block. Otherwise, segment the current block into four non-overlapping blocks of the same size, with a size of 2 n-2 ×2 n-2 After the segmentation is completed, a quadtree is constructed, with the entire bit plane as the root of the quadtree, representing level 0, and the number of levels increases by 1 each time the block is divided; where n is a multiple of the horizontal and vertical pixel lengths;
[0027] The available leaf nodes are encoded, and the encoding consists of: depth code, numerical mark code, number code of leaf nodes of this type in the current layer, and path code. In formula (5), the depth of the leaf node is L, that is, the corresponding leaf node layer number is L:
[0028]
[0029] Among them, E b is a bit plane of the error position map, E c For E b The blocks corresponding to the available leaf nodes.
[0030] L is converted into binary as the depth code, where L′ in formula (5) represents the length of the depth code.
[0031]
[0032] Where n′ is the maximum depth of the quadtree. After the hierarchical quadtree encoding is completed, the embedding capacity of the available leaf nodes in the L layer is calculated by formula (7) and C L express,
[0033]
[0034] in, is the number of nodes with pixel value 0, is the number of nodes with pixel value 1.
[0035] The effective load P of the quadtree is calculated by formula (8):
[0036]
[0037] Among them, D L It represents the encoding length of the available leaf nodes in the L layer, and MaxD represents the quadtree depth of the current bit plane.
[0038] Furthermore, step 3 is specifically as follows:
[0039] Starting from the first bit plane, the unprocessed area is re-divided into 4×4 blocks. According to the structural characteristics of the blocks, these blocks can be divided into seven types:
[0040] Suppose the number of pixels with pixel values of 0 and 1 in the block is n0, n1 respectively; the minimum value between them is
[0041] m=min{n0,n1}
[0042] When n1=0, the block type is marked as EB-I, indicating that all pixels in the block are 0;
[0043] When n0=0, the block type is marked as EB-II, indicating that all pixels in the block are 1;
[0044] When 0≤n1≤2, the block type is marked as EB-III, indicating that there are 1 to 2 white dots in the black block;
[0045] When 0≤n0≤2, the block type is marked as EB-IV, indicating that there are 1 to 2 black dots in the white block;
[0046] When n b ≤2, b1=0, the block type is marked as EB-V, indicating that there is a unique white sequence in the black block;
[0047] When n b ≤2, b1=1, the block type is marked as EB-VI, indicating that there is a unique black sequence in the white block;
[0048] When n b >2, the block type is marked as NEB, indicating a non-embeddable block;
[0049] Blocks marked as EB-I and EB-II are identified as embeddable blocks; blocks marked as EB-III, EB-IV, EB-V and EB-VI are identified as embeddable blocks if the redundancy within the block is greater than the length of the block structure information; b1 represents the pixel value within the block;
[0050] Since the blocks corresponding to the available leaf nodes in the quadtree encoding are all pure color blocks, the remaining blocks after the quadtree encoding are mixed color blocks, that is, the pixel values in the blocks are not exactly the same, so the EB-III, EB-IV, EB-V, and EB-VI type blocks are compared to select the embeddable blocks with remaining space;
[0051] Auxiliary information is embedded in the embeddable block, and the auxiliary information includes three parts: the first part is the auxiliary information of the overflow pixel in the error position map, which records the position of the overflow pixel information to generate the overflow position map, and starting from the first pixel, records the pixel position of the overflow position map as auxiliary information; the second part is the auxiliary information of the hierarchical quadtree coding, which records the structure and number of layers of the tree in the quadtree coding process; the third part is the auxiliary information generated by the optimal block identification, which records the type and position information of the optimal block.
[0052] Further, the image freed up in step 4 is used v The expression formula is shown in (9):
[0053]
[0054] Among them, p v (i,j) represents the pixel in image Iv, Represents pixel p v The kth position of (i,j);
[0055] Using the encryption key K e Generate a pseudo-random matrix q of size M×N, convert it into a binary sequence, and use q k (i, j) indicates that k = 0, 1, 2, ..., 7, and the encryption operation is performed; represents the encryption bit, ⊕ represents the XOR operation,
[0056]
[0057]
[0058] Among them, the encrypted image pixel is represented as p e (i,j), generate encrypted image I e , using the scrambling key k s to I e Scramble the image to get the encrypted image.
[0059] Furthermore, in step 5, hierarchical quadtree coding is applied to different bit planes of the error position map, and the capacity of the i-th bit plane is denoted as H i , as shown in formula (12), when H i ≤0, the bit plane is not used to make room;
[0060]
[0061] Among them, 1≤i≤7, f i represents the quadtree depth of the i-th bit plane;
[0062] Starting from the first bit plane, continuous available bit planes are selected for embedding. MaxK represents the number of bit planes encoded by the hierarchical quadtree, as shown in formula (13):
[0063]
[0064] H is the embedding amount provided by the error position map through hierarchical quadtree coding, as shown in formula (14):
[0065]
[0066] MaxB represents the number of continuous bit planes that can provide the maximum embedding space through optimal block identification, as shown in formula (15):
[0067]
[0068] B is the embedding amount provided by the optimal block recognition of the unprocessed part, as shown in formula (16):
[0069]
[0070] The total capacity provided by the image is C, which is calculated as shown in (17):
[0071] C=H+B (17)
[0072] Keep the least significant bit plane LSB unchanged and embed the secret data into the free space of other bit planes. The maximum embedding rate A can be calculated as follows:
[0073]
[0074] Among them, F is the maximum number of bits of secret data to be embedded. In order to ensure the security of secret data during transmission, the scrambling key K is used. s Scramble the encrypted image.
[0075] The beneficial effects of the present invention are:
[0076] The present invention is a reversible data hiding method based on quadtree coding and block redistribution, uses MED error map technology as an embedding carrier of secret data to expand the embeddable space, and solves the problem that the image is not hidden enough after data hiding; the error map is divided into bit plane blocks, and quadtree coding and block redistribution technology are used to free up space, thereby improving the embedding rate of the method, and solving the problem of low embedding rate; bit plane decomposition technology is used to free up free space to hide data, and solves the problem that the image cannot be restored losslessly. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] Figure 1 It is a method framework diagram of the reversible data hiding method based on quadtree coding and block subdivision of the present invention;
[0078] FIG2( a ) is an original grayscale image in Example 3 of the present invention;
[0079] FIG2( b ) is an error position diagram in Example 3 of the present invention;
[0080] Figure 3 The error position map of the reversible data hiding method based on quadtree coding and block subdivision of the present invention is divided into 8 bit planes;
[0081] Figure 4 It is a schematic diagram of quadtree segmentation of a unit plane of an error position diagram of a reversible data hiding method based on quadtree coding and block subdivision of the present invention;
[0082] Figure 5 It is a schematic diagram of the individual path coding of the quadtree and leaf nodes of the reversible data hiding method based on quadtree coding and block subdivision of the present invention;
[0083] Figure 6 It is a coding structure diagram of available leaf nodes of L layers of the reversible data hiding method based on quadtree coding and block subdivision of the present invention;
[0084] Figure 7 It is a schematic diagram of an embeddable basic block in which there is only one white continuous pixel in a black block of the reversible data hiding method based on quadtree coding and block subdivision of the present invention;
[0085] Figure 8 It is a schematic diagram of an embeddable basic block in which there is only one black continuous pixel in a white block of the reversible data hiding method based on quadtree coding and block redivision of the present invention;
[0086] Fig. 9 It is the Lena original graph of the reversible data hiding method based on quadtree coding and block redivision of the present invention;
[0087] Fig.10 It is a Lena prediction error graph of the reversible data hiding method based on quadtree coding and block subdivision of the present invention;
[0088] Fig.11 It is a Lena encrypted image of the reversible data hiding method based on quadtree coding and block redivision of the present invention;
[0089] Fig.12 It is a Lena scrambled encrypted image based on the reversible data hiding method of the present invention based on quadtree coding and block redivision;
[0090] Fig.13 It is a Lena restored image of the reversible data hiding method based on quadtree coding and block redivision of the present invention;
[0091] Fig.14 It is a Lena original image histogram of the reversible data hiding method based on quadtree coding and block redivision of the present invention;
[0092] Fig.15 It is a Lena scrambled encrypted image histogram of the reversible data hiding method based on quadtree coding and block redivision of the present invention;
[0093] Fig.16 It is a Lena scrambled encrypted image histogram of the reversible data hiding method based on quadtree coding and block redivision of the present invention; DETAILED DESCRIPTION
[0094] The present invention is described in detail below with reference to the accompanying drawings and specific embodiments.
[0095] Example 1
[0096] The reversible data hiding method based on quadtree coding and block redivision of the present invention calculates the prediction error, calculates the predicted pixel value for the original grayscale image, subtracts the original pixel value from the predicted pixel value to obtain the prediction error, generates an error position map, and replaces the original image with the error position map for spatial compression. The prediction error bit plane is compressed using hierarchical quadtree coding. For areas that do not use quadtree coding, they are divided into blocks of size 4×4, and the embeddable blocks are optimally identified and free space is freed. The freed-up image is encrypted and scrambled using an image key and a scrambling key, respectively. In the embedding stage, the encrypted image is inversely scrambled, and then the additional data encrypted by the data key is directly embedded, and finally the embedded image is scrambled again using the same scrambling key, and the receiver can achieve error-free data extraction and image recovery through different keys.
[0097] Example 2
[0098] The present invention is based on a reversible data hiding method based on quadtree coding and block redistribution, such as Figure 1 As shown, the specific steps include:
[0099] Step 1: Replace the original image with the error position map for spatial compression
[0100] For an M*N original grayscale image, its prediction value is calculated based on the median edge predictor MED; for each pixel, the MED predictor uses the left pixel, the upper pixel, and the right pixel to calculate the prediction value, and the original value is subtracted from the prediction value to obtain the error value in the corresponding error position map, and the error position map is generated and bit plane decomposition is performed, and the bit plane decomposition is performed to generate 8 bit planes;
[0101] The first pixel of the original grayscale image in step 1 is used as the reference pixel, and the formula for calculating the predicted value of the first row and first column pixels is shown in (1):
[0102]
[0103] Among them, x is the original pixel, is the predicted value of the pixel in the i-th row and j-th column; x(i-1,j-1), (x(i-1,j), x(i-1,j) and x(i,j-1) represent the pixels of each 4×4 block in a block;
[0104] In particular, the first pixel of the original image is retained as the reference pixel to reduce the auxiliary information and restoration error of the image, and for other pixels in the first row, its predicted value is recorded as the pixel value of the pixel on its left; for the pixels in the first column, its predicted value is recorded as the pixel value of the pixel above it, and the prediction error value of the pixel is calculated according to formula (2);
[0105]
[0106] Where, e is the prediction error value;
[0107] For a grayscale image of size M*N, its pixel value range is [0, 255], and each pixel value requires 8 bits to store. Therefore, for an error value, when it is greater than or equal to "128" or less than or equal to "-128", if the sign bit is retained, the pixel value will overflow. The overflow pixel problem can be solved according to formula (3);
[0108]
[0109] Where e is the prediction error value.
[0110] Step 2: The bit plane obtained in step 1 is segmented into multiple blocks by quadtree, and then the available leaf nodes whose pixels are pure color blocks are identified and hierarchically encoded. Finally, the path encoding of the compressed leaf nodes is used to free up the embedding space.
[0111] Step 2 is as follows: perform quadtree segmentation from the first bit plane to the seventh bit plane of the error position map. Each bit plane is divided into four square blocks, and the size of the block is 2 n-1 ×2 n-1 , where n is a multiple of the horizontal and vertical pixel lengths. Then start processing each block from left to right and from top to bottom. For the four blocks after segmentation, if the pixels in the block are the same, stop segmentation and continue to analyze the next block. Otherwise, continue to segment the current block into four non-overlapping blocks of the same size; after the segmentation is completed, construct a quadtree with the entire bit plane as the root of the quadtree, representing level 0, and the number of layers increases by 1 each time the block is segmented;
[0112] The available leaf nodes are encoded, and the encoding consists of: depth code, numerical mark code, number code of leaf nodes of this type in the current layer, and path code; the depth of the leaf node in formula (4), that is, the number of corresponding leaf node layers, is represented by L:
[0113]
[0114] Among them, E b is a bit plane of the error position map, E c For E b The blocks corresponding to the available leaf nodes;
[0115] The leaf node depth L is converted into binary as the depth code. In formula (5), L′ represents the length of the depth code.
[0116]
[0117] Where n′ is the maximum depth of the quadtree. After the hierarchical quadtree encoding is completed, the embedding capacity of the available leaf nodes in the L layer is calculated by formula (7) and C L express,
[0118]
[0119] in, is the number of nodes with pixel value 0, is the number of nodes with pixel value 1;
[0120] The effective load P of the quadtree is calculated by formula (8):
[0121]
[0122] Among them, D L It represents the encoding length of the available leaf nodes in the L layer, and MaxD represents the quadtree depth of the current bit plane.
[0123] Step 3: In step 3: starting from the first bit plane, the unprocessed part is re-divided into 4×4 blocks. According to the structural characteristics of the blocks, these blocks are divided into seven types, as shown in Table 1.
[0124] Table 1
[0125] Parameter conditions Block type tag Block Type Description <![CDATA[n1=0]]> EB-I All pixels in the block are 0 <![CDATA[n0=0]]> EB-II All pixels in the block are 1 <![CDATA[0≤n1≤2]]> EB-III There are 1 to 2 white spots in the black block <![CDATA[0≤n0≤2]]> EB-IV There are 1 to 2 black spots in the white block <![CDATA[n b ≤2,b1=0]]> EB-V There is a unique sequence of white in the black block <![CDATA[n b ≤2,b1=1]]> EB-VI There is a unique black sequence in the white block <![CDATA[n b >2]]> NEB Non-embeddable blocks
[0126] Among them, n0, n1 are the number of pixels with pixel values 0 and 1 in the block, and the minimum value between them is m=min{n0,n1}.
[0127] Blocks marked as EB-I and EB-II are identified as embeddable blocks; blocks marked as EB-III, EB-IV, EB-V and EB-VI are identified as embeddable blocks if the redundancy within the block is greater than the length of the block structure information; b1 represents the pixel value within the block;
[0128] Since the blocks corresponding to the available leaf nodes in the quadtree encoding are all pure color blocks, the remaining blocks after the quadtree encoding are mixed color blocks, that is, the pixel values in the blocks are not exactly the same, so the EB-III, EB-IV, EB-V, and EB-VI type blocks are compared to select the embeddable blocks with remaining space;
[0129] Auxiliary information is embedded in the embeddable block, and the auxiliary information includes three parts: the first part is the auxiliary information of the overflow pixel in the error position map, which records the position of the overflow pixel information to generate the overflow position map, and starting from the first pixel, records the pixel position of the overflow position map as auxiliary information; the second part is the auxiliary information of the hierarchical quadtree coding, which records the structure and number of layers of the tree in the quadtree coding process; the third part is the auxiliary information generated by the optimal block identification, which records the type and position information of the optimal block.
[0130] Step 4: Use I to free up the free space for the image v It is expressed as shown in formula (9):
[0131]
[0132] Among them, p v (i,j) represents image I v Pixels in . Represents pixel p v The kth position of (i,j).
[0133] Then use the encryption key K e Generate a pseudo-random matrix q of size M×N, and then convert it into a binary sequence, using q k (i, j) is represented by k = 0, 1, 2, ..., 7. Next, the encryption operation is performed. represents the encryption bit, and ⊕ represents the XOR operation.
[0134]
[0135]
[0136] Among them, the encrypted image pixel is represented as p e (i,j), generate encrypted image I e , using the scrambling key k s to I e Scramble the image to get the encrypted image.
[0137] Step 5: Perform data hiding in the least significant bit plane LSB. The secret data is hidden using the data key K before embedding. d Encrypt and scramble; reverse the scrambled encrypted image to the encrypted image Then, the auxiliary information on the lowest bit plane LSB of the encrypted image is extracted, and the auxiliary information is used to restore the image, and all the embeddable spaces of the high bit plane are obtained, and the high bit plane is the bit plane other than the lowest bit plane LSB; the secret data is embedded in the space vacated by the high bit plane; finally, the image is scrambled and encrypted to obtain the scrambled encrypted image and send it to the receiver;
[0138] Hierarchical quadtree coding is applied to different bit planes of the error position map, and the capacity of the i-th bit plane is denoted as H i , as shown in formula (14). If H i ≤0, the bit plane is not used to make space;
[0139]
[0140] Among them, 1≤i≤7, f i represents the quadtree depth of the i-th bit plane;
[0141] Starting from the first bit plane, continuous available bit planes are selected for embedding. MaxK represents the number of continuous bit planes that can provide the maximum embedding space through hierarchical quadtree coding, as shown in formula (13):
[0142]
[0143] H is the embedding amount provided by the error position map through hierarchical quadtree coding, as shown in formula (14):
[0144]
[0145] MaxB represents the number of continuous bit planes that can provide the maximum embedding space through optimal block identification, as shown in formula (15):
[0146]
[0147] B is the embedding amount provided by the optimal block recognition of the unprocessed part, as shown in formula (16):
[0148]
[0149] The total capacity provided by the image is C, which is calculated as shown in (17):
[0150] C=H+B (17)
[0151] Keep the least significant bit plane LSB unchanged and embed the secret data into the free space of other bit planes. The maximum embedding rate A can be calculated as follows:
[0152]
[0153] Among them, F is the maximum number of bits of secret data to be embedded. In order to ensure the security of secret data during transmission, the scrambling key K is used. s Scramble the encrypted image.
[0154] Step 6: The receiver has the key K d and Ks , the embedded data can be obtained from the scrambled encrypted image When the legitimate recipient obtains K s After that, the encrypted image is obtained by inverse scrambling. Then, the bit stream of the embedded secret data is directly extracted from the high-order plane of the encrypted image with embedded data, and K d Recover the original content of the secret data.
[0155] The receiver holds the key K e and K s , the original image can be restored without loss. First, the receiver sends the scrambled encrypted image Perform the reverse scrambling and then use the encryption key K e , the original image can be completely restored.
[0156] Example 3
[0157] The reversible data hiding method based on quadtree coding and block redivision specifically includes the following steps:
[0158] Step 1: Replace the original image with the error position map for spatial compression; for an M*N original grayscale image (as shown in Figure 2(a)), calculate its prediction value based on the median edge predictor MED; for each pixel, the MED predictor uses the left pixel, the upper pixel, and the right pixel to calculate the prediction value, and subtracts the original value from the prediction value to obtain the error value in the corresponding error position map, generate the error position map of Figure 2(b) and perform bit plane decomposition, and perform bit plane decomposition to generate the following Figure 3 The 8 bit planes shown;
[0159] After the prediction error value is calculated, there may be pixels that exceed the pixel representation range of the error position map. Therefore, these pixels are marked as overflow pixels, and their pixel values are modified so that they fall within the normal value range. If the out-of-bounds error pixel of the current pixel is less than or equal to -128, the prediction error value of the pixel is added by 128; if the out-of-bounds error pixel of the current pixel is greater than or equal to 128, the prediction error value of the pixel is subtracted by 128. All error-modified pixels are overflow pixels. At this time, the pixel range of the error position map is (-128, 128), as shown in Figure 2 (b).
[0160] Since the original position of the bit plane is disrupted in the subsequent embedding operation, the sign of the prediction error cannot be determined in the image restoration step. In this case, if only the traditional method is used to calculate the bit plane, the proposed method is irreversible. Therefore, the method uses the lowest bit plane to represent the sign of the prediction error, and the absolute value is represented by the first seven bit planes. For pixels with prediction errors in (-128, 128), the eighth bit of the pixel with a prediction error less than zero is 1, otherwise, the eighth bit is 0. In particular, for pixels with prediction errors equal to zero, if the value of the prediction error before modification is 128 or -128, the corresponding eight-bit binary of the error pixel is "00000000" and "00000001". The reference pixel is directly converted into an 8-bit binary sequence, and then the other prediction errors are converted into a 7-bit binary sequence in the following way, as shown in formula (4):
[0161]
[0162] An overflow position map is used to record the positions of all overflow pixels. In the overflow position map, the corresponding positions of the overflow pixels are set to 1, and other pixels are set to 0. In particular, in the data embedding stage, the overflow position map will be embedded into the image as part of the auxiliary information.
[0163] Step 2: The error position map obtained in step 1 is compressed by hierarchical quadtree coding to make room for embedding secret data. First, the bit planes are quadtree segmented, and then the available leaf nodes are identified and hierarchically encoded. Finally, the embedding space is freed up by compressing the path coding of the leaf nodes.
[0164] Step 2 is as follows: perform quadtree segmentation from the first bit plane to the seventh bit plane of the error position map. Each of the seven bit planes to be processed is divided into four square blocks, that is, a size of 2 n ×2 n The blocks are divided into Figure 4 The four square blocks shown have a block size of 2 n-1 ×2 n-1 Then, each block is processed from left to right and from top to bottom. For the four blocks after segmentation, if the pixels in the blocks are the same, the segmentation is stopped and the next block is analyzed. Otherwise, the current block is segmented into four non-overlapping blocks of the same size, with a size of 2 n-2 ×2 n-2 After the segmentation is completed, a quadtree is constructed. Figure 5 As an example, Figure 6 The corresponding quadtree is described. The entire bit plane is used as the root of the quadtree, representing level 0, and the number of levels increases by 1 each time the block is divided. Figure 4 and Figure 6 As shown, Figure 6 The four nodes on the same branch represent from left to right Figure 4 There are four blocks I, II, III and IV in the diagram. Each of these four nodes is a leaf node or a branch node. A branch node represents a mottled block. Further segmenting the mottled block can obtain a smaller pure color block. If all the pixels in the block are the same, that is, the current block is a pure color block, then the corresponding leaf node is an available leaf node, otherwise it is an unavailable leaf node. Figure 8 In the figure, the oblique leaf nodes and dot leaf nodes are both available leaf nodes, the mesh leaf nodes are unavailable leaf nodes, and the black nodes are branch nodes;
[0165] The available leaf nodes are encoded, and the encoding consists of: depth code, numerical mark code, number code of this type of leaf nodes in the current layer, and path code.
[0166] 1. Depth code: The depth of a leaf node is represented by L and is calculated by formula (5).
[0167]
[0168] Among them, E b is a bit plane of the error position map, E c For E b The blocks corresponding to the available leaf nodes.
[0169] L is converted into binary as the depth code, where L′ in formula (6) represents the length of the depth code.
[0170]
[0171] 2. Numerical marking code: records the value of the leaf node so that the receiver can correctly restore the corresponding leaf node. Because there are only two values (0 or 1), one bit is used to record the value of the leaf node to indicate whether the currently available leaf node is a black leaf node or a white leaf node.
[0172] 3. Quantity code: Since there are at most 4 L layers L nodes, that is and The range is [0,4 L ] Therefore, log2(4 L )=2L bits record the number of black leaf nodes and white leaf nodes in the L layer.
[0173] 4. Path coding: Each time the leaf node is split, the path coding of the leaf node increases by two bits. Figure 4 As shown, the leaf node codes at the corresponding positions are 00, 01, 10, and 11, respectively, and the corresponding leaf node codes are added to the path code. Figure 5An example is given to show the separate path code for each leaf node. The path code consists of two parts, namely the path code of the parent node and the leaf node code, which requires 2L bits to record. For leaf nodes with the same parent node, the first (2L-2) bits of the path code are also the same. Therefore, the code length can be shortened by compressing the path code of the leaf node. For leaf nodes at the Lth level, if the parent node is the same, the path code from the parent node to the root is recorded only once, with a length of (2L-2) bits. Combined with the characteristics of quadtree partitioning, there are at most three available leaf nodes from the same parent node, so 2 bits are used to record their number, represented as 01, 10, and 11 respectively, and these 2 bits are spliced to the end of the parent node path code. Finally, each leaf node code is recorded in sequence.
[0174] In particular, if the bits in the bit plane are the same, there is no need to split the bit plane, and only the depth code and the value mark code need to be recorded. For the leaf nodes of the first layer, only separate encoding is required. For the available leaf nodes of other levels, the encoding information is shortened by compressing their path encoding. Since the number of available leaf nodes at each level is different and the distribution is uncertain, the number code and path code are both variable length. The encoding structure is shown in Table 2.
[0175] Table 2
[0176] <![CDATA[log2(n′+1) bits]]> 1st 2L position Variable length Deep Coding Numerical marking code Quantity Code Path Encoding
[0177] After the hierarchical quadtree encoding is completed, the embedding capacity C of the available leaf nodes in the L layer is calculated by formula (7): L and the payload P of the quadtree.
[0178] Step 3: After quadtree segmentation and encoding of the first to seventh bit planes, there are still unprocessed parts of the image after quadtree segmentation. The unprocessed parts are processed twice, and good blocks are selected for subsequent embedding in combination with the optimal block recognition strategy; finally, an image with free space is obtained;
[0179] The secondary processing in step 3 is: starting from the first bit plane, the unprocessed area is re-divided into 4×4 blocks. According to the structural characteristics of the blocks, these blocks can be divided into seven types, as shown in Table 3.
[0180] Table 3
[0181] Parameter conditions Block type tag Block Type Description <![CDATA[n1=0]]> EB-I All pixels in the block are 0 <![CDATA[n0=0]]> EB-II All pixels in the block are 1 <![CDATA[0≤n1≤2]]> EB-III There are 1 to 2 white spots in the black block <![CDATA[0≤n0≤2]]> EB-IV There are 1 to 2 black spots in the white block <![CDATA[n b ≤2,b1=0]]> EB-V There is a unique sequence of white in the black block <![CDATA[n b ≤2,b1=1]]> EB-VI There is a unique black sequence in the white block <![CDATA[n b >2]]> NEB Non-embeddable blocks
[0182] Among them, n0, n1 are the number of pixels with pixel values 0 and 1 in the block, and the minimum value between them is m=min{n0,n1}.
[0183] Figure 7 indicates a block where there is a unique white sequence, Figure 8 Indicates blocks where there is a unique black sequence.
[0184] Since the blocks corresponding to the available leaf nodes in the quadtree coding are all pure color blocks, the objects of optimal block recognition are all mixed color blocks, that is, the pixel values in the blocks are not exactly the same. The corresponding EB-III, EB-IV, EB-V, and EB-VI type blocks in Table 3 are analyzed to select the embeddable blocks with remaining space;
[0185] This method selects EB-III type blocks in the first part of the unprocessed area for embedding, and the remaining blocks are marked as non-embeddable blocks. Based on the characteristics of EB-III type blocks, they are reclassified into two types of blocks: blocks with 1 white dot in a pure black block and blocks with 2 white dots in a pure black block, which correspond to Good-I and Good-II type blocks in Table 2, respectively. As shown in Table 3, all blocks are reclassified into three types of basic blocks. Among them, Good-I and Good-II type blocks are embedded as the optimal blocks.
[0186] Table 3
[0187] Serial number Parameter conditions Block type identifier Block Type Description 1 <![CDATA[n1=1]]> Good-I There is 1 white spot in the pure black block 2 <![CDATA[n1=2]]> Good-II There are 2 white spots in the pure black block 3 otherwise Bad Cannot be used for data embedding
[0188] The block mark bit composition is as follows. The first bit marks whether the current block is embeddable. If it is an embeddable block, it is marked as 1, otherwise it is marked as 0. For Good type blocks, the second bit is a quantity code, marking the number of "1" in the current block. There is only one "1" in the block, the quantity code is 0, corresponding to the Good-I type block; when the number of "1" in the block is 2, the quantity code is 1, corresponding to the Good-II type block. The position index value of the pixel "1" in the block can be any integer in the range of [1,16]. Therefore, fixed-length coding is used for recording, and the corresponding code is 0000-1111. The structural information of Good-I and Good-II type blocks is self-embedded, so no additional space is required for embedding. For Bad type blocks, the first pixel in the block needs to be recorded, and each Bad block requires 1 bit of additional space for embedding.
[0189] Auxiliary information is embedded in the embeddable block, and the auxiliary information includes three parts: the first part is the auxiliary information of the overflow pixel in the error position map, which records the position of the overflow pixel information to generate the overflow position map, and starting from the first pixel, records the pixel position of the overflow position map as auxiliary information; the second part is the auxiliary information of the hierarchical quadtree coding, which records the structure and number of layers of the tree in the quadtree coding process; the third part is the auxiliary information generated by the optimal block identification, which records the type and position information of the optimal block.
[0190] Step 4: Free up the free space for the image using I v Then use the encryption key K e Generate a pseudo-random matrix q of size M×N, and then convert it into a binary sequence, using q k(i, j) is represented by k = 0, 1, 2, ..., 7. Next, the encryption operation is performed. The encrypted image pixel is represented by p e (i,j), generate encrypted image I e ; Use the scrambling key k s to I e Scramble the image to get the encrypted image.
[0191] Step 5: Perform data hiding in the least significant bit plane LSB. The secret data is hidden using the data key K before embedding. d Encrypt and scramble; reverse the scrambled encrypted image to the encrypted image Then, the auxiliary information on the lowest bit plane LSB of the encrypted image is extracted, and the auxiliary information is used to restore the image, and all the embeddable spaces of the high bit plane are obtained, and the high bit plane is the bit plane other than the lowest bit plane LSB; the secret data is embedded in the space vacated by the high bit plane; finally, the image is scrambled and encrypted to obtain the scrambled encrypted image and send it to the receiver;
[0192] Step 6: The receiver has the key K d and K s , the embedded data can be obtained from the scrambled encrypted image When the legitimate recipient obtains K s After that, the encrypted image is obtained by inverse scrambling; then, the bit stream of the embedded secret data is directly extracted from the high-order plane of the encrypted image with embedded data, and K d Recover the original content of the secret data.
[0193] Take the Lena image as an example, where Fig. 9 is the original image, Fig.10 is the error location map based on the MED predictor, Fig.11 The encryption scramble key K e and K s The generated scrambled encrypted image, Fig.12 The encrypted image after scrambling has an embedding rate of 3.065bpp. Fig.13 is the scrambling key K s and encryption key K e Recovered image. Fig.11 and Fig.12 It can be seen that the scrambled encrypted image and the scrambled encrypted image are highly obfuscated. The correlation between pixels has been destroyed and a highly secure ciphertext is generated. Figure 14-16 The histogram of the frequency of Lena images in three stages: original image, scrambled encrypted image, and scrambled encrypted image is shown. Fig.15and Fig.16 The statistical characteristics and Fig.14 There is an obvious difference. Therefore, it is difficult to obtain the content of the original image, which proves that the proposed method has good security.
Claims
1. A reversible data hiding method based on quadtree coding and block redivision, characterized in that: The predicted pixel value is calculated for the original grayscale image, and the predicted pixel value is subtracted from the original pixel value to obtain the predicted error, and an error position map is generated. The original image is replaced with the error position map for spatial compression; the prediction error bit plane is compressed using hierarchical quadtree coding, and for areas that are not encoded using quadtree, it is divided into 4×4 blocks, and the embeddable blocks are identified to free up free space; the combined blocks are classified and encrypted in the error position map using the encryption key K e After encryption and embedding auxiliary data, the encrypted image I is obtained e , and for image I e Each pixel in the data is hidden by the key K d Hide the key K through data d Losslessly extract secret data through encryption key K e Restore the image.
2. The reversible data hiding method based on quadtree coding and block subdivision according to claim 1, characterized in that: The specific steps are as follows: Step 1: For an original grayscale image with M*N pixels, a median edge predictor MED is used to calculate the predicted pixel value, and the error value is obtained by subtracting the original pixel value from the predicted value. An error position map is generated according to the corresponding error and a bit plane is decomposed to generate 8 bit planes. The 8 bit planes include the lowest bit plane LSB and high bit planes arranged from low to high, i.e., the first to seventh bit planes. Step 2: The bit plane obtained in step 1 is segmented into multiple blocks by quadtree, and then the available leaf nodes whose pixels are pure color blocks are identified and hierarchically encoded. Finally, the path encoding of the compressed leaf nodes is used to free up the embedding space. Step 3: After quadtree segmentation and encoding of the first to seventh bit planes, there are still unprocessed parts of the image after quadtree segmentation. The unprocessed parts are processed twice, and good blocks are selected for subsequent embedding in combination with the optimal block recognition strategy; finally, an image with free space is obtained; Step 4: Use the encryption key K on the freed-up image e Encryption; free up space for images with I v Then use the encryption key K e Generate a pseudo-random matrix q of size M×N pixels, and then convert it into a binary sequence, using q k (i,j) represents, with k = 0, 1, 2, ..., 7, perform encryption operation, use scrambling key k s For secret data I e Scramble the image to get the encrypted image I e s ; Step 5: Perform data hiding in the least significant bit plane LSB. The secret data is hidden using the data key K before embedding. d Encrypt and scramble; reverse scramble the scrambled encrypted image to the encrypted image I e s ; Then, extract the auxiliary information on the lowest bit plane LSB of the encrypted image, the auxiliary information is used to restore the image, and obtain all embeddable spaces of the high bit plane, the high plane is the remaining bit planes except the lowest bit plane LSB; The secret data is embedded in the space vacated by the high-order plane; finally, the image is scrambled and encrypted to obtain the scrambled encrypted image and send it to the receiver; Step 6: The receiver has the key K d and K s , the embedded data can be obtained from the scrambled encrypted image I e s Extract directly from s After that, the encrypted image is obtained by inverse scrambling; then, the bit stream of the embedded secret data is directly extracted from the high-order plane of the encrypted image with embedded data, and K d Recover the original content of the secret data.
3. The reversible data hiding method based on quadtree coding and block subdivision according to claim 1, characterized in that: In step 1, the first pixel of the original grayscale image is used as the reference pixel, and the formula for calculating the predicted value of the first row and first column pixels is shown in (1): Among them, x is the original pixel, is the predicted value of the pixel in row i and column j; Calculate the prediction error value of the pixel according to formula (2); Where, e is the prediction error value; For a grayscale image of size M*N, its pixel value range is [0, 255], and each pixel value requires 8 bits to store. Therefore, for an error value, when it is greater than or equal to 128, or less than or equal to -128, if the sign bit is retained, the pixel value will overflow. The overflow pixel problem can be solved according to formula (3); Where e is the prediction error value.
4. The reversible data hiding method based on quadtree coding and block subdivision according to claim 3 is characterized in that: Quadtree segmentation is performed from the first bit plane to the seventh bit plane of the error position map, and each bit plane is divided into four square blocks with a block size of 2 n-1 ×2 n-1 , where n is a multiple of the horizontal and vertical pixel lengths; The available leaf nodes are encoded, and the encoding consists of: depth code, numerical mark code, number code of leaf nodes of this type in the current layer, and path code; the depth of the leaf node in formula (4), that is, the number of corresponding leaf node layers, is represented by L: Among them, E b is a bit plane of the error position map, E c For E b The blocks corresponding to the available leaf nodes; The leaf node depth L is converted into binary as the depth code. In formula (5), L′ represents the length of the depth code. Where n′ is the maximum depth of the quadtree. After the hierarchical quadtree encoding is completed, the embedding capacity of the available leaf nodes in the L layer is calculated by formula (7) and C L express, in, is the number of nodes with pixel value 0, is the number of nodes with pixel value 1; The effective load P of the quadtree is calculated by formula (8): Among them, D L It represents the encoding length of the available leaf nodes in the L layer, and MaxD represents the quadtree depth of the current bit plane.
5. The reversible data hiding method based on quadtree coding and block subdivision according to claim 2, characterized in that: In step 3: starting from the first bit plane, the unprocessed part is re-divided into 4×4 blocks. According to the structural characteristics of the blocks, these blocks are divided into seven types: Suppose the number of pixels with pixel values of 0 and 1 in the block is n0, n1 respectively; the minimum value between them is m=min{n0,n1} When n1=0, the block type is marked as EB-I, indicating that all pixels in the block are 0; When n0=0, the block type is marked as EB-II, indicating that all pixels in the block are 1; When 0≤n1≤2, the block type is marked as EB-III, indicating that there are 1 to 2 white dots in the black block; When 0≤n0≤2, the block type is marked as EB-IV, indicating that there are 1 to 2 black dots in the white block; When n b ≤2, b1=0, the block type is marked as EB-V, indicating that there is a unique white sequence in the black block; When n b ≤2, b1=1, the block type is marked as EB-VI, indicating that there is a unique black sequence in the white block; When n b >2, the block type is marked as NEB, indicating a non-embeddable block; Blocks marked as EB-I and EB-II are identified as embeddable blocks; blocks marked as EB-III, EB-IV, EB-V and EB-VI are identified as embeddable blocks if the redundancy within the block is greater than the length of the block structure information; b1 represents the pixel value within the block; Since the blocks corresponding to the available leaf nodes in the quadtree encoding are all pure color blocks, the remaining blocks after the quadtree encoding are mixed color blocks, that is, the pixel values in the blocks are not exactly the same, so the EB-III, EB-IV, EB-V, and EB-VI type blocks are compared to select the embeddable blocks with remaining space; Embedding auxiliary information in the embeddable block, the auxiliary information includes three parts: the first part is the auxiliary information of the overflow pixel in the error position map, recording the position of the overflow pixel information to generate the overflow position map, starting from the first pixel, recording the pixel position of the overflow position map as the auxiliary information; The second part is the auxiliary information of hierarchical quadtree coding, which records the structure and number of layers of the tree during quadtree coding; the third part is the auxiliary information generated by optimal block identification, which records the type and location information of the optimal block.
6. The reversible data hiding method based on quadtree coding and block subdivision according to claim 4, characterized in that: The image that freed up space in step 4 is used by I v It is expressed as shown in formula (9): Among them, p v (i,j) represents the pixel in image Iv, Represents pixel p v The kth position of (i,j); Using the encryption key K e Generate a pseudo-random matrix q of size M×N, convert it into a binary sequence, and use q k (i, j) indicates that k = 0, 1, 2, ..., 7, and the encryption operation is performed; represents the encryption bit, ⊕ represents the XOR operation, Among them, the encrypted image pixel is represented as p e (i, j), generate the encrypted image Ie, and use the scrambling key ks to encrypt I e Scramble the image to get the encrypted image.
7. The reversible data hiding method based on quadtree coding and block subdivision according to claim 4, characterized in that: Step 5 applies hierarchical quadtree coding to different bit planes of the error position map, and the capacity of the i-th bit plane is denoted as H i , as shown in formula (12), when H i ≤0, the bit plane is not used to make space; Among them, 1≤i≤7, f i represents the quadtree depth of the i-th bit plane; Starting from the first bit plane, continuous available bit planes are selected for embedding. MaxK represents the number of bit planes encoded by the hierarchical quadtree, as shown in formula (13): H is the embedding amount provided by the error position map through hierarchical quadtree coding, as shown in formula (14): MaxB represents the number of continuous bit planes that can provide the maximum embedding space through optimal block identification, as shown in formula (15): B is the embedding amount provided by the optimal block recognition of the unprocessed part, as shown in formula (16): The total capacity provided by the image is C, which is calculated as shown in (17): C=H+B (17) Keep the least significant bit plane LSB unchanged and embed the secret data into the free space of other bit planes. The maximum embedding rate A can be calculated as follows: Among them, F is the maximum number of bits of secret data to be embedded. In order to ensure the security of secret data during transmission, the scrambling key K is used. s Scramble the encrypted image.
Citation Information
Cited By
Video encryption method and device and computer storage medium
CN122120498A
