# Edge Detection and Huffman Encoding Based Image Steganography with High Data Embedding Capacity

Butta Singh, Rajwinder Kaur, Manjit Singh, Himali Sarangal, Satveer Kour

► To cite this version:

Butta Singh, Rajwinder Kaur, Manjit Singh, Himali Sarangal, Satveer Kour. Edge Detection and Huffman Encoding Based Image Steganography with High Data Embedding Capacity. 6th International Conference on Computational Intelligence in Data Science (ICCIDS), Feb 2023, Chennai, India. pp.25-33, 10.1007/978-3-031-38296-3_3. hal-05466043

HAL Id: hal-05466043

https://inria.hal.science/hal-05466043v1

Submitted on 19 Jan 2026

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons CC BY 4.0 - Attribution - International License
<figure><img src="image_2.png" /></figure>

ifip

International Federation for Information Processing

This document is the original author manuscript of a paper submitted to an IFIP
conference proceedings or other IFIP publication by Springer Nature. As such, there
may be some differences in the official published version of the paper. Such
differences, if any, are usually due to reformatting during preparation for publication or
minor corrections made by the author(s) during final proofreading of the publication
manuscript.
<figure><img src="image_3.png" /></figure>

# Edge Detection and Huffman Encoding Based Image Steganography with High Data Embedding Capacity

Butta Singh<fnref n="1" />(✉), Rajwinder Kaur<fnref n="1" />, Manjit Singh<fnref n="1" />, Himali Sarangal<fnref n="1" />, and Satveer Kour<fnref n="2" />

**Abstract.** In the present study, an edge detector and Huffman encoding based image-steganography approach for high data embedding capacity is presented. High frequency pixel region is exploited to preserve the imperceptibility characteristics of the stego-image and cover-image. Confidential data is encoded with Huffman encoding based technique. Finally, 2ⁿ correction is applied to maintain the visual quality. A security key enhances the robustness of embedding and extraction process of the confidential message. The proficiency of the method is also collated with already proposed techniques with various evaluation parameters.

**Keywords:** Image steganography · Huffman encoding · Edge detection · EC · PSNR · SSIM

## 1 Introduction

The transmission and reception of digital data over the internet has increased on an exponential scale. As internet is an open access network, communicating the data through the internet become more convenient, as well as equally more difficult to protect the data from the malicious users. There are mainly two techniques for securing secret information, one is cryptography and other is data hiding [1, 2]. Cryptography approaches convert the secret data into an encrypted scribbled form, which is then transmitted and incomprehensible for any malicious user [3]. Data hiding is another method to secure the secret information using secret data embedding mechanism into the digital media (for example: text, audio, video, or images) [4]. Images are the digital cover media that are extensively employed in the various steganography techniques. The imperceptibility and robustness of the image steganography are the main design criterion while embedding secret data and stowing away the significant information in a cover media. Steganography can be broadly classified as Spatial and transform domain.

The spatial domain approaches directly alter the pixels for steganography within the cover image. In the last decade, the least significant bit (LSB) substitution is the mostly

<footnote n="1">¹ Department of Electronics and Communication Engineering, Guru Nanak Dev University, Regional Campus, Jalandhar, India
bsl.khanna@gmail.com</footnote>

<footnote n="2">² Department of CET, Guru Nanak Dev University, Amritsar, India</footnote>
employed spatial domain steganographic method. To date, various LSB replacement schemes are introduced (Chan and Cheng et al. [5], Mielikainen et al. [6]) to further enhance the stego-image and embedding capacity (EC). In transform domain steganography techniques, cover image transformed from spatial domain to any other domain [7–9]. The characteristics and special features of other domains are exploited to embed the secret information.

The intensity discontinuities with sharp pixel changes form the image edges. The edge pixels have randomness characteristics, so the edge pixel variations are unidentifiable [10]. Sobel, Canny are the famous edge detection methods that can be used in image steganography. But canny edge detection is the efficient edge detector and detects more edges as compared to Sobel. The canny edge detector uses Gaussian filter and threshold parameter to detect the edges. Image compression is a technique in which compact representation of image storage and transmission is possible [11]. Image compression is classified into lossless and lossy compression. The lossless compression is mostly employed in image steganography to encode the data. The methods that are used under the lossless compression are Huffman, Lempel-Ziv-Welch (LZW) and run length encoding [12–14]. In this proposed work Huffman encoding is used.

