Keywords

1 Introduction

Image [1] data hiding is the technique of preserving the confidential or secret content inside a cover image. Data hiding [2] has recently become common in the fields of medicine, military, and copyright protection. In particular, in the field of medicine. [3] patient records such as medical history can be reversibly obscured in scan images. This allows the practitioner to quickly view the medical records without having to re-study them. In military applications [4], the confidential data can be shared between the soldiers of a country by hiding it in a cover image. Data hiding is also essential for maintaining the image content’s [5] ownership. The two broad area of data hiding are steganography and cryptography [6, 7]. The steganography algorithm [8] aims to recover the hidden data completely when the stego image is not subject to attacks. When the stego image is attacked, these algorithms typically fail to recover the data. The [7,8,9] embedding capacity is highly limited, if the steganography algorithm produces a single stego image. As a result, dual stegano image-based algorithms are implemented, which can carry a large number of data without losing the stego image’s visual quality. Stego photos are secret data contained in the original cover image.

Histogram shifting [10], difference expansion [11], LSB substitution [12], and prediction error expansion [13] are some of the most basic data hiding algorithms. The aim of the histogram shifting algorithm is to estimate the cover image’s histogram of pixel values; the data is then embedded by creating a vacancy bin. The visual quality of these algorithms is excellent, but the embedding rate is extremely poor. By changing the LSB bit of the cover image pixels, the LSB substitution [12] algorithm hides the details. This scheme has a low degree of distortion, but it is insecure. By shuffling the LSB bit, an unauthorised user can easily extract the secret data. The prediction error expansion [13] and difference expansion scheme provides a very high embedding rate, but it creates a high distortion, since the prediction error or difference value is high near the edges [22].

Several dual data hiding techniques are derived from the prediction error expansion and difference expansion. The algorithm includes exploiting modification direction (EMD) [14], encoding based schemes [15] and location based scheme [16]. The EMD scheme [15] uses a modulus function to embed the data. The centre folding strategy folds the decimal data and then embeds it on the cover image. The modified centre folding strategy [17] uses an encoding scheme to encode the decimal data and then embedded the encoded indices in the cover image. The location based technique uses a pair of pixels \({X}_{i,j}\) and \({X}_{i,j+1}\) to embed the data. The cover pixels \({X}_{i,j}\) and \({X}_{i,j+1}\) is modified as \({X}_{i,j}^{^{\prime}}\) and \({X}_{i,j+1}^{^{\prime}}\) after embedding a 2-bit message.

The shiftable position [18] scheme is proposed where it uses an optimal parameter to estimate the code length. Y.L Wang et al. [19] used last 3 bits to embed the data which is derived from the LSB substitution method. The method K.H Jung et al. [20] used modulus function in vertical and horizontal direction instead of estimating in diagonal direction. The binary data is converted to base 5 values for embedding. Chang et al. [14, 21] extended the EMD scheme using a \(3\times 3\) and \(5\times 5\) modulus function.

2 The Proposed Algorithm

The data embedding scheme and data extraction scheme are the two phases of the proposed process, as shown in the following section.

2.1 Proposed Embedding Scheme

The block diagram of proposed embedding scheme is depicted in Fig. 1.

Let \({X}_{1}\), \({X}_{2}\)………\({X}_{K}\) be the \(K\) number of pixels where the data is to be embedded. By calculating the error between adjacent pixels, the data is embedded. Enable eqn to be used to estimate the error between adjacent pixels

Fig. 1.
figure 1

Block diagram of proposed embedding algorithm

$$ e_{i} = X_{i} - X_{i - 1} \;\;\;\;\;\;\;\;i = 0,1 \ldots \ldots K $$
(1)

The proposed method estimate an adaptive weight using the error \({e}_{i}\). The adaptive weight is estimated using the relation,

$${w}_{i}={w}_{i-1}+{e}_{i}\times d$$
(2)

e where \(d\) is the data to be embedded. The problem with Eq. (2) is, if the error \({e}_{i}\) is 0, then the weight becomes \({w}_{i}={w}_{i-1}\). If the data \(d\) is either 0 or 1 (in case of binary), the Eq. (2) loss the property of reversibility. To solve this issue, the Eq. (2) can be modified as,

$${w}_{i}={w}_{i-1}+{e}_{i}\times d+\alpha \times d$$
(3)
$${w}_{i}={w}_{i-1}+d\times [{e}_{i}+\alpha ]$$
(4)

where \(\alpha \) is the factor that decides the embedding strength. Lower the value of \(\alpha \) creates less distortion. The value of \(\alpha \) is selected such that using Eq. (5)

$$\alpha =|\mathrm{min}\left({e}_{i}\right)-1|$$
(5)

Improve the security, the Eq. (4) is modified as Eq. (6)

$${w}_{i}={w}_{i-1}+d\times \left[{e}_{i}+\alpha \right]-{k}_{i}$$
(6)

