1 Introduction

Computer systems are designed using digital electronics, which means they may keep their electronic circuits in either one of two states: on or off. In other words, computer systems use binary number system. The binary number system is a method by which ordinary numbers like 42 or 365 are stored as patterns of 1’s and 0’s [1]. The binary numbers are weighted numbers, and the value of the bit increases by a factor of two as we move one bit to the other from Least Significant Bit (LSB) to Most Significant Bit (MSB), with the value of LSB being one and MSB being \(2^n/2\), where n is the number of bits. Meanwhile, the ongoing scaling of MOS transistors resulted in new nano-scale devices. Scientists have moved from traditional deterministic binary computing to different computing technologies such as probabilistic stochastic computing, because of the reliability issues with deterministic binary computing. In 1956, Von Neumann laid the foundation of stochastic computing (SC) [2] . Gaines and Poppelbaum [3] followed this path by introducing the basic concepts and the construction of general-purpose SC computers. In the 1990s, Jeavons, Kim, and Shanblatt [4] studied the specialized applications of SC, including artificial neural networks and hybrid controllers. SC has been described as potentially useful for specialist devices needing small-size, low-power, soft-error tolerance, and limited precision over the years. So, in terms of integration, hardware costs, and noise robustness, SC is efficient [5].

Machine learning and image processing applications have been used in binary and frequency domains in their methods of visual classifications [6]-[7]-[8], however recently, the focus is on stochastic computing as complex arithmetic functions can be implemented using only simple blocks [9] -[10]. For example, a scaled adder can be implemented with a single multiplexer [11]. To represent a binary number of n bits, it will be \(2^n\) bits in the stochastic format, while the probability of seeing a 1 denotes the value of the number. Stochastic numbers have several formats (unipolar, bipolar, inverse bipolar, ratioed, etc.), and their use depends on the type of application. The number of 1’s in the overall sequence is essential in all the formats. In unipolar format, the value of a stochastic number depends on the ratio of the total number of 1’s to the total length of a sequence and not on the location of 1’s as in binary computing [12]. Therefore, bit flipping does not influence the overall value because the location of the bit has a minor impact making the system tolerant for faults. Since it will be possible to change more than one bit in stochastic numbers, the data hiding capability will be more extensive, making it an excellent tool for steganographic applications [13].

Steganography is the practice of hiding data in a text, image, audio or video [14]-[15]. In image steganography, the focus is on hiding an image referred to as the secret image within another image referred to as the cover image. In binary computing, image steganography was firstly introduced by embedding one bit of the secret image into the LSB of the cover image [16]-[17]. Therefore, LSB techniques have been most commonly used to hide data based on digital features, and many algorithms have been proposed in the literature based on this technique. These algorithms focused on increasing the number of stored bits as proposed in [18]. It divides the cover image into blocks of 2x2 pixels and calculates the determinant to define the best location to embed pixels. Edge area is used to embed more bits as edge area is insensitive to value changes [19]. However, these LSB techniques allowed unauthorized receivers to guess the hidden data, making them less secure. This has led the researchers to use encryption methods such as chaotic maps [20] to generate pseudo-random keys used to choose the pixel position of the cover image randomly. The main method in most of the encryption techniques is generating keys to encrypt data and then restore the information using synchronized keys [21, 22] and [23]. Using the LSB in the binary image steganography is not the most efficient method due to the limited number of stored bits without affecting the cover image’s resolution. Therefore, researchers employed different techniques in the literature, which helps in hiding the images, including compressing the secret image and embedding the secret image using tri-way pixel-value differencing to achieve higher payload [24]. Recently, artificial neural networks (ANNs) and convolutional neural networks(CNNs) have been used to obtain efficient binary image steganalysis scheme [25]. Nowadays, Researchers aim to achieve high capacity steganography to embed more secret data so the single-stream can hold more than one pixel. A binary pattern that preserves the Local Binary Pattern (LBP) feature of the cover with comparable embedding rates was proposed in [26]. Joint distortion measurements which depend on the visual effects and discrimination effects of flipping corresponding pixels were introduced in [27].