The primary aim of proposed approach is the EC improvement as well as to design a more secure algorithm for image steganography. This method is proposed by combining the features of edge detector and image compression method. The image compression method will encode and the secret key will increase the security of the secret message at the transmitter and receiver. The imperceptibility of the proposed approach is further enhanced by $2^n$ correction method. The jpg image of size 512 * 512 is used for embedding and extraction process.

# 2 Proposed Work

## 2.1 Edge Detection

It is observed that the embedding of secret information in the edge area is more imperceptible than the smooth areas. The edge area contains more random variations in pixel intensities than the smooth area. So, it becomes difficult for the intruder to detect the secret information. In this proposed approach, canny edge detector method is used for cover image edge detection [15]. The detected edges are sorted and exploited to hide the secret information.

## 2.2 LSB Substitution

LSB is an established data embedding method, which exploit the lsb locations to conceal the data in the pixels. After LSB modification, the human vision system is not able to visualize the embedded data in stego-image. Replacement of the number of LSB is calculated depending upon the capacity of the edge pixels.
## 2.3 Huffman Encoding

David A. Huffman [16], proposed a lossless data compression technique, Huffman encoding, widely employed in image and video compression approaches. Huffman encoding converts the data into little bit stream and form a binary tree. Initially, it sets the signal say (A1, A2, A3, A4) and sort them in ascending order corresponding to their probability of occurring. Then, the signals with smallest probability are added together and allocated to the parent node. Then repeat the whole process till only one root node left. Assign 0 and 1 to each node and translate the code from the leaf to root node to form the Huffman table. Huffman encoding encodes the secret information into 0 and 1 before embedding. Each secret image pixel is allotted a binary code. Bit-Length (B<sub>L</sub>) is defined as the amount of the embedded bits in edge pixels (P). The cover image pixels have different embedding capacity. So, the variable bit length is calculated as:

```
if P ≥ 2^7
    B_L = 5
else if P ≥ 2^6 & P < 2^7
    B_L = 4
else if P ≥ 2^5 & P < 2^6
    B_L = 3
else if P ≥ 2^4 & P < 2^5
    B_L=2
else
    B_L=1
end if
```

## 2.4 Embedding Process

In the embedding stage of proposed method, first load the cover image (jpg). Canny edge detector, a widely used edge detection operator, is employed on cover image prior secret data embedding. The security and robustness get improved by sorting of edge pixels. The secret data is converted into binary bit stream using Huffman encoding. The security of the algorithm is enhanced by secret key provided for secret data embedding. The secret information of computed bit length, Huffman table and secret key is embedded into the sorted edge pixels. After embedding, the edge pixel value is adjusted using 2<sup>n</sup> correction method to maintain the imperceptibility of the cover image. Finally, a stego-image is obtained for transmission. Algorithm 1 shows the detailed algorithm of embedding stage.
**Algorithm 1: Embedding stage**

**Initialization:** Error ($Er$), Stego-pixel ($Sp$), Cover edge pixel ($P$), secret data ($Gsecret$), Stego-pixel after 2$^n$ bit correction ($Np$)

Load the cover image

Detect the edge pixels applying canny edge detector.

Calculate the value of $BL$.

Select the secret data, $Gsecret$

Apply Huffman encoding to the secret data and construct the Huffman table.

Embed secret information, Huffman table, and secret key into the edge pixel according to the following conditions.

$$Er = P - Sp$$

if $Er \ge 2^{n-1}$ and $Sp - (2^n) \ge 0$ then

$$Np = Sp - 2^{(n-1)}$$

$$key = 1$$

else if $Er \le -(2^{(n-1)})$ and $(Sp + 2^n) \le 255$ then

$$Np = Sp + 2^{(n-1)}$$

$$Key = -1$$

else

$$Np = Sp$$

$$key = 0$$

end

The above mentioned method attains high imperceptibility by selecting stego-image pixels with less deviation from cover image pixels.

**2.5 Extraction Process**

