1 Introduction

The increasing use of digital communication raises concerns about information security and privacy. In response to this, researchers designed cryptographic algorithms such as DES [8] and RSA [21], which convert digital objects (i.e., texts, images, videos, and audios) into ciphertexts for secure transmission over public channels. Although ciphertexts may be secure, their unrecognizable form alerts malicious users to the transmission of secure information. To resolve this issue, information hiding (also called data hiding) embeds secret information within cover objects, making it difficult for malicious users to distinguish between original cover objects and stego objects (i.e., cover objects embedded with secret information). Because of the minimal storage space and bandwidth consumption of compressed images, researchers have proposed reversible information hiding schemes that use compressed images as cover objects. Reversible data hiding schemes ensure that both the cover object and the secret message can be successfully restored from a stego object. In particular, many researchers used vector quantization (VQ) [9] and side match vector quantization (SMVQ) [13] compressed images as cover objects to embed secret data [2,3,4,5,6,7, 12, 14,15,16, 18,19,20, 22,23,24,25,26].

In 2011, Yang et al. [26] used the differences between a VQ index and its four adjoining neighbors to regulate their embedding capacity. The frequencies of the two smallest differences determine the number of secret bits embedded into a VQ index. To reduce the size of the output code stream, Huffman codes [10] were used as indicators. While this achieves an average bit rate of 0.494 bits per pixel (bpp), their embedding rate is 1.298 bits per index (bpi) on average. In 2013, Wang et al. [22] used the values of a VQ index’s neighbors to build two state codebooks. Because state codebooks are smaller than main codebooks, fewer bits are required to represent state codewords. Wang et al.’s adjoining state codebook mapping (ASCM) technique [22] obtains an average embedding rate of 2.441 bpi at an average bit rate of 0.496 bpp. Pan et al. [19] proposed an improvement to Chang et al.’s information hiding scheme [2] that was based on the search order coding (SOC) algorithm [11]. They extended Chang et al.’s compression codes [2] to include all SOC codes by adding an indicator bit. While this strategy gains an average bit rate of 0.457 bpp, their embedding capacity is fixed at 1 bpi. Lee et al. [14] increased the correlation among the VQ indices within the smooth regions of an image by sorting the main codebook in order of codewords’ mean values. Their algorithm utilizes coarse and fine subcodebooks to compress these highly correlated VQ indices, creating spaces to embed secret bits. Although their scheme does not perform well with complex images, it achieves a good average embedding rate of 3.046 bpi at an average bit rate of 0.540 bpp, improving the works of Chang et al. [4], Wang and Lu [23], and Chang et al. [7]. Chang et al. [6] embedded secret bits into transformed index values (TIVs). The TIVs refer to the position of a VQ index’s codeword within the state codebook generated by the SMVQ algorithm [13]. As a result, the TIVs tend to be smaller and more correlated than the VQ indices. Their scheme compresses the TIVs that are either less than eight or have a 2-bit search order code, achieving an average bit rate of 0.407 bpp. The limitations of their scheme are a fixed embedding rate of 1 bpi and ignoring SOC code 11.

In 2014, Wang et al. [24] modified the locally adaptive coding (LAC) algorithm [1] to increase the frequency of LAC stack positions in the interval [0, 7]. This created an SMVQ frequency distribution that is ideal for compression with variable bit encoding. In order to control the size of the output code stream, Wang et al.’s scheme [24] only embeds secret bits into the first four LAC stack positions. While this approach achieves an average embedding rate of 1.861 bpi at an average bit rate of 0.403 bpp, their embedding capacity decreases as image complexity and main codebook size increase.

In 2015, Lin et al. [16] combined SOC and state codebook mapping (SCM) to improve Wang et al.’s ASCM technique [22]. If a search order code does not exist for a VQ index, Lin et al.’s scheme [16] uses the SCM to build a state codebook for each search point in the SOC algorithm. This generates more state codebooks than ASCM, increasing the probability of compressing a VQ index. Lin et al.’s approach [16] embeds secret bits if the compression code is less than ψ bits. While this generates good average embedding rates of 3.035 bpi and 3.879 bpi with ψ = 8 and 9, the respective average bit rates of 0.519 bpp and 0.572 bpp are worse than the traditional VQ compression.

In 2015, Chang et al. [5] proposed the use of SMVQ and search order codes to represent the secret bits 1 and 0, respectively. Their scheme uses three of the four 2-bit search order codes (00, 01, and 10) to compress SMVQ indices. The fourth search order code, 11, is used to inform the decoder that no search order code is found. Additionally, their embedding strategy ignores the shorter search order codes when the secret bit is 1. Despite a fixed embedding capacity of 1 bpi, Chang et al.’s scheme [5] achieves excellent average bit rates of 0.368 and 0.417 bpp with state codebooks of sizes 32 and 64.

In order to improve the embedding capacity and bit rate of SMVQ-based reversible information hiding schemes, this paper proposes to classify SMVQ indices as either Case 1 or 2 based on the value of the minimum side match distortion (SMD) and a threshold t. This classification increases the probability of Case 1 SMVQ indices belonging to the interval [0, a], and Case 2 SMVQ indices belonging to the interval [a + 1, M − 1], where a = 2w − 1, w = 0, 1, 2, 3, ..., ⌈log2 M⌉, and M is the state codebook size. The proposed scheme controls the length of compression codes used for these subintervals through the value of a parameter . Therefore, when a Case 1 or 2 SMVQ index is detected, the proposed scheme can switch between compression codes optimized for the subintervals [0, a] and [a + 1, M − 1]. After an SMVQ index is compressed, n secret bits are appended to its compression code, where n = 1, 2, 3, or 4. Performance comparisons with the recent works of Chang et al. [5], Chang et al. [6], Lin et al. [16], and Wang et al. [24] confirm that our proposed scheme improves the embedding capacity and bit rate of recent reversible VQ and SMVQ-based data hiding schemes.

