1 Introduction

With the increase of data exchanges on the internet, data hiding is essentially important for applications such as copyright protection, secret communication, authentication and so on. So far, most of works have been focused on digital images and the priority demand of the embedding system is visual quality of marked image produced by embedding secret data into original (cover) image.

In the recent years, reversible data hiding (RDH) has been widely investigated as a special kind of data hiding technique which requires not only extraction of hidden data but also exact restoration of the cover image from the marked image [11]. Two most important metrics in evaluating the RDH performance are embedding capacity (EC) and marked image quality quantified by bit per pixel (bpp) and Peak Signal to Noise Rate (PSNR) respectively [13, 16].

Up to now, many RDH algorithms have been proposed. Nevertheless, in the technical sense of application, RDH has been supported by two pillars of RDH with contrast enhancement (RDH-CE) and prediction error expansion based RDH (RDH-PE) with high capacity and low distortion among the current mechanisms, performing differently than the inherent data hiding in which slight degradation is tolerable.

Histogram shifting based RDH, which is considered as one of typical RDH techniques, was first proposed by Ni et al. [11]. After that, this technique has been extended to various applications, one of which is the RDH with contrast enhancement (RDH-CE) proposed by Wu et al. [16]. In the RDH-CE method, histogram equalization is realized during the embedding procedure due to histogram bin shifting and splitting, which results in the image contrast enhancement. As a result, the Wu’s method has been recognized as a useful technique in improving visual quality especially for poorly illustrated images including medical and military map images as image contrast is one of the main factors in evaluating the image quality. However, the EC and PSNR of the RDH-CE are relatively low because using more peak pairs to increase the EC may result in over-enhanced marked image and rapid descent of PSNR curve. There exist several works for improving the performance of RDH-CE [1,2,3, 7, 8, 12]. They archived a considerable improvement in terms of PSNR and EC while avoiding visual distortion.

Nowadays, PE based RDH (RDH-PE) has been extensively exploited in recent years due to the higher performance compared with RDH based on expanding difference values of pixel pairs for embedding secret data [13]. The RDH-PE provides the best embedding performance among the existing RDH techniques in terms of EC and PSNR [4, 5]. Many researches have been focused on improving the statistical property of prediction errors [2, 6, 9, 10, 15]. Although the PSNR resulted by RDH-PE is kept high, the improvement of visual quality is not observed easily in the sense of human visual perception.

The inherent properties of the above two methods motivate us to seek an effective way to archive satisfactory embedding performance, i.e., the high embedding capacity keeping the good effect of image contrast enhancement. In this paper, we propose a novel RDH-CE method with high capacity by determining two characteristic parameters for the combination of RDH-CE and RDH-PE based on analyzing the change property of its relative contrast error (RCE) [4].

The rest of this paper is organized as follows. The performance properties of RDH-CE and RDH-PE are analyzed in Sect. 2, and the detail of the proposed method is presented in Sect. 3. Finally, experiment and conclusion are given in Sects. 4 and 5 respectively.

2 Related Work

In this section, the RDH-CE algorithm proposed in [16] is first explained briefly, and then the change properties of image contrast caused by RDH-CE and RDH-PE are analyzed with experimental results.

2.1 Wu’s RDH-CE Method

The RDH-CE is performed by pair-wisely expanding the highest two peak bins in histogram of an image. Two bins with the highest frequency values in histogram G for a given image, denoting the left and right bins by \(G_{a}\) and \(G_{b}\), are chosen and split outward in each time for embedding secret data. The embedding procedure is performed according to Eq. 1,

$$\begin{aligned} i' = {\left\{ \begin{array}{ll} i-1 &{} \text {for } i<G_a\\ G_a-m_k &{} \text {for } i=G_a\\ i &{} \text {for } G_a<i<G_b\\ G_b+m_{k} &{} \text {for } i=G_b\\ i+1 &{} \text {for } i>G_b\\ \end{array}\right. } \end{aligned}$$
(1)