The extraction stage of proposed algorithm consist the following steps.

1. Load the stego-image.

2. Apply Canny edge detection operator.

3. Sort the edges pixel values.

4. Calculate the bit length $BL$ using the edge pixels.

5. Extract the LSB bits using the secret key as explained in Algorithm 1

6. Decode Huffman table.

7. The secret and cover image formation.

**3 Performance Metrics**

The proposed edge detection and Huffman encoding based mechanism is assessed by various parameters. The explanation of these parameters is described as:
## 3.1 EC

Embedding capacity (EC) measures the amount of data (excluding any overhead or dummy bits) achievable to embed in a specified cover media. The larger the EC of a algorithm, better the steganography system.

## 3.2 PSNR

Peak signal to noise ratio (PSNR) expressed (Eq. 1) in the logarithmic decibel scale is the ratio of maximum power of the cover-media pixels to the mean squared error (MSE) (Eq. 2) of the cover-image (S) and stego-image (S'') of size M rows and N columns [2]. A low MSE and high PSNR value indicates better will be the image quality.

$$PSNR = 10 \log_{10} \left( \frac{255^2}{MSE} \right) db \qquad (1)$$

where

$$MSE = \frac{1}{MXN} \sum_{k=1}^{M} \sum_{i=1}^{N} (S_{ki} - S''_{ki})^2 \qquad (2)$$

## 3.3 Structural Similarity Index (SSIM)

The image quality measure, SSIM (developed by Wang et.al [17]), applied to quantify the similarity between the S and S''. The SSIM (Eq. 3) represents the structured arrangement of three image characteristics aspects; loss of correlation, luminance and contrast distortion (Eqs. 4, Eq. 5 and Eq. 6). The SSIM is defined as follow:

$$SSIM(i, k) = \frac{(2\mu_i\mu_k + 1)(2\sigma_{ik} + H_2)}{(\mu_i^2 + \mu_k^2 + H_1)(\sigma_i^2 + \sigma_k^2 H_2)} \qquad (3)$$

$$\text{Luminance factor: } \mu_i = \frac{1}{N} \sum_{j=1}^{N} (S_j, \mu_k = \sum_{j=1}^{N} S'') \qquad (4)$$

$$\text{Contrast Calculation: } \sigma_i = \frac{1}{N-1} \sum_{j=1}^{N} (S_j - \mu_i)^2, \sigma_k = \frac{1}{N-1} \sum_{j=1}^{N} (S_j - \mu_k)^2 \qquad (5)$$

$$\text{Correlation Parameter: } \sigma_{ik} = \frac{1}{N-1} \sum_{j=1}^{N} (S_j - \mu_i)(S''_j - \mu_k) \qquad (6)$$

The parameters, $H_1 = (f_1L)^2$ and $H_2 = (f_2L)^2$ $H_2 = (f_2L)^2$ will stabilize the division with weak denominator. The values $f_1 = 0.01$ and $f_2 = 0.03$ are applied in the present study. Whereas the dynamic pixels range (L) for a grayscale image of 8 bits/pixels is 255.
## 4 Result and Discussion

The performance of the projected algorithm is accessed on MATLAB 2017a with window 7, i5 system. All the images used for simulation are acquired from http://sipi.usc.edu/database/ in jpg format of size 512 * 512 as shown in Fig. 1. The projected method improves the EC while maintaining the PSNR. To analyze the proposed method, PSNR, EC and SSIM parameters are considered and evaluated for cover images Boat, Elaine, Couple, Lena and Pepper. PSNR equal to 53.6934, 52.0832, 57.0084, 55.0084 and 54.5622 was obtained at EC equal to 127695, 90060, 111342, 72635 and 74703 bits for cover image Boat, Elaine, Couple, Lena and Pepper respectively (Table 1). The SSIM, structured consolidation of features; loss of correlation, luminance and contrast distortion is applied to evaluate the similarity between the cover and stego-image. SSIM values comes to be higher than 0.99 for all the cover media which justifies the efficacy of the proposed algorithm. high ssim values justify the acceptable perceptibility of the stego image for all the images.