Combining edge detector and high payload technique for colored images to produce a new steganographic algorithm was proposed in [28]. In [29], the combination of pixel value difference and LSB substitution was shown to provide higher capacity and less distortion. Steganography algorithm, based on the Wavelet Packet Decomposition (WPD), was proposed in [30]. A method to enhance the payload message by embedding messages on the dilated edge areas by the LSB method was proposed in [31]. An approach that uses an adaptive embedding process over dual-tree complex wavelet transform sub-band coefficients with machine learning-based optimization techniques, employed to embed the secret data over optimal cover-image-blocks with minimal retrieval error, was given in [32]. A method that uses batch steganography to allocate a large payload to multiple covers to keep the whole converting communication at a high level of security was proposed in [33]. A method based on deep learning was investigated in [34] where the discrete cosine transform was used to transform the secret image, and then the transformed image was encrypted by elliptic curve cryptography to improve the anti-detection of the obtained image. A novel approach develops a statistical framework for image steganography in which the cover and the stego messages are modeled as multivariate Gaussian random variables was presented in [35]. These methods had massive computational time with increased complexity without significantly enhancing the number of bits stored in each pixel.

This paper introduces a novel method based on stochastic computing, providing high-capacity digital image steganography. The proposed method achieves a higher capability of the number of stored bits in each pixel without highly affecting the resolution of the cover image or being easily detected. This is the first paper where stochastic computing has been used for high-capacity image steganography, as per the authors’ best knowledge. The method is tested to store five images of the same size in the cover image. The method is tested for grey images only. In the future, the method shall be tested for color images and other types of steganography as well.

The paper is organized as follows: the proposed method and converters blocks are discussed in Section 2. Section 3 describes the simulation results. Finally, the paper is concluded in Section 4.

Fig. 1
figure 1

Transmitting and receiving systems for proposed digital image stenography technique (a) Transmitter, and (b) Receiver

2 Proposed steganography method

In binary steganography, each pixel of image is converted into binary stream of fixed number of bits (e.g. 8). In this binary stream, each bit is weighted and the weight (value) of bits increase as we move from LSB to MSB. Therefore, in order to hide the bits in this binary stream with no visible change in the pixels of the original image, the LSB bits are usually used for storing the information. Thus the storage capability of binary stegnography is limited as the number of bits used for hiding the data cannot be usually more than two as it leads to the significant change in the value of pixels of original image. Besides, the binary stegnography has security issues if the bits are stored in the LSBs as the location of bits shall be known to an un-authorized receiver in advance. Therefore, several techniques have been given in the literature to improve the security of binary stegnography. However, the capacity of binary stegnagrphy is still low as usually more than two bits cannot be used for data hiding purpose. Therefore, in this paper, an effort has been made to explore the capability of stochastic computing in storing more bits than conventional binary image steganography. For this purpose, a binary stream of N bits (e.g. 8 bits) representing a pixel of the original image is first converted into a stochastic stream of of \(2^N\) (e.g. \(2^8\) bits). The value of stochastic stream is calculated by counting the number of 1’ in the stream. Each bit of the stochastic stream is unweighted and has the same value. Therefore, while in binary stegnography, there is an option of hiding the bits in N-bits of pixel; in stochastic stegnography, there will be an option of hiding the bits in \(2^N\)-bits of stochastic representation of pixel. Thus the data hiding capacity of the proposed method is much more than the conventional binary stegnography. However, the method should include the retrieval of bits at the receiver which has been described in detail in the paper. The complete architecture of the transmitter and the receiver is shown in Fig. 1. The transmitter is responsible for reading the cover image, then converting each binary pixel to a stochastic stream using LFSR, which allows hiding of more than one binary pixel of the secret image within the stochastic streams of the cover image. After embedding the secret image in the cover image and applying our proposed algorithm using the lookup table (LUT) method, the output stream guarantees that the quality of the stego image is high, and the secret image can be recovered. The LUT contains all possible streams with its seed, which will help to get the seed of each new optimized stochastic stream to restore the same stream at the receiver. The stego image will be transmitted in binary format to minimize the overhead of sending each pixel in a stochastic format. At the receiver, the pixels of the Stego image will be converted back to stochastic sreams using the corresponding seed pixel of the seed image to restore the secret image pixel with the least possible error.