The remainder of this paper is organized as follows: Section 2 reviews related works. Section 3 describes the proposed scheme. Section 4 presents the experimental results and comparisons to the recent works [5, 6, 16, 24]. Section 5 summarizes the contributions of this paper.

2 The related works

2.1 Vector quantization

Vector quantization (VQ) is a lossy data compression technique proposed by Gray in 1984 [9]. VQ has three components, namely, codebook generator, VQ encoder, and VQ decoder. The codebook D containing N k-dimensional codewords CW y ’s is generated by using the LBG clustering algorithm [17], where CW y  = (cw y,0, cw y,1, ..., cw y,k-1). A grayscale image G sized H × W to be compressed is then divided into nonoverlapping pixel blocks Xs, each of size p × q, where p × q = k. These pixel blocks are processed in raster scan order (i.e., left to right and top to bottom). The VQ encoder compresses each pixel block X by searching the codebook D and selecting the codeword CW r with the smallest Euclidean distance from X. The Euclidean distance between X and CW y is defined as

$$ ED\left( X,{CW}_y\right)=\sqrt{\sum_{i=0}^{p-1}\sum_{j=0}^{q-1}{\left({X}_{i, j}-{cw}_{y, p\times i+ j}\right)}^2}, $$

where X i,j is the jth component in the ith row of the pixel block X, CW y is the yth codeword in D, and cw y,z (z = p × i + j) is the zth component of CW y . The index value r (0 ≤ r ≤ N − 1) of the chosen codeword CW r (i.e., the best-matched or optimal codeword) is then added into the VQ index table VIT sized (H/p) × (W/q) in raster scan order. Each VQ index in VIT is represented by using ⌈log2 N⌉ bits. The VQ decoder reconstructs the image G from the received VQ index table VIT and the codebook D. Each pixel block X of the image G is reconstructed by replacing each VQ index in VIT with the corresponding k-dimensional codeword in D.

2.2 Side match vector quantization

Side match vector quantization (SMVQ) was designed by Kim in 1992 [13] to improve the bit rate of vector quantization [9]. Kim proposed the use of a smaller state codebook (also called subcodebook) Y of size M instead of the codebook D sized N used in VQ (D is also known as super or main codebook). Since M < N, the number of bits used for an SMVQ index (i.e., ⌈log2 M⌉ bits) is less than that used for a VQ index (i.e., ⌈log2 N⌉ bits). SMVQ divides a grayscale image G sized H × W into nonoverlapping pixel blocks Xs, each of size p × q. These pixel blocks are processed in raster scan order. Pixel blocks in the first row and column are encoded using the VQ encoder with the main codebook, and residual blocks (i.e., blocks are not in the first row or column) are encoded using the SMVQ encoder with the state codebook.

Given the upper and left adjacent pixel blocks, denoted as U and L, of the current pixel block X, as shown in Fig. 1, the boundary pixel vector (BV) of the current pixel block X (also called the state vector X’) is defined as BV(X) = (X 0,0, X 0,1, ..., X 0,q-1, X 1,0, X 2,0, ..., X p-1,0), where X 0,0 = (U p-1,0 + L 0,q-1) / 2, X 0,1 = U p-1,1, ..., X 0,q-1 = U p-1,q-1, X 1,0 = L 1,q-1, ..., X p-1,0 = L p-1,q-1. The SMD between the BV(X) and a codeword CW y  = (cw y,0, cw y,1, ..., cw y,q-1, ..., cw y,p×q-1) in the main codebook D is defined as

$$ SMD\left( BV(X),{CW}_y\right)=\sqrt{\sum_{j=0}^{q-1}{\left({X}_{0, j}-{cw}_{y, j}\right)}^2}+\sqrt{\sum_{i=1}^{p-1}{\left({X}_{i,0}-{cw}_{y, i\times q}\right)}^2}. $$
Fig. 1
figure 1

Adjacent pixel blocks U, L, and X used in SMVQ

The codewords of the main codebook D are sorted in ascending order based on the SMDs with the BV(X). The first M codewords are then selected to be the state codewords SCW y ’s for the state codebook Y, where 0 ≤ y ≤ M − 1. Similar to VQ, the input pixel block X is replaced with the ⌈log2 M⌉-bit representation of an SMVQ index x in the state codebook Y. The SMVQ index x refers to the state codeword SCW x with the smallest Euclidean distance to X—that is, ED(X, SCW x ) ≤ ED(X, SCW y ) for all SCW y in Y, where SCW y is the yth state codeword in the state codebook Y.

2.3 Chang et al.’s method

In 2013, Chang et al. [6] proposed a hybrid information hiding scheme combining SMVQ and SOC [11]. Their scheme introduced the use of TIVs for the VQ-based reversible information hiding scheme. A TIV d refers to a state codeword SCW d that is equal to the best matched (or optimal) codeword CW r selected by the VQ algorithm for an input pixel block X. That is, ED(CW r , SCW d ) ≤ ED(CW r , SCW y ) for all SCW y in Y, where SCW y is the yth state codeword in the state codebook Y. Because M = N, there exists a unique d such that ED(CW r , SCW d ) = 0 and SCW d  = CW r . As a result, the SMVQ decoder can be used to reconstruct the VQ compressed image from the TIT. The following summary of their encoding and embedding algorithm is cited from Chang et al. [6]. The extraction algorithm is simply the inverse process of the encoding and embedding algorithm.

2.3.1 Encoding and embedding algorithm

Input: Grayscale cover image G, super codebook D, confidential message S.

