Reversible Data Hiding for AMBTC Compressed Images Based on Matrix and Hamming Coding

: In this paper, we propose a two-layer data hiding method by using the Hamming code to enhance the hiding capacity without causing signiﬁcantly increasing computation complexity for AMBTC-compressed images. To achieve our objective, for the ﬁrst layer, four disjoint sets using different combinations of the mean value (AVG) and the standard deviation (VAR) are derived according to the combination of secret bits and the corresponding bitmap, following Lin et al.’s method. For the second layer, these four disjoint sets are extended to eight by adding or subtracting 1, according to a matrix embedding with (7, 4) Hamming code. To maintain reversibility, we must return the irreversible block to its previous state, which is the state after the ﬁrst layer of data is embedded. Then, to losslessly recover the AMBTC-compressed images after extracting the secret bits, we use continuity feature, the parity of pixels value, and the unique number of changed pixels in the same row to restore AVG and VAR. Finally, in comparison with state-of-the-art AMBTC-based schemes, it is conﬁrmed that our proposed method provided two times the hiding capacity comparing with other six representative AMBTC-based schemes while maintaining acceptable ﬁle size of steog-images.


Introduction
Due to the openness of the Internet, transmitted messages are now at greater risk of being tampered with or compromised [1]. Therefore, mechanisms must be developed to protect transmitted messages, especially sensitive information such as medical and military data. Data hiding conceals secret information in a cover carrier so that the hidden data is not easily detected by malicious attackers [2]. Digital images often serve as cover media because they are easy to obtain and contain multiple redundant pixel values or features for carrying confidential data. Once the embedding operation is done, the hidden image is called a 'steog-image' [3].
Data hiding techniques for images can generally be classified into three domains: spatial, transformation, and compression. A spatial domain-based data hiding scheme is one that embeds confidential messages into a cover image by simply modifying its pixel values. A representative scheme is least significant bit (LSB) substitution [4]. Following LSB substitution, many schemes based on histogram shifting have been proposed [5,6].
The frequency domain-based information hiding method transforms a cover image into frequency coefficients by means of a discrete wavelet transform (DWT) [7], discrete transform (DCT) [8], etc. Secret data is embedded into coefficients, then the inverse operation is conducted to obtain the steog-image. In general, transform domain-based data hiding schemes are stronger at resisting malicious attacks than spatial domain-based schemes, but at the cost of computational complexity. To extend the applications of data hiding, compression domain schemes are proposed. Conventional compression techniques are explored, such as vector quantization (VQ) [9], side match vector quantization (SMVQ) [10], block truncation coding (BTC) [11], and Joint Photographic Experts Group (JPEG) [12]. Among them, Lema and Mitchell's absolute moment block truncation coding (AMBTC) [13] has attracted scholarly attention in the past decade because its computation is more efficient than other BTC variants while maintaining similar quality of the reconstructed image.
BTC or AMBTC family-based data hiding schemes can be further classified into four categories according to what kind of technologies they co-work with [14]: (1) histogram shifting (HS) based [15][16][17][18]; (2) block classification based [14,[19][20][21][22]; (3) prediction error expansion (PEE) based [23][24][25][26][27][28][29]; or (4) Type 1 based [28][29][30][31][32] data hiding methods: (1) The HS-based method, as given by Li et al. [15], proposed a reversible data hiding (RDH) scheme for BTC-compressed images by using bitmap flipping and HS strategies for two-level quantizers. Subsequently, some methods based on HS were proposed [16][17][18]. Due to the lack of additional information in the stego bit stream, low image distortion is achieved when data is embedded; however, the data capacity is low. (2) The block classification-based method, as first developed by Chuang and Chang [19] in 2006. For a given cover image, it is encoded by BTC and then blocks are classified as smooth or complex ones by using predefined thresholds. The secret bits are embedded into the bitmaps of the selected BTC-compressed blocks. Later, scholars developed variant methods [20][21][22] based on Chung and Chang's idea. (3) Sun's PEE-based method [24], in which a joint neighbor coding (JNC) technique is used to encode BTC-compressed data according to the secret bits. All high average values and low mean values of BTC-compressed blocks are collected as the high mean table and low mean table, respectively. Two secret bits are embedded into each value of either high mean table or low mean table. In general, Sun's method obtains a capacity four times greater than the number of blocks in the cover image at the cost of extra data to be included in the stego BTC compression stream. It also requires a special BTC-decoding algorithm to derive the reconstructed image. In 2017, Hong et al. [25] modified the prediction and classification rules of Sun et al. and proposed an improved method with a lower bit rate. However, their method also needs two-bit indicators to represent four types of prediction errors. Using a fixed-size indicator may not be effective in representing coding conditions because it leads to an increased bit rate. To overcome these shortcomings of negative prediction errors, in 2018, Chang et al. also adopted the ideas of Sun et al. and used JNC to embed secret information by an exclusive OR operator [27]. At the same year, Hong et al. used a reversible integer transform method to represent their two-level quantizers based on their mean and difference values [28]. In addition, the prediction error is further classified as a symmetrical coding case by using the adaptive classification method. Experimental results confirm Hong et al.'s method provides the lowest bit rate than previous methods. (4) Type 1-based methods hide confidential data by modifying the AMBTC codes. For example, in 2014, Pan et al. [32] designed a reference matrix and used different combinations of two quantizer. Then, four cases are designed for data hiding based on different combinations of two quantifiers, the high mean value (H) and low mean value (L) in each block. In the next year, Lin et al. designed another data hiding method by modified high and low means of AMBTC blocks [31]. In Lin et al.'s method, four disjoint sets are created as embeddable blocks, in which the unique number of pixels in each block is more than 2 to embed secret data via different combinations of the mean value (AVG) and the standard deviation (VAR After reviewing BTC or AMBTC-family based data hiding schemes, we found that the lowest hiding capacity is around 64,516 bits and the highest hiding capacity is around 262,144 bits. Therefore, we concluded that it is a challenge to find auxiliary tools to increase the hiding capacity of BTC or AMBTC-family based RDH schemes while maintaining the low computation complexity offered by BTC or AMBTC coding. To break through the limitation of BTC or BTC-family based RDH schemes, literature review is conducted and then we found Chang et al.'s research team proposed a high-payload steganographic scheme for compressed images with Hamming code [35] in 2008. After that, different high-steganographic schemes based on Hamming code were proposed [36,37], but it is noted they are irreversible. Although there is no Hamming code-based RDH method has been proposed. However, (7, 4) Hamming code has a unique feature-hiding three secret bits in a seven-bit stream at the cost of just a single bit modification. In other words, it takes the least cost to conceal three-bit secrets in a seven-bit steam. To apply this advantage of (7, 4) Hamming code to AMBTC-compressed images while providing reversibility feature, in this paper, we propose a two-layer RDH scheme using (7, 4) Hamming code. Later, experimental results will confirm that the hiding capacity offered by our proposed method is significantly higher than that of Chang  The remainder of this paper is organized as follows. In Section 2, the AMBTC method is introduced, two quantizers Hs and Ls of blocks can be restored by the corresponding AVGs, VARs, and bitmaps; (7, 4) Hamming code and Lin et al.'s method are reviewed, respectively. Section 3 illustrates the proposed method in the embedding and extracting phases. In Section 4, we conduct some experiments and comparisons with other AMBTCcompressed image methods. The last section makes concluding points and discusses directions for future work.

Related Work
Since our two-layer data hiding scheme is based on Lin et al.'s RDH method [31], we begin by describing their fundamental technique, AMBTC, in Section 2.1. Next, the data embedding and extraction phases of Lin et al.'s method are briefly discussed in Section 2.2. The core technique used to enhance the hiding capacity of Lin et al.'s scheme- (7,4) Hamming code-will be explained at the end of this section.

Absolute Moment Block Truncation Coding
In 1984, Lema and Mitchell proposed a variant of BTC for reconstructing images with better image quality by preserving the local characteristics inside the divided blocks of the image [13]. During data encoding, an image is first decomposed into several nonoverlapping m × m-sized blocks. In general, m could be 4 or 8. For each block, its AVG and VAR are computed by Equation (1) where (i, j) is the coordinate of a given block, x k represents the grayscale of each pixel ranging from 0 to 255, N = m × m is the total pixels in an image, AVG ij represents the pixels' mean value in a block, and VAR ij denotes the standard deviation for pixels in a block. Both values are transmitted along with a bitmap, which contains "1" in those places when (x k ) ij ≥ AVG ij and "0" otherwise. On the receiver side, a reconstructed block can be obtained with two-level quantizer L ij and H ij that preserves the sample mean and standard deviation according to Equation (2) where q is the number of pixels greater than or equal to AVG ij , L ij represents the low mean value, and H ij represents the high mean value in a (i, j) block. An example is provided here to demonstrate the reconstruction of an AMBTCcompressed image based on AVG, VAR and the corresponding bitmap. The corresponding encoding and decoding results of the AMBTC compression method are demonstrated in Figure 1. In the conventional AMBTC encoding phase, an image is generally divided into non-overlapping blocks of 4 × 4 pixels. Since the encoding results will co-work with (7,4) Hamming coding in our proposed scheme, and the block size is changed to 4 × 7 pixels. For purposes of illustration, the example in Figure 1 is sized as 4 ×7 pixels. Apart from this size difference, the operations of the encoding and decoding phases are the same as in conventional AMBTC. with two-level quantizer Lij and Hij that preserves the sample mean and standard deviation according to Equation (2) = - where q is the number of pixels greater than or equal to AVGij, Lij represents the low mean value, and Hij represents the high mean value in a (i, j) block. An example is provided here to demonstrate the reconstruction of an AMBTC-compressed image based on AVG, VAR and the corresponding bitmap. The corresponding encoding and decoding results of the AMBTC compression method are demonstrated in Figure 1. In the conventional AMBTC encoding phase, an image is generally divided into non-overlapping blocks of 4 × 4 pixels. Since the encoding results will co-work with (7,4) Hamming coding in our proposed scheme, and the block size is changed to 4 × 7 pixels. For purposes of illustration, the example in Figure 1 is sized as 4 × 7 pixels. Apart from this size difference, the operations of the encoding and decoding phases are the same as in conventional AMBTC.

Lin et al.'s RDH Method
In 2015, Lin et al.'s RDH method [31] simply used the AVG and VAR generated by AMBTC to design their data hiding strategies instead of the two quantizers H and L. In their scheme, new two-level quantizers are defined in advance as AVG + VAR and AVG − VAR. Then, disjoint four disjoint cases are created by combining the bitmap and newly defined two-level quantizers. Finally, four hiding strategies for mapping to those four disjoint cases are demonstrated in Table 1.

Lin et al.'s RDH Method
In 2015, Lin et al.'s RDH method [31] simply used the AVG and VAR generated by AMBTC to design their data hiding strategies instead of the two quantizers H and L. In their scheme, new two-level quantizers are defined in advance as AVG + VAR and AVG − VAR. Then, disjoint four disjoint cases are created by combining the bitmap and newly defined two-level quantizers. Finally, four hiding strategies for mapping to those four disjoint cases are demonstrated in Table 1. With four disjoint data hiding cases and four hiding strategies, receivers can easily embed secret bits into embeddable blocks for more than two different pixels. Although Lin et al.'s hiding strategies slightly hamper the image quality of the steog-image, they remained disjoint pixel values in embeddable blocks after data embedding, and it is called as holding the same parity in this paper. Such property successfully guarantees the reversibility of Lin et al.'s RDH method and makes sure the hidden secret bits can be extracted according to Table 1 and Equation (2). Based on Lin et al.'s property which is holding the same parity after the data embedding, we explore the possibility of further enhancing the hiding capacity without reducing steog-image quality.

(7, 4) Hamming Code
Hamming codes [38] are a kind of linear error-correcting code, first invented by Richard Hamming in 1950. In this paper, (7,4) Hamming code is applied to add three parities to four bits of secret data for data hiding with the advantage of detecting and correcting 1-error bit. In (7, 4) Hamming code, four data bits d = (d 1 , d 2 , d 3 , d 4 ) are encoded into seven bits C (also called 'codeword') by adding three parity bits via the generator matrix G of the Hamming code.
Next, codeword C is sent to the receiver. On the receiving side, the received seven-bit codeword R can be checked for errors by Equation (4) using the parity check matrix H 0 by a module of 2. It is noted that sy 1 , sy 2 and sy 3 are bits.
where, Equation (5) is below: The computed result is called a 'syndrome'. If the syndrome (sy 1 , sy 2 , sy 3 ) is '000 , then R = C. If a single error bit occurs, the syndrome (sy 1 , sy 2 , sy 3 ) will not equal '000 . Assume that codeword C = (1000110), the received codeword R' has one error (e.g., R' = (1100110), the calculated syndrome is '010 , which is identical to the second column of H 0 , and R is corrected by R = R ⊕ e 2 = (1100110) ⊕ (010000) = (1000110) (6) where e i is the ith unit vector of length seven (e 2 indicates a zero vector of length seven with a "1" located at the second position, e 2 = (0100000). By ignoring the last three parity bits, we can obtain the correct original data bits, i.e., d = (1000).

Improvement of Lin et al.'s Method
In Lin et al.'s RDH method, their data hiding strategies elegantly achieve two objectives: the property of holding the same parity is always maintained even after data embedding, and secret data can be concealed without causing complex computation. Unfortunately, the hiding capacity provided by their scheme is only 1 bpp. Based on holding the same parity property offered by Lin et al.'s method, we pursue a higher hiding capacity with (7, 4) Hamming code and propose a two-layer RDH for AMBTC-compressed images.
Our two-layer RDH scheme is divided into two parts: (1) a data embedding phase and (2) a data extraction and recovery phase. In the data embedding phase, Lin et al.'s four disjoint data hiding strategies are conducted in the first layer. Then, a new data hiding strategy based on (7, 4) Hamming code is conducted in the second layer, which follows the concept of (7, 4) Hamming code by modifying single bit to conceal three secret bits and extends Lin et al.'s four disjoint cases into eight by adding or subtracting 1 according to a matrix embedding with (7, 4) Hamming code. In the two-layer data hiding strategies, secret bit streams are divided into two parts-secret bits-1 and secret bits-2. During the Electronics 2021, 10, 281 6 of 20 data embedding phase, underflow or overflow may occur in the first and/or second layers. To avoid such problems, the following condition is defined in Equation (7). If only Equation (7) holds after data hiding, then the current block is determined to be embeddable; otherwise, it is un-embeddable.
In order to extract secret bits and completely recover an AMBTC-compressed image, in the first layer, if the unique number of pixels is less than 3 in a block, those blocks are determined as un-embeddable. In the second layer, either the number of embedded pixels is less than 6, or the number of different embedded pixels is 6, but the current processing block cannot be recovered as a lossless AMBTC-compressed block, the current processing block also is identified as un-embeddable one. The extraction phase also is divided into two: (1) when the number of different pixels is greater than or equal to 6, we use continuity feature (which means a set of different pixel values are continuous), the parity of modified pixel values, and the unique feature offered by our second-layer data hiding strategy (i.e., only one pixel value will be changed in a given row) to ensure that the hidden secrets Sb1 and Sb2 can be successfully extracted and the original two-level quantizers AVG and VAR can be stored; and (2) when the number of different pixels is 3 or 4, the parity of pixel values can also be used to extract hidden secrets Sb1 and restore the original two-level quantizers AVG and VAR. The proposed data embedding phase, along with examples of data embedding and irreversibility, are introduced in Section 3.1. Data extraction and recovery are explained in Section 3.2.

Data Embedding Phase
In the data embedding phase, the 512 × 512-sized grayscale image is first divided into k × 7 non-overlapping blocks. After AMBTC encoding, the trios (Bm _k × 7 ) ij , VAR ij and AVG ij are generated for a given block (i, j), where k is 4, (Bm _k ×7 ) ij indicates a block's bitmap, and (i, j) presents the block's coordinates. Assume (Sb 1_k × 7 ) ij is secret bits Sb1 and (Sb 2_k × 3 ) ij is secret bits Sb2. Usually, k is set as 4 since (7, 4) Hamming code is adopted in the proposed method. As for the size of Sb1 is 4 × 7 = 28 bits and the size of Sb2 is 4 × 3 = 12 bits, this is because the hiding capacity for a given block with Lin et al.'s method in the first layer is the same as the block size and three secret bits can be concealed into seven bits as long as one single bit modification is required by adopting (7, 4) Hamming code in the second layer, respectively.
First, hide secret bits Sb1 (Sb 1_k × 7 ) ij into bitmap (Bm _k × 7 ) ij according to the four disjoint cases defined in Lin et al.'s data hiding strategies [31]. Then, hide Sb2 (Sb 2_k × 3 ) ij into bitmap (Bm _k × 7 ) ij using matrix embedding with (7, 4) Hamming code which is proposed in this paper. Finally, check the number of modified pixels to decide whether the stego block is reversible or not after two-layer data hiding. If the number of different pixels is less than 6, or the number of different embedded pixels is 6, but the current processing block cannot be recovered as a lossless AMBTC-compressed block, then we return the modified pixels to the previous state before performing embedding with (7, 4) Hamming code. The flowchart of the two-layer data embedding phase is depicted in Figure 2 Input: 4 × 7 block (B_k × 7)ij, its two-level quantizers VARij and AVGij, and two sets Sb1 and Sb2 of secret bits (Sb1_k × 7)ij and Sb2 (Sb2_k × 3)ij, respectively. Output: Steog-image Step 1: Combine secret bits Sb1 (Sb1_k × 7)ij and bitmap (Bm_k × 7)ij for the current processing (i, j) block to derive the modified pixel values according to data hiding rules listed in Table  1.
Step 2: Check the hidden pixels in a block. If the number of different hidden pixels is 1 or 2, the current block is un-embeddable and all modifications conducted in Step 1 must be undone. Otherwise, it is embeddable and we go to Step 3.
Step 3: If VAR of this block is greater than or equal to 2, we go to Step 4. Otherwise, no secret bits will be embedded.
Step 4: The secret bits Sb2 (Sb2_k × 3)ij are embedded into bitmap (Bm_k × 7)ij by using Equation where m = Sb2_k × 3, x = Bm_k × 7, F(syndrome) = ek as mentioned in Section 2.3, then go to Step 5. As for Emd, which is bit assignment function and it can be used to generate the stego image y according to Mao defined in their work [39].
Step 5: Due to the second layer of data hiding with (7, 4) Hamming code, the bitmap needs to be changed. The corresponding position of each k row in block (B_k × 7)ij needs to be changed. The four hiding strategies designed for the second layer are presented in Table  2. Input: 4 × 7 block (B _k × 7 ) ij , its two-level quantizers VAR ij and AVG ij , and two sets Sb1 and Sb2 of secret bits (Sb 1_k × 7 ) ij and Sb2 (Sb 2_k × 3 ) ij , respectively.
Output: Steog-image Step 1: Combine secret bits Sb1 (Sb 1_k × 7 ) ij and bitmap (Bm _k × 7 ) ij for the current processing (i, j) block to derive the modified pixel values according to data hiding rules listed in Table 1.
Step 2: Check the hidden pixels in a block. If the number of different hidden pixels is 1 or 2, the current block is un-embeddable and all modifications conducted in Step 1 must be undone. Otherwise, it is embeddable and we go to Step 3.
Step 3: If VAR of this block is greater than or equal to 2, we go to Step 4. Otherwise, no secret bits will be embedded.
Step 4: The secret bits Sb2 (Sb 2_k × 3 ) ij are embedded into bitmap (Bm _k × 7 ) ij by using Equation (8) [38], where m = Sb 2_k × 3 , x = Bm _k × 7 , F(syndrome) = e k as mentioned in Section 2.3, then go to Step 5. As for Emd, which is bit assignment function and it can be used to generate the stego image y according to Mao defined in their work [39].
Step 5: Due to the second layer of data hiding with (7, 4) Hamming code, the bitmap needs to be changed. The corresponding position of each k row in block (B _k × 7 ) ij needs to be changed. The four hiding strategies designed for the second layer are presented in Table 2. Step 6: If the number of modified pixel values S is equal to 5 for the current processing block, or if the number of modified pixel values S is equal to 6, but the block is determined as irreversible; which indicates that either continuity feature, the parity of modified pixel values is not holding or more than one pixel value has been changed after second-layer data embedding. All modifications made in Step 5 are cancelled and returned to the previous state.
Step 7: Proceed to the next block until all blocks have been completed. Finally, output the steog-image.

Example of Data Embedding Phase
An example is provided here to demonstrate the two-layer data hiding strategies shown in  Although the rules of reversibility are defined in Step 3 of data embedding phase, two cases of unreversible blocks are demonstrated below. These cases deem a block to be unreversible when it contains six or more different pixels. Here, blocks B1, B2, and B3 are used to demonstrate the application of our un-reversible rule in second-layer embedding.
Block B1, for instance, contains six pixels {4, 5, 6, 7, 23, 24} after second-layer data embedding. After checking the continuity feature and parity values of the modified pixels {4, 5, 6, 7, 23, 24}, we see two sublists-{4, 5, 6, 7} and {23, 24}. This is the "42" type, since, after second-layer data embedding, eight pixels at most can be found in the list of different pixels {(AVG -VAR − 2, AVG -VAR − 1, AVG − VAR, AVG − VAR + 1), (AVG + VAR, AVG + VAR − 1, AVG + VAR + 1, AVG + VAR + 2)}. By mapping the two sublists {4, 5, 6, 7} and {23, 24}, we can only conclude that AVG -VAR = 6. In other words, we cannot calculate the exact value of AVG and VAR for block B1. Therefore, block B1 is determined to be unembeddable, and all modifications conducted in the second layer must be cancelled. The situation in block B3 is the same. As for block B2, two sublists can be found-  To conduct the first-layer data embedding, the first secret bit stream Sb1 is combined with a 4 × 7 bitmap. Note that the combination merges the first bit of Sb1 with that of the 4 × 7 bitmap as '00'. Follow the same concept, there are 28 pairs are derived. Take the first pair as '00' for example, its pixel value should be modified as 44 (= 50 − 6) according to rule of Case00 defined in Table 1 Table 1.
Once first-layer data embedding is completed, the second-layer data embedding begins. Noted that the number of different pixels is more than 3 in above example; therefore, all 4 × 7 blocks will be proceeded by conducting the second-layer data embedding to conceal secret bits of Sb2. For a given 4 × 7 block, the first seven bits are selected from the first row of the corresponding 4 × 7 bitmap as x as defined in Equation (8), and the first three bits are then selected from the second bit stream Sb2 to serve as m as defined in Equation (8). Finally, syndrome = (110) T x is obtained, and its corresponding position is identified as the first row in H0. Take the first three bits of Sb2 as {010} for example. The first bit denoted '0' of the first row of the 4 × 7 bitmap is determined to be changed according to Equation (8) and its corresponding modified pixel is equal to AVG − VAR after the first-layer data embedding. It can be categorized as Case00 as defined in Table 2. In other words, the corresponding pixel should be modified as 45(= AVG − VAR + 1 = 44 + 1). Following the same concept, the seventh position in the second row, the fourth position in the third row and the second position in the fourth row of Figure 3 are classified as Case11, Case00, and Case11, respectively. All modified pixels have been marked in blue, red, yellow, and green for different rows as shown in Figure 3 to provide a visual representation. Finally, the stego pixels after second-layer data embedding are {45 44 44  57 57 56 57; 44 44 43 57 57 57 58; 44 43 43 45 44 57 44; 44 58 44 57 44 56 57}. To ensure that reversibility can be guaranteed after data extraction, reversibility must be checked according to the rules defined in Step 6 of the data embedding phase.
Although the rules of reversibility are defined in Step 3 of data embedding phase, two cases of unreversible blocks are demonstrated below. These cases deem a block to be unreversible when it contains six or more different pixels. Here, blocks B1, B2, and B3 are used to demonstrate the application of our un-reversible rule in second-layer embedding.
Block B1, for instance, contains six pixels {4, 5, 6, 7, 23, 24} after second-layer data embedding. After checking the continuity feature and parity values of the modified pixels {4, 5, 6, 7, 23, 24}, we see two sublists-{4, 5, 6, 7} and {23, 24}. This is the "42" type, since, after second-layer data embedding, eight pixels at most can be found in the list of different pixels {(AVG -VAR − 2, AVG -VAR − 1, AVG − VAR, AVG − VAR + 1), (AVG + VAR, AVG + VAR − 1, AVG + VAR + 1, AVG + VAR + 2)}. By mapping the two sublists {4, 5, 6, 7} and {23, 24}, we can only conclude that AVG -VAR = 6. In other words, we cannot calculate the exact value of AVG and VAR for block B1. Therefore, block B1 is determined to be un-embeddable, and all modifications conducted in the second layer must be cancelled. The situation in block B3 is the same. As for block B2, two sublists can be found-{43, 44, 45} and {56, 57, 58}-but there are two possible candidates for the former: {AVG -VAR − 2 , AVG -VAR − 1, AVG − VAR} and {AVG -VAR − 1, AVG − VAR, AVG -VAR + 1}. The same holds for the latter; therefore, it can be concluded that the modified pixel values have no parity property and block B2 is determined as unreversible one. Once the blocks listed in Table 3 are determined to be unreversible, all modifications conducted in the second-layer embedding will be undone and (Sb2 _k × 3 ) will be embedded into the next block.

Extraction and Recovery Phase
Before the extraction and recovery phase, eight cases are concluded and guide the receiver to derive AVG and VAR according to the number of different modified pixels in a given block after two-layer data embedding. However, by mapping to the two-layer data embedding, two categories can be produced, depending on whether one-layer or two-layer data embedding has been conducted. If the numb of modified pixels is 3 or 4, only the first layer of the embedding phase has been performed and the current processing block only carries secret bits Sb1, so the original extraction phase defined in Lin et al.'s method [31] is applied. In contrast, if the number of modified different pixels is greater than or equal to 6, then secret bits Sb1 and Sb2 have been concealed in the current processing block. It is noted that the number different pixel values would not be equal to 5 since the second layer data hiding is terminated as mentioned in Step 6 in the data embedding phase to maintain the reversibility. To extract the hidden Sb2, our proposed extraction rules are listed below along with an overview of our extraction phase ( Figure 4). As we mentioned earlier, S = 5 is not shown in Figure 4 because our embedding operation of the second layer is terminated if the number of different values is equal to 5.

Extraction and Recovery Phase
Before the extraction and recovery phase, eight cases are concluded and guide the receiver to derive AVG and VAR according to the number of different modified pixels in a given block after two-layer data embedding. However, by mapping to the two-layer data embedding, two categories can be produced, depending on whether one-layer or two-layer data embedding has been conducted. If the numb of modified pixels is 3 or 4, only the first layer of the embedding phase has been performed and the current processing block only carries secret bits Sb1, so the original extraction phase defined in Lin et al.'s method [31] is applied. In contrast, if the number of modified different pixels is greater than or equal to 6, then secret bits Sb1 and Sb2 have been concealed in the current processing block. It is noted that the number different pixel values would not be equal to 5 since the second layer data hiding is terminated as mentioned in Step 6 in the data embedding phase to maintain the reversibility. To extract the hidden Sb2, our proposed extraction rules are listed below along with an overview of our extraction phase ( Figure 4). As we mentioned earlier, S = 5 is not shown in Figure 4 because our embedding operation of the second layer is terminated if the number of different values is equal to 5. Input: steog-image (Imag_k × 7)ij Output: secret bits Sb1, secret bits Sb2, AVG and VAR Input: steog-image (Imag_ k × 7 ) ij Output: secret bits Sb1, secret bits Sb2, AVG and VAR Step 1: Count the amount of modified values denoted as S, and S = {1, 2, 3, 4, 6, 7, 8} inside the current processing stego-block. If S is 1 or 2, then the stego-block has carried no secret. Otherwise, go to Step 2. It is noted that S would not equal to 5 since the embedding operation in the second layer data hiding is not proceeded when the number of different pixel values is equal to 5.
Step 2: If the different pixel values S is less than 6, then go to Step 3. Otherwise, go to Step 5.
Step 3: If S = 3, follow the flowchart for the extraction phase, shown in Figure 5. Sort the three different values as x 1 <x 2 <x 3 , and compare (x 3 -x 2 ) and ( x 2 -x 1 ). If x 3 -x 2 > x 2x 1 , x 1 ∈ case10 and x 2 ∈ case00, then check the parity property among x 3 , x 2 ; if Parity(x 3 , x 2 ) = 0, then x 3 and x 2 are either both even or odd, and it can be concluded that x 3 ∈ case01. Otherwise, x 3 ∈ case11. If x 3 − x 2 < x 2 − x 1 , then x 2 ∈ case01. and x 3 ∈ case11.. Check the parity property between x 2 and x 1 . If Parity(x 1 , x 2 )=0, then x 1 and x 2 are either both even or both odd, and x 1 ∈ case00. Otherwise, x 1 ∈ case10. Since we know three pixels, the fourth can be calculated according to Table 1. Then, from Table 1, we can easily extract Sb1 and calculate AVG and VAR.
Step 4: If S = 4, we sort the different pixel values as x 1 < x 2 < x 3 < x 4 and directly calculate AVG and VAR by the formula AVG = x 3 +x 2 2 , VAR = x 3 −x 2 2 . According to Table 1, we can extract Sb1.
Check the parity property between x2 and x1. If Parity(x1, x2)=0, then x1 and x2 are either both even or both odd, and ∈ 00. Otherwise, ∈ 10. Since we know three pixels, the fourth can be calculated according to  Step 4: If S = 4, we sort the different pixel values as and directly calculate AVG and VAR by the formula = , = . According to Table 1, we can extract Sb1.
Step 5: If S = 6, go to Step 6. If S = 7, go to Step 7. Otherwise, go to Step 8.
Step 6: If S = 6, following the flowchart for the extraction phase in Figure 6, sort the different pixel values as , which can be divided into three Types: 42, 24 and 33. Since Type 42 has the same situation as Type 24, we illustrate Types 42 and 33 as Figures 6 and 7, respectively. Step 5: If S = 6, go to Step 6. If S = 7, go to Step 7. Otherwise, go to Step 8.
Step 6: If S = 6, following the flowchart for the extraction phase in Figure 6, sort the different pixel values as x 1 < x 2 < x 3 < x 4 < x 5 < x 6 , which can be divided into three Types: 42, 24 and 33. Since Type 42 has the same situation as Type 24, we illustrate Types 42 and 33 as Figures 6 and 7, respectively.     Step 7: If S = 7, the flowchart for extraction is shown in Figure 8. Sort the different pixel values as x 1 < x 2 < x 3 < x 4 < x 5 < x 6 < x 7 , which can be divided into Types 43 and 34, where "43" means that the first four values are less than AVG, and the last three are greater than AVG. Type 34 is the opposite, so we simply illustrate the former Type 43 in Figure 8. If x 1 + x 4 = x 2 + x 5 and x 3 − x 2 = 1, then the leftmost four pixels are continuous natural numbers. It is noted that x 3 =AVG-VAR. In this case, we simply need to check the rightmost four pixels: (1) if 2x 6 = x 5 + x 7 , then the rightmost three pixels are continuous natural numbers. Then check the parity of x 3 and x 5 . If Parity(x 3 ,x 5 ) = 0, then it can be concluded that x 5 = AVG + VAR. So insert x 5 -1 between x 4 and x 5 , and go to Step 8. Otherwise, it can be concluded that x 6 = AVG + VAR. In this case, insert x 7 +1 behind x 7 , and go to Step 8; (2) if 2x 6 > x 5 + x 7 , then the rightmost three pixels are not continuous natural numbers, so x 7 is closer to x 6 than to x 5 , and x 5 and x 6 are not continuous natural numbers; therefore, insert x 5 + 1 between x 5 and x 6 , and go to Step 8; (3) if 2x 6 < x 5 + x 7 , we do the same as in (2), then insert x 6 + 1 between x 6 and x 7 , and go to Step 8.
Step 8: If S = 8, sort the eight different values as x 1 < x 2 < x 3 < x 4 < x 5 < x 6 < x 7 < x 8 , and we can conclude that x 1 , x 2 ∈ case10, x 3 , x 4 ∈ case00, x 5 , x 6 ∈ case0, x 7 , x 8 ∈ case11. Next, check whether pixels located in the kth column and mth row in the block are equal to either x 1 , x 4 , x 5 , or x 8 . If so, then flip the corresponding bit value of the bitmap. Otherwise, no pixels have been flipped in any row. Finally, multiply H 0 T with each block according to Equation (9) to extract the hidden secret (Sb2 _k × 3 ) ij .
where m' is extracting Sb2, and y is the changed value of (Bm _k × 7 ) ij .
= AVG + VAR. So insert x5-1 between x4 and x5, and go to Step 8. Otherwise, it can be concluded that x6 = AVG + VAR. In this case, insert x7+1 behind x7, and go to Step 8; (2) if 2x6 > x5 + x7, then the rightmost three pixels are not continuous natural numbers, so x7 is closer to x6 than to x5, and x5 and x6 are not continuous natural numbers; therefore, insert x5 + 1 between x5 and x6, and go to Step 8; (3) if 2x6 < x5 + x7, we do the same as in (2), then insert x6 + 1 between x6 and x7, and go to Step 8. Step 8: If S = 8, sort the eight different values as , and we can conclude that , ∈ 10 , , ∈ 00 , , ∈ 0, , ∈ 11. Next, check whether pixels located in the kth column and mth row in the block are equal to either x1, x4, x5, or x8. If so, then flip the corresponding bit value of the bitmap. Otherwise, no pixels have been flipped in any row. Finally, multiply H0 T with each block according to Equation (9) to extract the hidden secret (Sb2_k × 3)ij. m' = H0 syndrome, (9) where m' is extracting Sb2, and y is the changed value of (Bm_k × 7)ij.  Figure 4, the number of different pixel values in a 4 × 7 block is 6. Sorting these six different values yields a sorted value stream of {43, 44, 45, 56, 57, 58}. In this stream, there are three continuous values on the left and three on the right. Therefore, the block shown in Figure 10 is Type 33, because it satisfies 2x 2 = x 1 + x 5 and 2x 5 = x 4 + x 6 . According to the flowchart of the extraction phase shown in Figure 8, two pixels have the same values as x 1 = 43, and they are located in the same row (marked in red). This means that it cannot be the changed pixel, so insert x 1 -1 = 42 in front of x 1 . Here, a new sorted value stream-denoted as {42, 43, 44, 45, 56, 57, 58}-is obtained and belongs to Type 43.
Since this value stream has seven different pixel values, it belongs to Type 43 and satisfies 2x 6 = x 5 + x 7 , so the parity of x 3 and x 6 is checked. In this case, x 3 = 44 and x 6 = 56, both of which are even, so Parity (x 4 , x 6 ) = 0; therefore, x 5 − 1 = 55 is inserted between x 4 and x 5 , and a new sorted value stream is obtained-{42, 43, 44, 45, 55, 56, 57, 58}. Eventually, we can see that {42, 43} belongs to Case 10; {44, 45} belongs to Case 00; {55 56} belongs to Case 01; and {57, 58} belongs to Case 11, based on Step 8 of the extraction and recovery algorithm shown in Figure 4. Finally, the original two quantizer levels can be easily derived from AVG = (44 + 56)/2 = 50 and VAR = (56 − 44)/2 = 6, respectively. Based on the rules listed in Table 1, two bits can be derived from a pixel, and a bit block can be transformed from the pixel block. The former bits (marked red in Figure 10) can be collected to obtain the hidden secret bits Sb1. The remaining bits are collected to derive the bitmap. From 45, 58, 45, and 58-colored blue, red, yellow, and green in the pixel block, respectively-we know that the values of the bitmap need to be changed in the corresponding positions. Thus, we change the original bitmap value of the corresponding position to its opposite value. And by multiplying H T 0 , we obtain the secret bits Sb2.
stream of {43, 44, 45, 56, 57, 58}. In this stream, there are three continuous values on the left and three on the right. Therefore, the block shown in Figure 10 is Type 33, because it satisfies 2x2 = x1 + x5 and 2x5 = x4 + x6. According to the flowchart of the extraction phase shown in Figure 8, two pixels have the same values as x1 = 43, and they are located in the same row (marked in red). This means that it cannot be the changed pixel, so insert x1 -1 = 42 in front of x1. Here, a new sorted value stream-denoted as {42, 43, 44, 45, 56, 57, 58}is obtained and belongs to Type 43. Since this value stream has seven different pixel values, it belongs to Type 43 and satisfies 2x6 = x5 + x7, so the parity of x3 and x6 is checked. In this case, x3 = 44 and x6 = 56, both of which are even, so Parity (x4, x6) = 0; therefore, x5 − 1 = 55 is inserted between x4 and x5, and a new sorted value stream is obtained-{42, 43, 44, 45, 55, 56, 57, 58}. Eventually, we can see that {42, 43} belongs to Case 10; {44, 45} belongs to Case 00; {55 56} belongs to Case 01; and {57, 58} belongs to Case 11, based on Step 8 of the extraction and recovery algorithm shown in Figure 4. Finally, the original two quantizer levels can be easily derived from AVG = (44 + 56)/2 = 50 and VAR = (56 − 44)/2 = 6, respectively. Based on the rules listed in Table 1, two bits can be derived from a pixel, and a bit block can be transformed from the pixel block. The former bits (marked red in Figure 10) can be collected to obtain the hidden secret bits Sb1. The remaining bits are collected to derive the bitmap.  From 45, 58, 45, and 58-colored blue, red, yellow, and green in the pixel block, respectively-we know that the values of the bitmap need to be changed in the corresponding positions. Thus, we change the original bitmap value of the corresponding position to its opposite value. And by multiplying , we obtain the secret bits Sb2.

Experiment Results and Discussions
This section presents experimental results to demonstrate how our proposed method outperforms existing methods. All experiments were implemented in MATLAB R2014b on a PC with Intel ® Core (TM) i7-8750H CPU @2.20 GHz, 16 GB RAM. Ten standard grayscale images of 512 × 512 resolution-Lena, F16, Barbara, Gold hill, Wine, Bird, Zelda, Boat, Baboon, and Peppers shown in Figure 10-were drawn from the USC-SIPI data [40]. Three criteria are utilized to measure the performance of the proposed methodpeak signal-to-noise ratio (PSNR), hiding capacity (HC) and embedding efficiency rate (ER). As we know that PSNR is used to estimate the visual quality of an AMBTC-compressed image, which is defined in Equation (10)

Experiment Results and Discussion
This section presents experimental results to demonstrate how our proposed method outperforms existing methods. All experiments were implemented in MATLAB R2014b on a PC with Intel ® Core (TM) i7-8750H CPU @2.20 GHz, 16 GB RAM. Ten standard grayscale images of 512 × 512 resolution-Lena, F16, Barbara, Gold hill, Wine, Bird, Zelda, Boat, Baboon, and Peppers shown in Figure 10-were drawn from the USC-SIPI data [40].
Three criteria are utilized to measure the performance of the proposed method-peak signal-to-noise ratio (PSNR), hiding capacity (HC) and embedding efficiency rate (ER). As we know that PSNR is used to estimate the visual quality of an AMBTC-compressed image, which is defined in Equation (10), where x i,j and x' i,j indicates the pixel value of the coordinate (i, j) of the original image and of the AMBTC-compressed steog-image, respectively. HT and WH represent the height and width of the image, respectively.
To examine the performance of different types of RDH schemes, we utilize the embedding efficient rate (ER) by Equation (11) where HC and stego_size represent the total of embedded secret bits and the size of stego bitstream codes, respectively. An embedding method with higher ER indicates that it offers a larger payload for stego bitstream codes.

Performance of Proposed Method
In this subsection, we demonstrate the performance of our improved method under different partitions. Our improved method can restore the original two quantizer levels AVG and VAR from the steog-image, apart from special cases when the number of different pixels in a block is 6, but the block is determined to be irreversible after data embedding. Such unique cases are presented in Table 4 under different partitions.
Here, we can see that even in a 4 × 7 partition, only one case is found in Lena, Barbara, and Zelda, respectively. It is concluded that these irreversible blocks do not affect the hiding capacity of our improved method. Therefore, no extra information is required to record these irreversible data. It is simple to ignore or cancel the modification that has been done once the block is determined to be irreversible. Through this arrangement, the reversibility of our improved method is maintained while achieving a high hiding capacity.
The performance of our proposed method with different block sizes is shown in Table  5. Although the first-layer hiding strategy is the same as Lin et al.'s method [9], we changed the partition size in our improved method from 4 × 4 to 4 × 7 or 8 × 7, to extend it to the second-layer data hiding operations. Therefore, we can see that the PSNR of the first layer is slightly lower with our improved method than that achieved by the original AMBTC. With our proposed method, the 'Bird' and 'Baboon' images, which are relatively complex, have a lower PSNR, but a higher capacity in 4 × 7 and 8 × 7 partitions. This is because they offer more blocks that contain six or more different pixel values in a block, as compared with smoother images. The hiding capacity of 'Wine', for example, can be increased from 343,096 to 35,072 bits when a block size is changed from 4 × 7 to 8 × 7. As for the remaining images, the general increased number of secret bits remains around 10,000 bits. This is because in the larger partition, with fewer smooth blocks, there are more numerous embeddable blocks. If we explore the relationship between the hiding capacity and PNSR with our proposed method, we can see that that the highest hiding capacity with our proposed two-layer data hiding strategies is up to 368,348 bits with 'Baboon' under block size 4 × 7 while maintaining PSNR as 25.6 dB which is lower 0.5 dB than the original BTC. This is because we adopt the (7, 4) Hamming code to achieve the reversible data hiding in the second layer. With the concept of (7, 4) Hamming code, three secret bits can be embedded into the embeddable stego blocks after the first layer data hiding at the cost of single bit modification. Certainly, to maintain all modifications caused in the second layer can be successfully restored in the recovery phase, many rules are designed to decide whether the stego blocks after the first layer can be proceeded in the second layer data hiding or not. However, in Table 5 we will find such judgements do not cause too much computation cost but make sure the reversibility of our proposed method. Because the 4 × 7 and 8 × 7 partitions are not generally adopted by conventional AMBTC, we slightly modified our partition to n × n in order to increase applicability. Corresponding data is presented in Table 5. Generally speaking, six different pixels can be found inside a 4 × 4 block when adopting our proposed (7, 4) Hamming code-based data hiding strategy. This is because in a 4 × 4 block, two sets can be obtained, each of which has 7 bits derived from its corresponding bitmap. The core concept of (7, 4) Hamming code is that only one bit is modified after data embedding. Under such circumstances, our improved method would not retain enough information to conclude the original two quantizer levels VAR and AVG in the extraction and recovery phase. Therefore, our embedding strategy must be slightly modified as follows.
First, all n × n embeddable blocks are expanded into 1 × n 2 and linked together to form a (1 × n) 2 × N table, where N denotes the number of embeddable blocks. 1 × 7 continuous bits are selected from the bitmap to conduct our proposed (7, 4) Hamming code-based data hiding strategy. The only modification is as follows: when the mth bit is determined to be changed after the (7,4) Hamming code-based data hiding strategy at the first 1 × 7 data set, the corresponding pixel of mth is then modified instead of its corresponding bit value on the bitmap. To embed the next secret bit, the second 1 × 7 data set begins from the (m + 1)th. If the second data set does not cause any modification, then the next 1 × 7 data set begins from the next seven bits. Certainly, every 4 × 4 data set needs to be checked for reversibility after data embedding. All reversibility rules are the same as above, except each row can carry more than one single secret bit. During data extraction, the corresponding bit in the bitmap is changed from '1' to '0,' or vice versa, when the first pixel value to differ from previous ones is determined. Let us assume that the first pixel value that differs is located at the mth. For the remaining data extraction, the next data set begins from the (m + 1)th. In the modified (7, 4) Hamming code-based data hiding strategy, since the construction is defined in our initial data hiding strategy: each row that hides only a single secret bit has been omitted; thus, hiding capacity increases. The experimental data of embedding capacity with our modified (7, 4) Hamming code-based data hiding strategy is shown in Table 6. Notably, the hiding capacity for 8 × 8 is significantly higher than that for 8 × 7, as shown in Table 5. The hiding capacity offered by 4 × 4 is lower than that of 4 × 7, but the corresponding PSNRs are significantly improved.

Performance Comparison with Related Studies
In this subsection, to further demonstrate our method's contribution, we compare its improved performance with five existing works, including Chang et al. [27], Lin et al. [31], Pan et al. [32], and Hong et al. [27,28] Table 6.
As shown in Table 6, the PSNR of our improved method is quite close to that of Lin et al.'s scheme, but our method has the highest HC than other existing methods. The significant difference between the proposed method and the others is that richly textured images will offer a higher hiding capacity with our improved method; i.e., 'Baboon' can carry 352,795 bits, more than doubling the capacity of Chang et al.'s method (151,439 bits). Our proposed method offers the highest HC than other methods because our method extends Lin's four hiding strategies and uses two-layer data embedding strategies. On the ER side, the result is slightly inferior to Chang et al.'s method, but compared with other methods, our ER still outperforms other methods.
Except the performance on hiding capacity, PSNR and ER, computation complexity is also the other criterion to evaluate the performance of the RDH scheme. In Table 7, the computation operations adopted in data embedding and data extracting phases are listed. We can find schemes of Lin et al. [31] and Pan et al. [32] used either table lookup or reference matrix checking to conduct data embedding and data extracting phases, respectively. Therefore, the computation complexity of both of two schemes are the lowest. As for our proposed method, there are two layers of data hiding and data extracting. The first layer data hiding operation of our proposed method simply inherits from Lin et al.'s scheme [31] but the second layer data hiding operation is (7, 4) Hamming coding. In other words, the second layer data hiding of our proposed method is matrix coding operation. In the contrast, only table lookup operation is required for both first layer and the second layer of data extracting operations. Therefore, the computation complexity of our proposed method is relatively higher than schemes of Lin et al.'s [31] and Pan et al.'s [32].  [27], they needed to perform XOR operation when embedding secret bits. Therefore, these two schemes require relatively higher computation complexity than Lin et al.'s scheme [31], Pan et al.'s scheme [32] and our proposed method. As for Hong et al.'s scheme [29], their computation complexity is the highest among six schemes because they needed to classify blocks into complex and smooth blocks first. Then, for smooth blocks, minimal distortion computation and reference matrix checking are conducted for carrying secret bits. For complex blocks, flipping operation is required to conceal secret bits.
Comparing performance on hiding capacity, PSNR, ER, and computation operations listed in Tables 6 and 7, we found the computation complexity of our proposed method is not the lowest, and it is relatively higher than that of schemes of Lin et al. [31] and Pan et al. [32]; however, the hiding capacity of our proposed method is 1.15 times of that of two schemes in the worst case. In other words, we can conclude our proposed method successfully significantly enhance the hiding capacity while maintaining acceptable computation complexity.

Conclusions
In this paper, an effective two-layer data hiding method was proposed for AMBTCcompressed images using (7, 4) Hamming code. In the first layer, four disjoint sets using different combinations of AVG and VAR are derived according to the combination of the secret bits and a bitmap, following Lin et al.'s method. In the second layer, these four disjoint sets are extended to eight by adding or subtracting 1 according to a matrix embedded with (7, 4) Hamming code. In the data extraction and recovery phase, continuity feature, parity of pixels, and the unique number of changed pixel in the same row are used to restore AVG and VAR. The experiments demonstrate that our proposed method has the highest HC among six representative BTC or AMBTC-family based RDH schemes. Moreover, the computation complexity of our proposed method is next to schemes of Lin et al.'s [31] and Pan et al.'s [32] since matrix coding is required in the second layer data hiding but only table lookup operation is required for the second layer data extracting. We can conclude our proposed method is suitable for real-time applications. However, considering attacks supported by deep learning [41] or other technologies [42] may cause the hidden security unsecure or the forged stego image. In the future, we hope to explore ways of further enhancing the security of hidden data or identifying the valid stego image while maintaining high HC and low computation complexity, so that our proposed method can be more practical for various applications.