<table><caption>**Table 1.** Evaluation of the proposed approach using EC, PSNR and SSIM of grayscale images</caption><thead><tr><td>Cover image</td><td>EC</td><td>PSNR</td><td>SSIM</td></tr></thead><tbody><tr><td>Boat</td><td>127695</td><td>53.6934</td><td>0.9984</td></tr><tr><td>Elaine</td><td>90060</td><td>52.0832</td><td>0.9981</td></tr><tr><td>Couple</td><td>111342</td><td>57.0084</td><td>0.9995</td></tr><tr><td>Lena</td><td>72635</td><td>55.0390</td><td>0.9988</td></tr><tr><td>Pepper</td><td>74703</td><td>54.5622</td><td>0.9992</td></tr></tbody></table>

On the other hand, the subjective test was performed for the examination of stego-image on human visual system (HVS). Figure 1 demonstrates the cover, edges and stego-images applied to conduct the experimentation. Even after embedding the secret bits the stego and cover images are not visually distinct. HVS analysis of the stego-image exhibit that even with large embedding stego image quality does not amend and hence the proposed method is imperceptible to EC. In total, the objective and subjective analysis accomplishes that the proposed steganography approach achieved sustained optimal image visual quality on various greyscale images and different EC combinations.
<table><caption>Fig. 1. Cover, Edges and Stego-images obtained by the proposed algorithm</caption><thead><tr><th>Image</th><th>Cover Image</th><th>Edge Detection</th><th>Stego-Image</th></tr></thead><tbody><tr><td>Boat</td><td></td><td></td><td></td></tr><tr><td>Couple</td><td></td><td></td><td></td></tr><tr><td>Lena</td><td></td><td></td><td></td></tr><tr><td>Elaine</td><td></td><td></td><td></td></tr><tr><td>Pepper</td><td></td><td></td><td></td></tr></tbody></table>

## 5 Performance Comparison

Table 2 demonstrates the Comparison of projected method and other techniques in literature. the performance is compared with other image edges detection-based embedding techniques [15, 17, 18]. In the proposed method, simulations were experimented on the same cover images as in the other techniques for justified comparison. The algorithm is
compared in form of PSNR and EC parameters (Table 2). The proposed approach hides higher secret bits in lena, elaine and pepper with acceptable level of PSNR value.

<table><caption>**Table 2.** Evaluation and performance comparison of the proposed algorithm</caption><thead><tr><th rowspan="2">Images</th><th rowspan="2">Size</th><th rowspan="2">Author</th><th rowspan="2">EC</th><th rowspan="2">PSNR</th><th colspan="2">Proposed Method</th></tr><tr><th>EC</th><th>PSNR</th></tr></thead><tbody><tr><td rowspan="3">Lena</td><td rowspan="3">512 * 512</td><td>Sun et al. [15]</td><td>38427</td><td>63.4807</td><td>72635</td><td>55.0390</td></tr><tr><td>Yu et al. [18]</td><td>37348</td><td>55.5273</td><td>72635</td><td>55.0390</td></tr><tr><td>Vanmathi et al. [19]</td><td>71504</td><td>59.840</td><td>72635</td><td>55.0390</td></tr><tr><td rowspan="3">Elaine</td><td rowspan="3">512 * 512</td><td>Sun et al. [15]</td><td>35852</td><td>62.7690</td><td>90060</td><td>52.0832</td></tr><tr><td>Yu et al. [18]</td><td>753695</td><td>55.8437</td><td>90060</td><td>52.0832</td></tr><tr><td>Vanmathi et al. [19]</td><td>73704</td><td>59.350</td><td>90060</td><td>52.0832</td></tr><tr><td rowspan="3">Pepper</td><td rowspan="3">512 * 512</td><td>Sun et al. [15]</td><td>35946</td><td>63.2399</td><td>74703</td><td>54.5622</td></tr><tr><td>Yu et al. [18]</td><td>34263</td><td>56.3618</td><td>74703</td><td>54.5622</td></tr><tr><td>Vanmathi et al. [19]</td><td>73704</td><td>59.410</td><td>74703</td><td>54.5622</td></tr></tbody></table>

# 6 Conclusion