Output: An output binary code stream CS.

  1. Step 1:

    Encode cover image G using VQ encoding to obtain index table VIT.

  2. Step 2:

    Transform index table VIT using SMVQ to create transformed index table TIT.

  3. Step 3:

    Read transformed index d from the transformed index table TIT.

  4. Step 4:

    Search for the SOC code of transformed index d, and read the confidential bit b from confidential message S.

  5. Step 5:

    If b = 1 and d ≤ 7 then d is encoded by the indicator bits 10 followed by the 3-bit binary representation of d. However, if b = 1 and d > 7 then d is encoded by the indicator bits 11 followed by the ⌈log2 N⌉-bit binary representation of d.

  6. Step 6:

    Otherwise, (i.e., b = 0), one of the following steps is employed:

  7. Step 6.1:

    If d has a SOC code in the range 0 to 22–2 then d is encoded by the indicator bit 0 followed by the 2-bit SOC code of d.

  8. Step 6.2:

    Otherwise (i.e., d does not have an SOC code), if b = 0 and d ≤ 7 then d is encoded by the indicator bits 011, followed by the 3-bit binary representation of d. However, if b = 0 and d > 7 then d is encoded by the indicator bits 011 followed by the ⌈log2 N⌉-bit binary representation of d.

  9. Step 7:

    Finally, the compression code for d is concatenated to the code stream CS.

  10. Step 8:

    Steps 3–7 are repeated until all indices are processed.

2.4 Lin et al.’s method

Lin et al. [16] proposed a hybrid data hiding scheme for VQ compressed images based on SOC [11] and SCM [22]. Their scheme locates the current VQ index r through a process of elimination. If r is not found in the SOC path, Lin et al.’s method [16] uses a state codebook mapping (SCM) procedure to generate a state codebook of size M for each search point within the SOC path. Specifically, given the VQ index value of the current search point y, a list of unseen codewords from the main codebook is created. That is, all the codewords contained in any of the state codebook(s) built so far, and all the codewords referenced by the VQ index values of any search point within the SOC path are ignored. The following summary of their encoding and embedding algorithm is cited from Lin et al. [16]. Their decoding and extraction algorithm is simply the inverse process of the encoding and embedding algorithm.

2.4.1 Encoding and embedding algorithm

Input: VQ index table, per block output length ψ, SOC bit length v, secret data.

Output: Compression codes

  1. Step 1:

    Input an index from the VQ index table, which is processed in raster scan order.

  2. Step 2:

    Find a search point with the same VQ index r in the predefined SOC path of the index table until the current processed index cannot be encoded with any of the 2v SOC codes, or a matched search point is found.

  3. Step 3:

    If a matched search point is found, follow the SOC embedding procedure and encode r with the indicator bit 0, followed by the corresponding SOC code and (ψ − v − 1) secret bits; otherwise, the SCM procedure is performed (see below).

  4. Step 4:

    Go to Step 1 and encode the next VQ index until all indices have been processed.

2.4.2 State codebook mapping procedure (SCM)

Input: Current processed index r, main codebook D length N, SOC bit length v, secret data, state codebook length M, search points (i.e., indices in the SOC path), and per block output length ψ.

Output: Compression code of in process index.

  1. Step 1:

    Generate a state codebook with M unseen VQ indices for each search point.

  2. Step 2:

    Find an element in all state codebooks with the same VQ index as that of r.

  3. Step 3:

    If an element is found at position p in the state codebook of the corresponding search point, then r is encoded with the indicator bits 10, followed by the corresponding v-bit SOC code, followed by the ⌈log2 M⌉-bit binary representation of p, followed by (ψ − v − ⌈log2 M⌉ − 2) secret bits. Otherwise, r is preserved, and is encoded with the indicator bits 11, followed by the ⌈log2 N⌉-bit binary representation of r.

2.5 Chang et al.’s method

Chang et al.’s scheme [5] encodes residual SMVQ indices using the SOC algorithm with a state codebook size M = 32 or 64. Because M is less than the super codebook size N (i.e., M < N), the visual quality of the reconstructed image is reduced and their scheme is only reversible for SMVQ compressed images. Despite this, Chang et al. [5] can embed 1 bit per residual SMVQ index at excellent bit rates. The following summary of Chang et al.’s encoding and embedding algorithm [5] is cited from their paper. The decoding and extraction algorithm is simply the inverse process of the encoding and embedding algorithm.

2.5.1 Encoding and embedding algorithm

Input: Each input pixel block X of cover image G in raster scan order and secret message S.

Output: Compression code C of image G, including secret message S.

  1. Step 1:

    Encode image G by using SMVQ to obtain index table SIT.

  2. Step 2:

    Read SMVQ index x in the residual area of index table SIT.

  3. Step 3:

    Determine the SOC code for index x, and read a secret bit b from secret message S.

  4. Step 4:

    If the SOC code is determined, and the SOC code ≤22–2. Perform one of the following steps:

  5. Step 4.1:

    If b = 1, index x is denoted by indicator bit 1, followed by the ⌈log2 M⌉-bit binary representation of x.

  6. Step 4.2:

    If b = 0, index x is denoted by indicator bit 0, followed by the two-bit SOC code of index x.

  7. Step 5:

    If the SOC code is not determined for index x, perform one of the follow ing steps:

  8. Step 5.1:

    If b = 1, index x is denoted by indicator bit 1, followed by the ⌈log2 M⌉-bit binary representation of x.

  9. Step 5.2:

    If b = 0, index x is denoted by indicator bit 0, followed by the two-bit binary information of 22–1, followed by the ⌈log2 M⌉-bit binary representation of x.

  10. Step 6:

    The compression code of index x is concatenated to the C.

  11. Step 7:

    Repeat Steps 2 through 6 until all indices in the residual area of in dex table SIT have been processed.

3 The proposed method