2.1 Proposed algorithm

The proposed method is a new approach to steganography that uses stochastic representation rather than binary representation. The data in stochastic computation is represented by random sequences of 0’s and 1’s. The probability of seeing a 1 represents the value of the number in these sequences, which are described as stochastic numbers. We have followed the unipolar format in this paper. Therefore the ratio of 1’s to the total length of a sequence defines the value of a stochastic number. Furthermore, the length of a sequence does not have to be constant. For example, the decimal number 0.5 can be represented in stochastic format by the following sequence: 01 (1/2), 10 (1/2), 1010 (2/4), 0011 (2/4), 011001(3/6), 0100101011 (5/10), etc. The stochastic numbers are like binary numbers, but the essential advantage of the stochastic format in steganography is that the value of the number does not depend on the weight of bits but the number of 1’s present in the bit-stream. Unlike binary representation, the error in one-bit transmission in the stochastic number is less than in the binary number. The proposed technique can be summarized as in the following steps:

2.1.1 Lookup table (LUT) construction

LFSR generates a stochastic stream representing the input binary number of each pixel, changing the seed will result in a shifted stream, so each binary number can have 256 stochastic stream representations as the seed length is 8 bits which allow generating a LUT that has 256 stochastic representations for all pixel values ranging from 0 to 255.

2.1.2 Converting cover image to stochastic

At the transmitter, the cover image is converted to a stochastic format using LFSR at a precisely specified seed, and it is prepared to store the hidden image. Stochastic to binary conversion block is shown in Fig. 2.

Fig. 2
figure 2

Binary to stochastic conversion block

2.1.3 Embedding secret image in the cover image

After converting the cover image to stochastic representation, the secret image binary representation is hidden in the cover image. The stochastic format of the cover image provides flexibility in storing the bits at any place determined by the transmitter, which is more secure than binary steganography. It can hide more than one bit due to the probabilistic behavior of the stochastic number. Because of the stochastic sequence length, each cover image pixel can hold one or more pixels of the secret images.

2.1.4 Applying data recovery algorithm Using LUT

Recovering the secret image requires applying our proposed data recovery algorithm on the stego image before transmitting it. The data recovery algorithm focuses on keeping the stego image undetectable and avoiding attacks. Algorithm 1 describes applying our proposed algorithm procedure in detail.

Algorithm 1
figure a

Proposed method

2.2 Binary to stochastic converter

A linear feedback shift register (LFSR) is used to generate a pseudo-random stream of \(2^n-1\) sequences for every n-bits binary number. It consists of n D-flip-flops, which operate as shift elements and logic gates. LFSR is one of the most vital circuit to be used in the main block of generating a stochastic random stream of bits, so the standard design must be modified to give a full-length sequence. An 8-bit LFSR shown in Fig. 3 and comparator blocks are used to convert binary numbers into stochastic streams, as shown in Fig. 2 [36]. LFSR’s input is an 8-bit seed, so the output is a sequence of 256 bits. The role of the comparator is to compare each output value of the 256 sequences (Xn) with the pixel’s binary value (Rn) and produces a 1-bit output that carries a value according to (1).