where \({k}_{i}\) is the \(K\) binary random sequence generated using key ‘U’. The Eq. (4) can be modified in two cases based on the value of \(\alpha \),

$$ w_{i} = \left\{ {\begin{array}{*{20}l} {w_{i - 1} + d \times \left[ {e_{i} + \alpha } \right] - k_{i} } \hfill & {if\,\alpha = \left| {\min \left( {e_{i} } \right) - 1} \right|} \hfill \\ {w_{i - 1} + d \times \left[ {e_{i} + \alpha } \right] + k_{i} } \hfill & {if\,\alpha = \left| {\max \left( {e_{i} } \right) + 1} \right|} \hfill \\ \end{array} } \right. $$
(7)

In this paper, we use the weight update Eq. (7) as \(w_{i} = w_{i - 1} + d \times \left[ {e_{i} + \alpha } \right] - k_{i}\) and \(\alpha = \left| {\min \left( {e_{i} } \right) - 1} \right|\). If the data is binary \(d \in \left[ {0,1} \right]\), the weight update Eq. (8) is expressed as,

$$ w_{i} = \left\{ {\begin{array}{*{20}l} {w_{i - 1} + k_{i} } \hfill & {if\, d = 0} \hfill \\ {w_{i - 1} + \left[ {e_{i} + \alpha } \right] - k_{i} } \hfill & {if\, d = 1} \hfill \\ \end{array} } \right. $$
(8)

Instead of using the binary data 0 or 1, the \(K\) number of binary data can be grouped together and converted to decimal to form a decimal data \(D\). Therefore the weight update equation can be expressed as using Eq. (9)

$$ w_{i} = w_{i - 1} + D \times \left[ {e_{i} + \alpha } \right] - k_{i} $$
(9)

The weight updation in a two dimensional image is expressed as,

$$ w_{i,j} = w_{i - 1,j} + D_{l} \times \left[ {e_{i,j} + \alpha } \right] - k_{i,j} $$
(10)

\(i = 1,2 \ldots \ldots \ldots ..M - 1\) and \(j = 1,2 \ldots \ldots \ldots ..N - 1\), where \(M \times N\) denotes the cover image size and \(l\) denotes the index decimal data.

Let \(C_{i,j}\) denote the cover image with coordinates \(\left( {i,j} \right)\), and r denote the random binary sequence generated with the key ‘U’. To get the random decimal sequence \(k_{i,j}\), the L bits of the random binary sequence are grouped together and converted to decimal. To obtain the decimal data \(D_{l}\), the secret data is grouped in \(L\) bits and converted to decimal. The error is calculated using the cover image \(C_{i,j}\), which is also used to calculate the parameter α. The cover image \(C_{i,j}\) is arranged in a single row for continuous weight updating, and the weight can be modified on that single row.

Using Eqs. (11) and (12), the adaptive weight \(w_{i,j}\) is embedded on the cover image \(C_{i,j} \) to produce the stego images \(S_{i,j}^{^{\prime}}\) and \(S_{i,j}^{^{\prime\prime}}\).

$$ S_{i,j}^{^{\prime}} = C_{i,j} - \left\lceil {\frac{{w_{i,j} }}{2}} \right\rceil $$
(11)
$$ S_{i,j}^{^{\prime\prime}} = C_{i,j} + \left\lfloor {\frac{{w_{i,j} }}{2}} \right\rfloor $$
(12)

Substituting the value of \(w_{i,j}\), the stego images can be estimated using the relation,

$$ S_{i,j}^{^{\prime}} = C_{i,j} - \left\lceil {\frac{{\left( {w_{i - 1,j} + D \times \left[ {e_{i,j} + \alpha } \right] - k_{i,j} } \right)}}{2}} \right\rceil $$
(13)
$$ S_{i,j}^{^{\prime\prime}} = C_{i,j} + \left\lfloor {\frac{{\left( {w_{i - 1,j} + D \times \left[ {e_{i,j} + \alpha } \right] - k_{i,j} } \right)}}{2}} \right\rfloor $$
(14)

2.2 Proposed Extraction Scheme

Fig. 2.
figure 2

A block diagram of the proposed data extraction algorithm

The original cover image \(C_{i,j}\) is retrieved from the two stego images \(S_{i,j}^{^{\prime}}\) and \(S_{i,j}^{^{\prime\prime}}\) in the extraction process using the relation Eq. (15) (Fig. 2).

$$ C_{i,j} = \left\lceil {\frac{{S_{i,j}^{^{\prime}} + S_{i,j}^{^{\prime\prime}} }}{2}} \right\rceil $$
(15)

The Eq. (14) is subtracted from eqn and (15), to get Eq. 16 as

$$ \left( {w_{i - 1,j} + D_{l} \times \left[ {e_{i,j} + \alpha } \right] - k_{i,j} } \right) = S_{i,j}^{^{\prime\prime}} - S_{i,j}^{^{\prime}} $$
(16)

The decimal data \(D_{l}\) can be estimated using Eq. (17) from the above Eq. (16)

$$ D_{l - 1} = \frac{1}{{\left( {e_{i,j} + \alpha } \right)}}\left( {S_{i,j}^{^{\prime\prime}} - S_{i,j}^{^{\prime}} - w_{i - 1,j} + k_{i,j} } \right) = \frac{1}{{\left( {e_{i,j} + \alpha } \right)}}\left( {diff - w_{i - 1,j} - k_{i,j} } \right) $$
(17)

The data must be extracted in the reverse order from last to first. The last data and the last weight must be known to the extracting module for the complete recovery of data. The weight for preceding pixel pair can be estimated as using Eq. (18)

$$ w_{i - 1,j} = w_{i,j} - D_{l} \times \left[ {e_{i,j} + \alpha } \right] + k_{i,j} $$
(18)

3 Experimental Results

MATLAB 2018a is used to apply the proposed reversible data hiding scheme, which uses four original images (Boat, Barbara, Cameraman, and Lena) as well as three confidential images (Cat, Pepper, Fruit,). As seen in Fig. 3, the cover image and the secret image are both 8 bit grayscale.

Fig. 3.
figure 3

Sample test images (a)–(d) test cover images (e)–(g) Secret images

The proposed scheme’s performance is measured using image performance parameters such as embedding capability and visual consistency (PSNR).

The embedding rate of dual stegano images ‘R’ was calculated using Eq. (19) to evaluate the proposed method’s efficiency.

$$ R = \frac{S}{2 \times M \times N}. $$
(19)

where S denotes the number of bits embedded in the image and MN denotes the cover image’s dimension. The PSNR between the cover image and the stego image is used to determine the visual consistency of the stego image. The dual stegano system will have two PSNR values because there are two stego images (PSNR1 and PSNR2). As eqn, the PSNR of the stego image is calculated using the equation as (20)

$$ PSNR = 10\log_{10} \frac{{255^{2} }}{MSE}dB $$
(20)

where MSE stands for mean square error, which is determined using Eqs. (21) and (22)

$$ MSE = \frac{1}{M \times N}\sum\nolimits_{i = 1}^{M} {\sum\nolimits_{j = 1}^{N} {\left( {C_{i,j} - S_{i,j}^{^{\prime}} } \right)^{2} } } $$
(21)
$$ MSE = \frac{1}{M \times N}\sum\nolimits_{i = 1}^{M} {\sum\nolimits_{j = 1}^{N} {\left( {C_{i,j} - S_{i,j}^{^{\prime\prime}} } \right)^{2} } } $$
(22)

where \(C_{i,j}\) denotes the cover image and \(S_{i,j}^{^{\prime}}\) and \(S_{i,j}^{^{\prime\prime}}\) denote the stego image. Using Eq. (23), the average PSNR is determined from PSNR1 and PSNR2

$$ PSNR_{avg} = \frac{1}{2}\left( {PSNR1 + PSNR2} \right) $$
(23)

The embedding capacity for L = 2 is greater than 5,23,000 bits, with a visual quality of more than 51.9 dB. Similarly, the embedding capacity for =2 is greater than 7,77,000 bits, with a visual quality of 47.7 dB.

Table 1. Embedding capacity and PSNR comparison for the proposed scheme with traditional methods

The graphical comparison of embedding rate between different schemes and the proposed method is shown in Fig. 4.The graphical comparison for proposed method is depicted for \(L = 3\) and \(L = 4\). From Fig. 4, it is clear that the visual quality reduces as the embedding rate increases. Also, the lower values of \(L\) provides a higher PSNR throughtout different embedding rate when compared to higher values of \(L\). The performance of proposed framework is compared with other latest schemes and state-of-the art methods such as Ki-Hyun Jung [19], Wang et al. [20], Qin et al. [21] Chang et al. [22] and Chang et al. [15] as depicted in Table 1. The proposed scheme outperforms conventional schemes for L = 3 and L = 4 and over a range of embedding rates, as shown in Table 1 and Fig. 4.

Fig. 4.
figure 4

Performance comparison of proposed method with the traditional methods for different cover images

4 Conclusion

Using an iterative weight update, this paper proposes a reversible data hiding approach on dual stego images. Iteratively, the weight is updated based on the error and the resulting data. To create dual stego images, the weight is then inserted in the cover pixels. The data is collected in the extraction process by calculating the inverse weight in reverse order. Metrics like embedding rate and PSNR are used to assess the algorithm’s success. The embedding capacity increases as the value of L increases, but the visual quality decreases. For L = 2 and L = 3, the proposed approach has an embedding capability of about 5,23,000 bits and 7,77,000 bits, respectively. In addition, for L = 2 and L = 3, the proposed approach offers an average PSNR of about 51.9 dB and 47.7 dB, respectively. When compared to other schemes, the proposed scheme offers a high embedding rate with high visual quality. In the future, we will apply our knowledge and skills to the development of a data embedding algorithm that is highly secure and robust and modifications.