The proposed scheme exploits the frequency distributions of SMVQ indices in the intervals [0, a] and [a + 1, M - 1] where a = 2w - 1 and w = 1, 2, 3, ..., ⌈log2 M⌉. As illustrated in Fig. 2, it can be seen that the frequency distribution of indices in the interval [0, 3] (e.g., a = 3) is much higher than the frequency distribution of indices in the [4, 255]. This implies that compression codes that are optimal for indices in the smaller interval [0, 3] are not optimal for indices in the larger interval [4, 255] and vice versa. Thus, if the proposed scheme can classify an SMVQ index x into either the interval [0, a] or [a + 1, M - 1], then it can use the optimal the compression codes for each interval. To achieve this goal, the proposed scheme compares a predefined threshold value t to the SMD value of the first state codeword, SMD(X’, scw 0), where the state vector X’ is the boundary pixel vector BV(X) as described in Section 2.2. Therefore, when the SMD(X’, scw 0) ≤ t, we assume that the SMVQ index x is in the interval [0, a] (i.e., Case 1). Otherwise, (i.e., SMD(X’, scw 0) > t) we assume that x is in the interval [a + 1, M - 1] (i.e., Case 2). During the development of the proposed scheme, we experimented with more than two intervals such as 3, 4, and up to 10 intervals, but we found that the two intervals [0, a] and [a + 1, M - 1] produced the optimal result in terms of bit rate. Therefore, we decided to simplify the proposed scheme by using only two intervals. The proposed scheme exploits a feature of the SMVQ frequency distributions for the intervals [0, a] and [a + 1, M - 1], as shown in Fig. 2, to achieve a better bit rate and embedding rate.

Fig. 2
figure 2

The SMVQ frequency distribution of the test image Lena with M = N = 256

We observed that Case 1 SMVQ indices have a higher probability of belonging to the smaller interval [0, a] (e.g., [0, 3]) than the larger interval [a + 1, M − 1] (e.g., [4, 255]), where a = 2w − 1 and w = 1, 2, 3, ..., ⌈log2 M⌉. Specifically, when a = 3, t = 8, and M = N = 256, the probability that a Case 1 SMVQ index belongs to the intervals [0, 3] and [4, 255] is 0.833 and 0.167, respectively; see Fig. 3. To exploit this characteristic, we designed the Case 1 compression codes as shown in Table 1a, where α = 2,  = 0, 1, 2, 3, ..., ⌊((log2 M) − 2)/15⌋. For example, when  = 1 and M = N = 256, only Case 1 SMVQ indices that are less than 15 can be compressed (i.e., these SMVQ indexes can be represented with less than ⌈log2 M⌉ bits). Additionally, when a = 3 and t = 8, the probability that a Case 1 SMVQ index belongs to the smaller interval [0, 3] is 0.833. Therefore, with  = 1 and t = 8, the proposed scheme can compress at least 83.3% of all Case 1 SMVQ indices.

Fig. 3
figure 3

The probability of a Case 1 SMVQ index from the SMVQ index tables of the test images in Fig. 7, belonging to the intervals [0, 3] and [4, M - 1] with various values of t and M = N = 256

Table 1 The proposed compression codes

In contrast, we observed that the probability of Case 2 SMVQ indices belonging to the smaller interval [0, a] (e.g., [0, 3]) and the larger interval [a + 1, M − 1] (e.g., [4, 255]) is similar. Specifically, when a = 3, t = 8, and M = N = 256, the probability that a Case 2 SMVQ index belongs to the intervals [0, 3] and [4, 255] are 0.589 and 0.411, respectively; see Fig. 4. Because of this characteristic, the proposed scheme cannot appropriately determine whether a Case 2 SMVQ index will belong to the smaller or larger interval. Therefore, we designed the length of the Case 2 compression codes as shown in Table 1b to optimize the compression performance of the proposed method. The details of the Case 2 compression codes are presented in Table 1b, where β = 2α = 2+1. It is clear from Table 1 that the selection of appropriate values for and t is necessary to achieve a good compression. The details of how to select these values for a given codebook size are presented in Section 4.1.

Fig. 4
figure 4

The probability of a Case 2 SMVQ index from the SMVQ index tables of the test images in Fig. 7, belonging to the intervals [0, 3] and [4, M - 1] with various values of t and M = N = 256

The works of Chang et al. [6], Wang et al. [24], and Chang et al. [5] all build an SMVQ index table from the input cover image G and then compress each SMVQ index in raster scan order, creating spaces to embed secret information. In contrast, the proposed scheme compresses each SMVQ index immediately after it is generated by the SMVQ algorithm (i.e., SMVQ indices are not stored in an SMVQ index table). This ensures that the SMD values are not recomputed when the proposed scheme classifies an SMVQ index as Case 1 or 2 by comparing the SMD value of the first state codeword with the threshold value t. The details of the encoding and embedding algorithms are presented in Section 3.1, and the details of the decoding and extraction algorithms are presented in Section 3.2.

3.1 The encoding and embedding phase

The grayscale cover image G sized H × W is divided into nonoverlapping pixel blocks X, each of size k = p × q. The proposed scheme processes these pixel blocks in raster scan order. If the current pixel block X is located in the first row or column, then the proposed scheme computes the VQ index r and outputs the ⌈log2 N⌉-bit binary representation of r, followed by the next n secret bits b 1 b 2...b n to the binary code stream CS (i.e., CS = CS||b 1 b 2...b n ), where the symbol ‘||’ denotes the concatenation operation. Otherwise (i.e., X is not in the first row or column), the proposed scheme constructs the state vector X’ (i.e., the boundary pixel vector of the current pixel block X), builds a state codebook of size M, and computes the SMVQ index x. If the SMD between the first state codeword scw 0 and the state vector X’ is less than or equal to the predefined threshold value t (i.e., SMD(X’, scw 0) ≤ t), the SMVQ index x is classified as Case 1, and the compression code z is generated by following the rules defined in Table 1a. Otherwise (i.e., SMD(X’, scw 0) > t), the SMVQ index x is classified as Case 2, and the compression code z is generated by using the rules defined in Table 1b. Then, the next n secret bits b 1 b 2...b n from the secret message S are embedded into z (i.e., z = z||b 1 b 2...b n ), and z is appended to the binary output code stream (i.e., CS = CS||z). The flowchart of the proposed encoding and embedding scheme is shown in Fig. 5. The proposed encoding and embedding algorithm is summarized as follows:

Fig. 5
figure 5

The flowchart of the proposed encoding and embedding scheme

3.1.1 The encoding and embedding algorithm

Input: A grayscale cover image G sized H × W, codebook D sized N, secret message S, and predefined values , t, M, and n, where n = 1, 2, 3, or 4.

Output: A binary code stream CS.

  1. Step 1:

    Divide G into nonoverlapping pixel blocks X, each of size p × q.

  2. Step 2:

    Read n secret bits b 1 b 2...b n from S.

  3. Step 3:

    Read a pixel block X from G in raster scan order.

  4. Step 4:

    If X is in the first row or column, compute VQ index r and output ⌈log2 N⌉-bit representation of r, followed by n secret bits b 1 b 2...b n to the code stream CS.

  5. Step 5:

    Else (i.e., X is not in the first row or column),

  6. Step 5.1:

    Build the state vector X’ and the M-sized state codebook of X.

  7. Step 5.2:

    Compute the SMVQ index x.

  8. Step 5.3:

    If SMD(X’, scw 0) ≤ t, then follow the rules in Table 1a to generate the compression code z of x, where scw 0 is the first state codeword in the state codebook.

  9. Step 5.4:

    Else (i.e., SMD(X’, scw 0) > t), follow the rules in Table 1b to generate the compression code z of x.

  10. Step 5.5:

    Append n secret bits b 1 b 2...b n to z (i.e., z = z||b 1 b 2...b n ).

  11. Step 5.6:

    Update the output code stream as CS = CS||z.

  12. Step 6:

    Repeat s teps 3 to 5 until al l p i xel blocks X a r e proc e ssed.

  13. Step 7:

    Output the binary c ode s t ream CS.

3.2 The decoding and extracting phase

The decoding and extracting phase recovers the reconstructed cover image G’ sized H × W and secret message S. The expected inputs are the received binary code stream CS, the main codebook D sized N, and the preset values , t, M, and n, where n = 1, 2, 3, or 4. First, S and G’ are initialized to be empty. Then G’ is divided into nonoverlapping pixel blocks X, each of size k = p × q. These pixel blocks are recovered in raster scan order. Let X be the currently recovered pixel block. If X is located in the first row or column, then the VQ index r is recovered as the decimal value e of the next ⌈log2 N⌉ bits from the code stream CS (i.e., r = e). The values of the rth codeword, cw r , from D are used to recover X. Finally, the recovered pixel block X is inserted into the reconstructed cover image G’ in raster scan order. The next n consecutive bits c i c i+1...c i+n-1 are extracted from CS as n secret bits b 1 b 2...b n and appended to the secret message S (i.e., S = S||b 1 b 2...b n ).

If X is not located in the first row or column, the state vector X’ and a state codebook of size M are constructed. If the SMD of the first state codeword scw 0 with the state vector X’ is less than or equal to the predefined threshold value t (i.e., SMD(X’, scw 0) ≤ t), the SMVQ index x is recovered by following the rules defined in Table 2a. Otherwise (i.e., SMD(X’, scw 0) > t), x is recovered by following the rules defined in Table 2b. The current pixel block X is reconstructed using the values of the xth state codeword, scw x . The reconstructed pixel block X is then inserted into G’ in raster scan order. The next n consecutive bits c i c i+1 ... c i+n-1 are extracted from CS as n secret bits b 1 b 2...b n and added to the secret message S (i.e., S = S||b 1 b 2...b n ). The above steps are repeated until the cover image G’ is reconstructed and the secret message S is recovered. The flowchart of the proposed decoding and extracting scheme is shown in Fig. 6. The decoding and extracting algorithm of the proposed scheme is summarized as follows:

Table 2 The proposed decoding rules
Fig. 6
figure 6

The flowchart of the proposed decoding and extracting scheme

3.2.1 The decoding and extracting algorithm

Input: The received binary code stream CS, codebook D sized N, and preset values , t, M, and n, where n = 1, 2, 3, or 4.

Output: The extracted secret message S and the reconstructed cover image G’ sized H × W.

  1. Step 1:

    Initialize S and G’ to be empty.

  2. Step 2:

    Divide G’ into nonoverlapping pixel blocks X, each of size p × q.

  3. Step 3:

    Let X be the pixel block that is currently recovered in raster scan order.

  4. Step 4:

    If X is in the first row or column, then recover r as the decimal value e of the next ⌈log2 N⌉ bits from CS (i.e., r = e).

  5. Step 4.1:

    Reconstruct X using the codeword cw r .

  6. Step 5:

    Else (i.e., X is not in the first row or column),

  7. Step 5.1:

    Build the state vector X’ and the state codebook of size M.

  8. Step 5.2:

    If SMD(X’, scw 0) ≤ t, then follow the rules in Table 2a to recover x.

  9. Step 5.3:

    Else (i.e., SMD(X’, scw 0) > t), use the rules in Table 2b to recover x.

  10. Step 5.4:

    Reconstruct X using the state codeword scw x .

  11. Step 6:

    Insert the recovered pi x el b lock X into G’ in raster scan order.

  12. Step 7:

    Extract the nex t n secret bits b 1 b 2 .. . b n from the code stream CS and append them to S (i.e., S = S||b 1 b 2...b n ).

  13. Step 8:

    Repeat steps 3 to 7 until the cover image G’ is reconstructed.

  14. Step 9:

    Output the extracted secret message S and reconstructed cover image G’ sized H × W.