where \(m_{k}\) is the k-th binary bit of the data to be embedded, i and \(i'\) are the original and modified pixel values respectively. To avoid overflow or underflow by histogram shifting, a location map is used to record locations of pre-shifted pixels in pre-processing. The procedures of data extraction and image recovery start with extracting the last peak-pair, and continue to extract the embedded data and recover the cover image by applying inversely the embedding procedure. While the embedding procedure usually repeats several times for increasing EC, the range of existing histogram bins is widely extended by histogram shifting, and their heights get similar gradually by histogram bin splitting. Figure 1 shows an example of the over-enhanced image and its histogram. As seen in the figure, the marked image is over-enhanced by the continuous process of histogram equalization, by which the EC in RDH-CE is restrained. The visual quality of marked image is usually evaluated by relative contrast error (RCE) rather than in terms of PSNR.

Fig. 1.
figure 1

Visual perception by RDH-CE for Lena image. (a) Original image. (b) Over-enhanced image, PSNR: 19.5 dB, EC: 173632 bits. (c) Histogram of original image. (d) Histogram of marked image.

2.2 Change of the Image Contrast Caused by RDH-PE

A RDH-PE method is based on expanding the prediction error (PE) from the neighborhood of a pixel for embedding data. A prediction error \(e_i\) is the difference between each pixel value \(x_i\) and its predicted value \(\hat{x_i}\), \(e_i=x_i- \hat{x_i}\). Each element of the obtained prediction error sequence is modified according to Eq. 2,

$$\begin{aligned} \tilde{e_i} = {\left\{ \begin{array}{ll} e_i+m_k &{} \text {for } e_i = 0\\ e_i-m_k &{} \text {for } e_i = -1\\ e_i+1 &{} \text {for } e_i>0\\ e_i-1 &{} \text {for } e_i<-1\\ \end{array}\right. } \end{aligned}$$
(2)

The marked image is produced by adding the modified error \(\tilde{e_i}\) to the predicted value of the cover pixel \(x_i\), \(\tilde{x_i}=\hat{x_i}+\tilde{e_i}\). The data extraction and image restoration procedures are performed by inverse order of the embedding procedure.

According to many experiments, the change of image contrast caused by the RDH-PE is extremely small. For example, the RCE of the intermediate-marked image with EC 83321 bits resulted by the RDH-CE is 0.55016 for Lena image and the RCE of the final marked image with EC 127282 bits embedded by RDH-PE after applying RDH-CE is 0.55053 for the same image. The difference of two RCEs is only 0.00037 as compared with the increased EC (43961 bits), which reveals a possibility to improve the EC by RDH-CE effectively without the severe visual distortion caused by the histogram equalization. Similarly, the change value of two PSNRs is only 0.0661 at the EC.

3 Proposed Method

The proposed method can be considered as a combined version of RDH-CE and RDH-PE (RDH-CE-PE). The RDH-CE-PE method contains two parts: the first part is the RDH-CE embedding under the restriction of a threshold pre-selected for preventing over-enhanced image, and then RDH-PE as the second part performs the sequence embedding operator on the image produced by RDH-CE to increase the EC. The data extraction and image recovery are performed by the reverse order of embedding procedure.

Fig. 2.
figure 2

Flowchart of proposed RDH algorithm

3.1 Embedding Algorithm by RDH-CE

Suppose that N peak-pairs are selected for a given 8-bit gray-level image C. The RDH-CE embedding procedure is performed as follows:

  • Step 1. Histogram bins from 0 to \(N-1\) are pre-shifted to right side by N and those from \(256-N\) to 255 to left side by N excluding the first 16 pixels in the bottom row. Locations of pre-shifted pixels are saved within a location map for image recovery.

  • Step 2. Histogram of the pre-shifted image is calculated excluding the first 16 pixels in the bottom row, and then one highest peak-pair (\(G_a\) and \(G_b\)) is selected in the histogram.

  • Step 3. Data embedding is performed by applying Eq. 1 to all pixels in the whole image in sequential order excluding the 16 pixels, and bin values of the peak-pair are kept as the side information (Fig. 2).

  • Step 4. Step 2–Step 3 are repeated while \(RCE \le T_R\).

  • Step 5. The location map (binary bits) is embedded before message bits. The amount of peak-pairs, the length of bitstream in the location map, the LSBs of excluded 16 pixels and the previous peak-pair values are embedded when the last peak-pair is split.

  • Step 6. Bin values of the last N-th peak-pair are embedded into LSBs of excluded 16 pixels by LSB replacement to generate an intermediate-marked-image M.

3.2 Embedding Algorithm by RDH-PE

The sequence embedding procedure by RDH-PE is performed on the intermediate-marked image M as follows:

  • Step 1. The prediction value of each \(x_i\) in M is calculated by applying Eq. 3 to all pixels in raster scanning order.

    $$\begin{aligned} \hat{x_i} = {\left\{ \begin{array}{ll} min(u,v) &{} \text {if } w \ge max(u,v)\\ max(u,v) &{} \text {if } w \le min(u,v)\\ u+v-w &{} \text {otherwise } \\ \end{array}\right. } \end{aligned}$$
    (3)

    where u, v and w are context elements of \(x_i\) in the medium predictor [10].

  • Step 2. Each prediction error is computed as \(e_i=x_i- \hat{x_i}\).

  • Step 3. Prediction-error histogram (PEH) is generated based on the prediction-error sequence \((e_1,\cdots ,e_n)\).

  • Step 4. The PEH is modified by Eq. (2) to embed data.

  • Step 5. The modified PE values are added to the prediction values of their corresponding pixels as \(\tilde{x_i}=\hat{x_i}+\tilde{e_i}\).

  • Step 6. Step 1–Step 5 are repeated K times (K levels) while RCE gradient \(F \le T_e\) to produce the final-marked image S.

3.3 Data Extraction and Image Recovery in RDH-CE-PE

The RDH-CE-PE extraction and recovery procedures are performed in the reverse order of embedding. At the beginning of the extraction, the RDH-PE extraction is first performed on the final-marked image S.

  • Step 1. Calculate the prediction value \(\hat{x_i}\) from marked pixel \(\tilde{x_i}\) for \(i \in \{1,\ldots , N_e\}\) using the medium predictor in the reverse scanning order. Where, \(N_e\) is the index of the binary data embedded in cover pixels.

  • Step 2. Modified prediction error \(\tilde{e_i}\) can be determined by subtracting the prediction \(\hat{x_i}\) from the marked pixel \(\tilde{x_i}\). Then, the embedded data can be extracted as

    $$\begin{aligned} m'_k = {\left\{ \begin{array}{ll} 0 &{} \text {if } \tilde{e_i} \in \{-1,0\}\\ 1 &{} \text {if } \tilde{e_i} \in \{-2,1\}\\ \end{array}\right. } \end{aligned}$$
    (4)

    where \(m'_k\) is the k-th binary bit of the extracted data.

  • Step 3. The prediction error \(e'_i\) is recovered by applying Eq. 5 to each modified prediction error \(\tilde{e_i}\).

    $$\begin{aligned} e'_i = {\left\{ \begin{array}{ll} \tilde{e_i} &{} \text {if } \tilde{e_i} \in \{-1,0\}\\ \tilde{e_i}-1 &{} \text {if } \tilde{e_i} > 0\\ \tilde{e_i}+1 &{} \text {if } \tilde{e_i} < -1\\ \end{array}\right. } \end{aligned}$$
    (5)
  • Step 4. Finally, the cover pixel is fully restored as \(x_i=\hat{x_i}+e'_i\) to restore the intermediate-marked image \(M'\) exactly.

    Sequentially, the RDH-CE extraction and recovery procedures are performed on \(M'\) as follows:

  • Step 5. The extraction procedure starts with extracting the N-th peak-pair by collecting LSBs of excluded 16 pixels. Then, the N-th peak-pair is used for obtaining the side information including the number of peak-pairs, the length of bitstream in the location map and LSBs of excluded 16 pixels.

  • Step 6. After generating the histogram of the image \(M'\), the embedded data are extracted from pixels with values of \(G_a-1\), \(G_a\), \(G_b\), \(G_b+1\) by Eq. 6.

    $$\begin{aligned} m'_k = {\left\{ \begin{array}{ll} 1 &{} \text {for } i' = G_a-1\\ 0 &{} \text {for } i' = G_a\\ 0 &{} \text {for } i' = G_b\\ 1 &{} \text {for } i' = G_b+1\\ \end{array}\right. } \end{aligned}$$
    (6)
  • Step 7. The image recovery procedure described by Eq. 7 is performed on all pixels excluding the first 16 pixels in the bottom row.

    $$\begin{aligned} i = {\left\{ \begin{array}{ll} i'+1 &{} \text {for } i'<G_{a}-1 \\ G_{a} &{} \text {for } i'=G_{a}-1 \text { or } i'=G_{a} \\ G_{b} &{} \text {for } i'=G_{b} \text { or } i'=G_{b}+1\\ i'-1 &{} \text {for } i'>G_{b}+1 \end{array}\right. } \end{aligned}$$
    (7)
  • Step 8. Step 6–Step 7 are repeated until all data are extracted.

  • Step 9. Using the location map reconstructed from the side information, pixel values corresponding to pre-shifted histogram bins are retrieved exactly.

  • Step 10. LSBs of the first 16 pixels in the bottom row are rewritten to original locations, and the cover image is fully recovered without any distortion.

4 Experiments

Our experiment is carried out by embedding/extracting pseudo random binary bits generated by the Matlab function rand() for grey-level images with the size of \(512*512\) [14] and recovering fully original image. The embedding performance of the proposed method is compared with Wu’s RDH-CE in terms of EC, PSNR and RCE because it is the combination of RDH-CE and RDH-PE.

Fig. 3.
figure 3

Reversibility test of proposed RDH algorithm for Plane image. (a) Original image. (b) Intermediate-marked image by RDH-CE, EC: 229859 bits, PSNR: 22.073 dB, RCE: 0.552. (c) Final-marked image by RDH-PE, EC: 314599 bits, PSNR = 21.78 dB, RCE: 0.554. (d) Intermediate-marked image recovered by RDH-PE. (e) Restored original image.

4.1 Test Reversibility of the Proposed Method

Figure 3 shows original, marked and recovered images of Plane image processed by the proposed method, demonstrating that the proposed method is exactly reversible. Surprisingly, although the amount of data (314599 bits) embedded in Fig. 3(c) is 84740 bits more than 229859 bits in Fig. 3(b), but it is difficult to distinguish between them in visual quality and a little changes of PSNR and RCE are measured. We have observed similar results for many other images.

Fig. 4.
figure 4

Performance comparison ((a) PSNR and (b) RCE) of proposed method and RDH-CE for Lena image.

4.2 Embedding Performance and Determination of Reasonable Parameters for Combination of RDH-CE and RDH-PE

The proposed RDH-CE-PE has two important parameters for the combination beside the inherent ones for the RDH-CE or the RDH-PE: the first is a threshold \(T_R\) of RCE pre-defined in RDH-CE and the other is a threshold \(T_e\) for determining additional EC by RDH-PE without visual distortion. According to experiment results, these two parameters vary from image to image. The parameter \(T_R\) (\(T_R\in [5.1,5.9]\)) can be first determined arbitrarily for different applications, and the performance curves for Lena image are plotted by increasing EC with differently selected \(T_R\) in Fig. 4. As one can see from Fig. 4, the sequence embedding by RDH-PE after performing RDH-CE while \(RCE \le T_R\) provides better PSNR and RCE than performing RDH-CE continuously at the same EC. The gradient of curves of PSNR and RCE in RDH-CE-PE is rapidly changed at a specific point of EC considering as the second parameter to approach curves in Wu’s RDH-CE degrading the visual quality severely. From the observation, it is noted that the second parameter \(T_e\) can be used for restraining the secondary contrast over-enhancing which is described as RCE gradient F quantified by ratio of difference values in RCE and EC according to Eq. 8.

$$\begin{aligned} (RCE_K-RCE_{K-1})/(EC_N-EC_{K-1}) \le T_e \end{aligned}$$
(8)

Here, \(EC_K\) and \(RCE_K\) indicate the EC (bpp) and RCE at the K-th level in RDH-PE respectively. Through experiments for many images, as \(T_e\) is set as 1.2, visual distortion is not perceived in the marked image produced by proposed method. Due to the lack of space, results for only three test images are shown in Fig. 5. Marked images shown in Fig. 5 are resulted as follows.

Fig. 5.
figure 5

Results for proposed method (RDH-CE-PE) using three test images.

(a) Original image (Baboon). (b) RDH-CE marked image (Baboon) EC = 84593 bits, RCE = 0.55, PSNR = 25.702933 dB. (c) RDH-CE-PE marked image (Baboon) EC = 115660 bits, RCE = 0.557956, PSNR = 23.312608 dB.

(d) Original image (Airport). (e) RDH-CE marked image (Airport) EC = 179240 bits, RCE = 0.55, PSNR = 22.82467 dB. (f) RDH-CE-PE marked image (Airport) EC = 231060 bits, RCE = 0.560469, PSNR = 21.259652 dB.

(h) Original image (Elaine). (i) RDH-CE marked image (Elaine) EC = 71280 bits, RCE = 0.55, PSNR = 25.0237 dB. (j) RDH-CE-PE marked image (Elaine) EC = 129244 bits, RCE = 0.557343, PSNR = 23.2630 dB.

Experiment results fully demonstrate superior performance of our proposed method compared with Wu’s RDH-CE.

5 Conclusions

In this paper, a high capacity RDH-CE is proposed to improve the performance of Wu’s RDH-CE. The proposed method can embed much more data into the contrast enhanced image by the RDH-CE while avoiding visual distortion by contrast over enhancing at the high EC. The proposed method provides the best performance among existing RDH methods with contrast enhancement, which can be supported by suitable combination of RDH-CE and RDH-PE based on restraining the degree of contrast enhancement. The further work will be intended to optimal determination of two specific parameters of RDH-CE-PE.