$$\begin{aligned} Y = \left\{ \begin{aligned} 1, \\ 0, \end{aligned} \right. \begin{aligned} Xn\le Rn \\ Xn>Rn \end{aligned} \end{aligned}$$
(1)

The output of the comparator is Y which is 256 bits in length, carrying a total number of ones equals to the decimal value of the pixel. Changing the seed will generate a different stream that is still carrying the same number of 1‘s.

2.3 Stochastic to binary converter

In this phase, the enhanced stego image is converted into its binary form for its transmission. Converting a stochastic stream to binary form needs less hardware as it is depending on counting the number of rising edges of the input signal then representing this value in its binary format as shown in Fig. 4 [37].

Fig. 3
figure 3

8-Bit Linear feedback shift register

Fig. 4
figure 4

Stochastic to binary number conversion block

2.4 Data extraction

After receiving the enhanced stego image and seed image, each pixel is converted to stochastic streams using LFSR with the corresponding seed pixel. By knowing the location of secret image pixels, they can be easily restored with the minimum possible error.

3 Simulation and results

The simulation is implemented in two stages; the first stage is the implementation of the binary stochastic converters shown in Figs. 2 and  4. They are implemented using Verilog, a hardware description language used to implement the systems on digital development boards such as Field Programmable Gate Array (FPGA) boards to assess their high-speed operation. The second phase is our proposed method for steganography using python, a general-purpose and open source programming language popularly used for image processing nowadays. The cover image and the secret images are considered with a size of \(512\times 512\), which are some of the standard images such as Lena, Baboon, Cameraman, Fruits, Airplane, Boat, cat, Watch, Goldhill, Tulips, Mountain, Sails, Zelda, Peppers, Monarch, Pool, Arctichare, Lake, Boy, and Barbara [38].

The steganography performance is measured by the peak signal to noise ratio (PSNR), Structural similarity (SSIM) index, and payload. The PSNR is used to detect asymmetry between images [39]. The PSNR (in dBs) is defined in (2).

$$\begin{aligned} PSNR=20\log {(\frac{MAX_f}{\root \of {MSE}})}, \end{aligned}$$
(2)

where Mean Square Error (MSE) is defined in (3):

$$\begin{aligned} MSE=\frac{1}{mn}\sum _{i=0}^{m-1}\sum _{j=0}^{n-1} \Vert f(i,j)-g(i,j)\Vert ^2, \end{aligned}$$
(3)

where f(ij) is original image’s pixel, g(ij) is the stego image’s pixel, \( m\times n \) is size of image.

Fig. 5
figure 5

One image steganography (a) Stego image before optimization (b) Transmitted Stego image, (c) Restored secret image

Fig. 6
figure 6

Two images steganography (a) Stego image before optimization (b) Transmitted Stego image, (c) First restored secret image and (d) Second restored secret image

The SSIM is a perceptual measure that quantifies the deterioration of image quality due to processing, such as compression techniques or data transmission losses. It is a total reference metric that involves a reference image and a processed image obtained from the same image. The values of the SSIM ranges between 0 to 1. 1 means a perfect match of the reconstructed image with the original one. The SSIM is defined in (4):

$$\begin{aligned} SSIM(x,y) = \frac{(2\mu _x\mu _y + C_1) + (2 \sigma _{xy} + C_2)}{(\mu _x^2 + \mu _y^2+C_1) (\sigma _x^2 + \sigma _y^2+C_2)}, \end{aligned}$$
(4)

where x is the original cover image, y is the stego image, \(\sigma _{xy}\) is the image covariance of image x against image y, \(\sigma _x^2\) is the variance of image x, \(\sigma _y^2\) is the variance of image y, and \(C_1\),\(C_2\) represent the constant values [39]. The payload in image steganography applications is defined as the maximum amount of a hidden data that can be embedded in a cover image, and the payload capacity is measured as the number of bits per pixel (bpp). The payload is defined in (5):

$$\begin{aligned} Payload=\frac{\text {Max. number of hidden message bits}}{m\times n}(bbp). \end{aligned}$$
(5)

Figure 5 shows the results of one image steganography system, which contains the secret image and the stego image before and after applying the proposed data recovery algorithm. The resulting images of the two images steganography and the three images steganography are shown in Figs. 6 and 7 respectively. The PSNR and payload values of one, two and three image steganography are shown in Table 1. The respective average values of PSNR and SSIM of the stego image for one image steganography is 39.5 dB and 0.9856, while for two image steganography, it is 38.46 dB and 0.9688. Finally, for three image steganography, it is 31.26 dB and 0.9068, respectively. Considering the payload and using (5), the values of payloads are 8,16 and 24 bpp in case of one, two, and three images steganography, respectively, which are higher than the proposed methods given in Table 2. As the seed image is transmitted of the same size as the stego image, which causes an overhead, so the payload will be reduced to half of its original value, which is still more extensive than the payloads compared to the methods given in Table 2.

Fig. 7
figure 7

Three images steganography (a) Stego image before optimization (b) Transmitted Stego image, (c) First restored secret image and (d) Second restored secret image (e) Third restored secret image

3.1 Scope of the Proposed Method

As stochastic steganography is introduced in this paper, the high capacity of embedding secret images can be extended to a higher number of images due to the large length of stochastic streams. Figures  8 and  9 show examples of embedding four and five images, respectively. Reaching a payload of 40 bpp, but the trade-off is the PSNR, which needs special attention for future research endeavors of the proposed method.

Table 1 Results of stego images of \(512 \times 512\) dimension, hiding one, two and three images of the same dimension
Table 2 Comparison of payload and PSNR of proposed method with the reported high capacity techniques secret images

3.2 Error robustness

One of the main features of stochastic computing is error robustness. So, simulating both binary and stochastic formats after steganography at different Z bits shows that the error in simple binary steganography increases exponentially till it reaches 100 percent when all bits are flipped while stochastic shows high error robustness as the error increases slowly as shown in Fig. 10.

Fig. 8
figure 8

Four images steganography (a) Stego image before optimization (b) Transmitted Stego image, (c) First restored secret image, (d) Second restored secret image, (e) Third restored secret image, and (f) fourth restored secret image

Fig. 9
figure 9

Five images steganography (a) Stego image before optimization (b) Transmitted Stego image, (c) First restored secret image , (d) Second restored secret image ,(e) Third restored secret image , (f) Fourth restored secret image ,and (g) fifth restored secret image

Fig. 10
figure 10

Error of stochastic and binary steganography at different z bits

3.3 Attacks

Attacks are considered a challenge to the proposed method as the seed image is highly needed to restore the secret images. Different types of attacks, such as cryptographic attacks, aim to attack the security data embedding in the images to find a way to remove the embedded images or embed misleading secret data. Another type is protocol attacks, which aim to attack the entire concept of the steganography application. The seed image is the most critical data that needs to be highly protected for the proposed method. Attackers can depend on the concept of the inversion of the seed image to corrupt the recovery of the secret images. The idea behind inversion is that the attacker subtracts the attacked data with a sequence of data created by him and claims to be the owner of the seed image [40]. One of the solutions is to hide our seed image while transmitting, which can be done by using an RGB cover image to have more degrees of channels to hide the seed image. Figure 11 shows a trial in embedding one secret image at the red channel while the blue has the seed image. It can be optimized to have more efficient results in future work.

Fig. 11
figure 11

RGB image with one secret image and seed image

4 Conclusion

This paper proposed a method in image steganography using stochastic computing. The stochastic format of the cover image provides flexibility in placing the bits at any place determined by the transmitter, which is more secure than binary steganography. Besides, the proposed method can hide more data due to the probabilistic nature of the stochastic numbers, thereby increasing the payload of cover images. The transmitted stego image can hold up to three secret images of the same size as the cover image achieving a payload up to 24 bpp and effective payload considering seed image as overhead is 12 bpp which is the highest payload compared to previously reported binary steganography methods. In future work, machine learning algorithms can be trained to identify features in an image that can be modified to hide data without significantly altering the visual appearance of the image. This can result in more secure and robust steganographic systems that are less likely to be detected by attackers. Also, RGB images can be considered instead of grayscale images to improve the payload. Furthermore, the receiver needs additional information to restore the secret data with a specific algorithm using the additional transmitted information. This can be avoided if using encryption methods with less overhead or using RGB images to hide the seed image.