4 Experimental results and discussions

This section compares the experimental results of the proposed scheme with the recent works of Chang et al. [6], Wang et al. [24], Lin et al. [16], and Chang et al. [5]. The cover images sized 512 × 512 used in all experiments are shown in Fig. 7. The four main codebooks used are of sizes N = 128, 256, 512, and 1024. The LBG algorithm [17] was used to generate the four main codebooks. Each main codebook contains 16-dimensional codewords (i.e., k = 4 × 4). Nonoverlapping 4 × 4 blocks were used for both VQ and SMVQ (i.e., p × q = 4 × 4). All experiments were implemented using the Dev-C++ version 5.9.2 software running on Intel Core i7, 2.4 GHz CPU, and 8 GB RAM hardware platform. The library function rand() was used to generate the binary secret message S. Bit rate (BR), embedding rate (ER), embedding efficiency (EE), peak signal-to-noise ratio (PSNR), and execution time were used to compare the performances of the related works [5, 6, 16, 24] with the proposed scheme with n = 1, 2, 3, and 4.

Fig. 7
figure 7

Grayscale test images sized 512 × 512

The BR measures the number of bits required to represent one grayscale pixel in bits per pixel (bpp), and it is used to evaluate the compression performance. The BR is defined as the size of the output code stream |CS| divided by the number of pixels in a grayscale cover image—that is, BR = |CS| / (H × W), where H and W are the height and width of the cover image. A lower BR indicates a better compression performance.

The ER measures the number of secret bits embedded per VQ or SMVQ index in bits per index (bpi), and it is used to evaluate embedding capacity. The ER is defined as the number of concealed secret bits |S| divided by the number of indices in the VQ or SMVQ index table of size (H/p) × (W/q)—that is, ER = (k × |S|) / (H × W), where k = p × q. A higher ER means that a larger secret message can be transmitted.

The EE measures the number of hidden secret bits that can be transmitted when one bit of the output code stream CS is delivered. It is defined as the number of hidden secret bits |S| divided by the size of the output code stream |CS|—that is, EE = |S| / |CS| = ER / (k × BR), where k = p × q. A higher EE value indicates that more secret information is transmitted for each bit of the output code stream CS.

The PSNR evaluates the visual quality of a recovered image. It expresses the difference between the original and the recovered images in decibels (dB). The PSNR is calculated as

$$ PSNR=10{ \log}_{10}\left(\frac{H\times W\times {(255)}^2}{\sum_{i=0}^{H-1}\sum_{j=0}^{W-1}{\left({G}_{i j}-{G}_{i j}^{\prime}\right)}^2}\right), $$

where H is the height of the image, W is the width of the image, and G ij and G ij are the pixel values in the ith row and jth column of the original and the recovered image, respectively. A higher PSNR value indicates a smaller difference between the original and the recovered images.

4.1 Selection of values for ℓ and t