In this proposed work, a high embedding capacity and imperceptible method using edge detection and Huffman encoding with secret key is discussed. It employs canny edge detector to hide a greater secret bits in the edges than in the smooth area to maintain the imperceptibility. Beside that algorithm security is further enhanced using security key. The proposed algorithm was evaluated using PSNR, EC and SSIM and outperform for the five grayscale images. The evaluation metrics confirm the high embedding capacity, PSNR and SSIM parameters.

# References

1. Shankar, K., Eswaran, P.: Sharing a secret image with encapsulated shares in visual cryptography. Proc. Comp. Sci. **70**, 462–468 (2015)

2. Kadhim, I.J., Premaratne, P., Vial, P.J., Halloran, B.: Comprehensive survey of image steganography. Techniques, evaluations, and trends in future research. Neurocomputing **335**, 299–326 (2019)

3. Tripathi, J., Saini, A.: Enhanced visual cryptography. An augmented model for image security. Proc. Comp. Sci. **167**, 323–333 (2020)

4. Kaur, R., Singh, B.: A hybrid algorithm for robust image steganography. Multidimension. Syst. Signal Process. **32**(1), 1–23 (2020). https://doi.org/10.1007/s11045-020-00725-0

5. Chan, C.K., Cheng, L.M.: Hiding data in images by simple LSB substitution. Pattern Recogn. **37**(3), 469–474 (2004)

6. Mielikainen, J.: LSB matching revisited. IEEE Signal Process. Lett. **13**(5), 285–287 (2006)
7. Zhang, J., Lu, W., Yin, X., Liu, W., Yeung, Y.: Binary image steganography based on joint distortion measurement. J. Vis. Commun. Image Represent. **58**, 600–605 (2019)

8. Sharma, V.K., Mathur, P., Srivastava, D.K.: Highly secure DWT steganography scheme for encrypted data hiding. In: Satapathy, S.C., Joshi, A. (eds.) Information and Communication Technology for Intelligent Systems. SIST, vol. 106, pp. 665–673. Springer, Singapore (2019). https://doi.org/10.1007/978-981-13-1742-2_66

9. Kaur, R., Singh, B.: A novel approach for data hiding based on combined application of discrete cosine transform and coupled chaotic map. Multimed. Tools App. **80**(10), 14665–14691 (2021). https://doi.org/10.1007/s11042-021-10528-5

10. Fang, D., Sun, S.: A new scheme for image steganography based on hyper-chaotic map and DNA sequence. J. Inf. Hiding Multimed. Signal Process. **9**(2), 392–399 (2018)

11. Zhou, N., Zhang, A., Zheng, F., Gong, L.: Novel image compression-encryption hybrid algorithm based on key-controlled measurement matrix in compressive sensing. Opt. Laser Technol. **62**, 152–160 (2014)

12. Dubey, V.G., Singh, J.: 3D medical image compression using Huffman encoding technique. Int. J. Scientific Res. Pub. **2**(9) (2012)

13. Saravanan, C., Surender, M.: Enhancing efficiency of Huffman coding using Lempel Ziv coding for image compression. Int. J. Soft Comp. Eng. **2**(6), 38–41 (2013)

14. Badkobeh, G., Fici, G., Kroon, S., Lipt'ak, Z.: Binary jumbled string matching for highly run-length compressible texts. Inf. Process. Lett. **113**(17), 604–608 (2013)

15. Sun, S.: A novel edge based image steganography with 2k correction and Huffman encoding. Inf. Process. Lett. **116**(2), 93–99 (2016)

16. Huffman, D.A.: A method for the construction of minimum-redundancy codes. Proc. IRE **40**(9), 1098–1101 (1952)

17. Wang, Z., Bovik, A.C.: A universal image quality index. IEEE Signal Process. Lett. **9**(3), 81–84 (2002)

18. Yu, J.G., Yoon, E.J., Shin, S.H., Yoo, K.Y.: A new image steganography based on 2k correction and edge-detection. In: Fifth International Conference on Information Technology: New Generations, vol. 2008, pp. 563–568. IEEE, Las Vegas, NV, USA (2008)

19. Vanmathi, C., Prabu, S.: Image steganography using fuzzy logic and chaotic for large payload and high imperceptibility. Int. J. Fuzzy Syst. **20**(2), 460–473 (2018)