The values of and t are critical factors in determining the size of the proposed scheme’s output code stream, where α = 2 and β = 2α = 2 +1. In order to determine the optimal values of and t, we tested the proposed scheme with all combinations of the ordered pair (, t) for the test images in Fig. 7, where 0 ≤  ≤ ⌊((log2 M) - 2)/15⌋; 1 ≤ t ≤ ⌈255√7⌉ = 675; M = 32, 64, and N; and N = 128, 256, 512, and 1024. For a specific main codebook size N and a state codebook size M, there is only one optimal pair (, t). It is defined as the order pair that generates the lowest pure bit rate (PBR) (i.e., the BR without embedding any secret bits) for all combinations of and t. Table 3 lists the optimal values of and t for all codebook sizes. For example, the optimal pairs (, t) with main codebook sizes N = 128, 256, 512, and 1024 and state codebook size M = N are (0, 6), (1, 10), (2, 8), and (3, 9), respectively. The experimental results in terms of bit rate of the proposed scheme with these optimal pairs and n = 1, 2, 3, and 4 are listed in Tables 4 and 5. The detailed experimental results of the PBRs with all combinations of and t for all codebook sizes can be found in (http://tinyurl.com/jmby5nq).

Table 3 Optimal values of and t with M = 32, 64, N, and N = 128, 256, 512, 1024
Table 4 BRs of the proposed scheme for (, t) = (0, 6), (1, 10), n = 1, 2, 3, 4, and M = N = 128, 256
Table 5 BRs of the proposed scheme for (, t) = (2, 8), (3, 9), n = 1, 2, 3, 4, and M = N = 512, 1024

4.2 Comparison of the proposed scheme with related works

This section compares the performance of the proposed scheme with the related works [5, 6, 16, 24]. BR, ER, EE, and PSNR were used to examine each scheme’s performance. For fair comparisons, we modified the proposed scheme to match the embedding capacities of each related work. When two schemes have the same embedding capacity, the scheme with the lower average BR has a better compression performance. The comparative results among the simulated methods are presented in Table 6.

Table 6 Summary of the average ER, BR, EE, and PSNR of Chang et al. [6], Wang et al. [24], Lin et al. [16], Chang et al. [5], and the proposed scheme for M = 32, 64, N; N = 128, 256, 512, 1024; ψ = 7, 8, 8, 9; and (l, t) = (0, 4), (0, 8), (0, 1), (0, 6), (1, 10), (2, 8), (3, 9)

In 2013, Chang et al. [6] designed a reversible information hiding scheme that embeds 1 bpi at very good average bit rates (e.g., 0.407 bpp with N = 256). Their scheme compresses all TIVs that are less than or equal to 7—that is, it uses less than ⌈log2 N⌉ bits to represent a TIV (i.e., fewer bits than the conventional VQ algorithm). It can be seen from Table 6 that the proposed scheme with n = 1 achieves lower average BRs for the same ER of 1 bpi. This indicates that the proposed scheme with n = 1 also obtains higher average EEs in all test cases. Based on these results, we can conclude that the compression performance of the proposed scheme is better than that of Chang et al.’s scheme [6]. The experimental results in terms of bit rate of Chang et al.’s scheme [6] and the proposed method with n = 1 for each test image shown in Fig. 7 can be found in Tables A1 − A2 in (http://tinyurl.com/jmby5nq).

In 2014, Wang et al. [24] proposed a reversible information hiding scheme based on the SMVQ algorithm and a modified LAC algorithm. Tables 7 and 8 compare the PBRs of Wang et al.’s scheme [24] with those of the proposed scheme. These data indicate that the proposed scheme obtains lower PBRs in all test cases. Therefore, we can conclude that the proposed scheme improves the compression performance of Wang et al.’s method [24].

Table 7 Comparison of the PBRs between Wang et al.’s scheme [24] and the proposed scheme with (, t) = (0, 6), (1, 10), and M = N = 128, 256
Table 8 Comparison of the PBRs between Wang et al.’s scheme [24] and the proposed scheme with (, t) = (2, 8), (3, 9), and M = N = 512, 1024

To fairly compare with their normal hiding (NH) and over hiding (OH) strategies, we modified the proposed scheme to embed the same number of secret bits in each test case as Wang et al.’s NH and OH [24]. Table 6 shows that, in all test cases, the proposed scheme achieves lower average BRs, implying that the proposed scheme also obtains higher average EEs. Based on these results, we can conclude that the proposed scheme improves the compression performance of Wang et al.’s scheme [24]. The experimental results with respect to the bit rate of Wang et al.’s scheme [24] and that of the proposed method for each test image shown in Fig. 7 can be referenced from Tables A3 − A6 in (http://tinyurl.com/jmby5nq).

In 2015, Lin et al. [16] proposed a VQ-based information hiding scheme combining the SOC [10] and the SCM [22]. The compression performance of their scheme relies on the number of VQ indices within the SOC path and the size of the state codebook generated by the SCM, denoted as SOL and M, respectively. They reported that the optimal values of SOL and M are 4 and 8 for most images. Tables 9 and 10 compare the PBRs between Lin et al.’s scheme [16] and the proposed scheme for SOL = 4 and M = 8. In all test cases, the proposed scheme achieves better PBRs. This suggests that, for the same embedding capacities, the proposed scheme will achieve lower bit rates.

Table 9 Comparison of PBRs between Lin et al.’s scheme [16] and the proposed scheme for SOL = 4, M = 8, (, t) = (0, 6), (1, 10), and M = N = 128, 256
Table 10 Comparison of PBRs between Lin et al.’s scheme [16] and the proposed scheme for SOL = 4, M = 8, (, t) = (2, 8), (3, 9), and M = N = 512, 1024

Lin et al. [16] defines the per-block output length ψ to control their embedding capacity. We selected the optimal value of ψ that yields the closest average bit rate to conventional VQ (i.e., 0.438, 0.500, 0.563, and 0.625 bpp for main codebook sizes N = 128, 256, 512, and 1024, respectively). The selected values of ψ are 7, 8, 8, and 9 for codebook sizes N = 128, 256, 512, and 1024, respectively. The complete data used for this selection can be obtained from Table A7 in (http://tinyurl.com/jmby5nq).

In order to fairly compare with Lin et al.’s scheme [16], we modified our proposed scheme to conceal the same number of secret bits as their scheme. Table 6 demonstrates that, in all test cases, the proposed scheme attains lower average bit rates, indicating that it also obtains higher average EEs. Therefore, we can deduce that the proposed scheme improves the compression performance of Lin et al.’s scheme [16]. The experimental results with regard to the bit rate of Lin et al.’s scheme [16] and that of the proposed approach for each test image shown in Fig. 7 can be seen in Tables A8 − A11 in (http://tinyurl.com/jmby5nq).

Chang et al.’s scheme [5] uses either SMVQ or 2-bit search order codes (i.e., 00, 01, and 10) to compress an SMVQ index (i.e., use fewer than ⌈log2 M⌉ bits to represent an SMVQ index). In their scheme, the size M of the state codebook is either 32 or 64, which is smaller than the size N of the main codebook (e.g., N = 256). This reduces the visual quality of the recovered image since the optimal codeword may not be within a state codebook of size M = 32 or 64. Their embedding rate is restricted to 0.984 bpi because one secret bit is embedded into each residual SMVQ index (i.e., SMVQ indices not in the first row or column of the SMVQ index table).

For a fair comparison with Chang et al.’s scheme [5], the proposed scheme embeds 16,129 secret bits (i.e., ER = 0.984 bpi). The experimental results in Table 6 illustrate that the proposed scheme has lower average BRs than Chang et al.’s scheme [5] in all test cases with M = 64 and N = 128, 256, 512, and 1024. Similarly, in all test cases with M = 32 and N = 128 and 256, the proposed scheme also obtains lower average BRs than Chang et al.’s method [5]. However, with M = 32 and N = 1024, Chang et al.’s approach [5] attains lower average BRs than the proposed scheme for the test image Baboon (see detailed data in Table A15 in (http://tinyurl.com/jmby5nq)). Although the state codebook size is small (i.e., M = 32), with the test image Baboon, the values of Cases 1 and 2 SMVQ indices tend to be greater than 7. Additionally, the small state codebook size (i.e., M = 32) increases the efficiency of the SOC algorithm, causing Chang et al.’s scheme [5] to generate the smaller output code stream. This is why our BRs are higher than those of Chang et al.’s method [5] for the test image Baboon with M = 32 and N = 1024. Despite this, our average BRs are lower than those of Chang et al.’s method [5] with M = 32 and 64 and N = 128, 256, 512, and 1024. Therefore, we can infer that our proposed scheme improves the compression performance of Chang et al. [5]. The detailed experiments with regard to the bit rate of Chang et al.’s scheme [5] and that of the proposed scheme for each test image shown in Fig. 7 can be read in Tables A12 − A15 in (http://tinyurl.com/jmby5nq).

For the visual quality of the recovered images obtained by the simulated methods, Table 6 shows that the average PSNR values of the proposed scheme are the same as those of the works proposed by Chang et al. [6], Lin et al. [16], and Wang et al. [24]. Chang et al.’s scheme [5] has the lowest average PSNR values among the implemented schemes. To sum up, it can be observed in Table 6 that the proposed scheme with n = 1 achieves the same average ER as Chang et al. [6] and better average BR and EE. Similarly, with a fixed ER of 0.984 bpi, the proposed scheme obtains better average BR and EE than Chang et al.’s scheme [5] with M = 32 and 64. To fairly compare with Wang et al.’s variable bit embedding strategies [24] (i.e., normal hiding [NH] and over hiding [OH]), we modified the proposed scheme to embed the same number of secret bits as Wang et al.’s approach [24]. Compared with Wang et al.’s scheme [24], for the same average ER, the proposed scheme obtains the better average BR and EE. In contrast, Lin et al.’s scheme [16] achieves a slightly better average ER than the proposed scheme with n = 3 for main codebook size N = 256. However, the proposed scheme achieves the better average BR and EE for all codebook sizes. Finally, with n = 4, the proposed scheme improves the average ER of all the related works. Therefore, based on the analysis of the experimental results presented in this section, we can conclude that our proposed scheme improves the performance of the related works [5, 6, 16, 24].

For computational complexity analysis, we determine that the basic operation for each simulated scheme is the comparison operation between two pixel blocks X’s of size p × q since each scheme requires many comparisons to build state codebooks, search for VQ and/or SMVQ indices and generate compression codes. In our implementation, we used the mergesort algorithm to build a state codebook of size M. For each input pixel block X, Chang et al.’s [5], Wang et al.’s [24] and the proposed scheme’s first build a sate codebook (i.e., N log2 N comparisons) and then search the state codebook for the SMVQ index x (i.e., M comparisons). After x is located, each scheme does a small amount of work before generating a compression code for x. Therefore, the main computational complexity of these three schemes is M + N × log2 N times the comparison operation. In contrast, for each X, Chang et al.’s scheme [6] first searches for a VQ index r (i.e., N comparisons), builds a state codebook (i.e., N log2 N comparisons) and then searches the state codebook for the TIV value d (i.e., M comparisons). Therefore, their main computational complexity is N + N × log2 N + M times the comparison operation, which is worse than Chang et al.’s [5], Wang et al.’s [24], and the proposed schemes. Finally, the computational complexity of Lin et al.’s scheme [16] is the worst. This is because, for each X, they search for a VQ index r (i.e., N comparisons), then if r is not found in the SOC path, they build 2v state codebooks (i.e., 2v × N × log2 N comparisons), and then search these state codebooks for r (i.e., K comparisons where 1 ≤ K ≤ 2v × M). However, if r is found in the SOC path, they simply generate the compression code for r. To simplify our analysis of Lin et al.’s scheme [16], we ignore K and assume that the probability that r is not found in the SOC path, P N , is 0.306, 0.446, 0.567 and 0.654 for N = 128, 256, 512, and 1024, respectively. These probabilities were generated from the test images by counting the number of times r is found in the SOC path divided by the total number of indices. Therefore, the main computational complexity of Lin et al.’s method [16] is N + P N  × 2v × N × log2 N times the comparison operation. With the optimal SOL of 4 in Lin et al.’s scheme (i.e., v = 2), their computational complexity is worse than all other schemes. Fig. 8 compares the average execution time for 10 times of each simulated scheme (i.e., 10 times for 11 test images). As expected, Lin et al.’s scheme [16] is the slowest while Chang et al.’s [5], Wang et al. [24], and the proposed schemes achieve similar execution times. Chang et al.’s scheme [6] is marginally slower than Chang et al.’s scheme [5], Wang et al.’s [24] and the proposed schemes but faster than Lin et al.’s scheme [16]. In general, the decoding and extraction algorithm of each scheme is faster than its respective encoding and embedding algorithm because the decoding and extraction algorithm does not need to compute VQ or SMVQ indices. Instead these indices are decoded directly from the received binary code stream.

Fig. 8
figure 8

Average execution time (in seconds) for all schemes and codebook sizes

5 Conclusions

This paper presents a novel reversible data hiding scheme by exploiting the SMD. The proposed scheme classifies SMVQ indices as Case 1 or 2 based on the values of the first state codeword’s SMD and a predefined threshold t. By using this classification as an indicator, the proposed scheme can switch between compression codes designed to compress Cases 1 and 2 SMVQ indices. This strategy achieves low average PBRs (i.e., the bit rate without embedding secret bits) of 0.230, 0.278, 0.337, and 0.391 bpp for the main codebook sizes N = 128, 256, 512, and 1024, respectively. The proposed method attains the embedding rates of 1, 2, 3, and 4 bpi at acceptable bit rates for main codebook sizes N = 128, 256, 512, and 1024. Additionally, for the same embedding capacities, the proposed scheme obtains lower average bit rates than recent VQ and SMVQ-based information hiding schemes [5, 6, 16, 24]. Therefore, we conclude that the proposed scheme improves the performance of these related works and is applicable for secret online communication.