Skip to content

This is a project on implementing Image steganography in Matlab using Block - DCT and Huffman Encoding

Notifications You must be signed in to change notification settings

SaiManojGubbala/Image-Steganography

Repository files navigation

Image Steganography


This is a project on Image Steganography which is performed using Block-DCT and Huffman Coding


Description :

              Image steganography is the art of hiding information into a cover 
image. This project presents a technique for Image steganography based 
on Block-DCT, where DCT is used to transform original image (cover image) 
blocks from spatial domain to frequency domain. Firstly a grey scale image of 
size M× N is divided into no joint 8 × 8 blocks and a two dimensional Discrete 
Cosine Transform(2-d DCT) is performed on each of the P = MN / 64 blocks. 
Then Huffman encoding is also performed on the secret messages/images 
before embedding and each bit of Huffman code of secret message/image is 
embedded in the frequency domain by altering the least significant bit of each 
of the DCT coefficients of cover image blocks.

Methodology :

This Method of Image Steganography uses Huffman Coding to embed the bits into the cover image
Since Huffman Coding decreases the number of bits required to embed
The Image Quality of The Cover Image is not reduced Heavily as compared to normal lsb embedding 
Normal method uses 8 bits to represent every pixel value (range 0 -255) for grey scale

Block-DCT is performed on The Cover Image to convert the Image into frequency domain from spatial domain
This is done to find the high frequency elements in the image
Because, Human eyes can't really see the high frequency parts in the image 

This technique is widely used in many image compression Techniques such as JPEG

After converting it to frequency domain we perform Quantization to reduce amount of high frequency elements in the image
As these elements gets reduced to value zero The amount of storage required to store the image or transmit the image is also reduced
By keeping the Image Quality closer to the RAW Image 
- Better Image Compression  

Then Zig-Zag Scaning is also Done to the image matrix in frequency domain Could also be considered as improved security because the order of embedding changes
Because , The matrix obtained may have intra block correlation to remove this zig zag  
scanning is done which results in 1d array which is arranged in acceding order.    

Note That All of These operations are performed on individual Block Matrix i.e(8*8 Matrices) of Image Matrix

References :


Running this Code :

The Codes should be Run in the following order
- EncodingImage.m
- Embedding.m
- Converting.m
- Decoding.m
- Displaying.m
But make sure that all the files are in the same folder including 
- CosineTransform.m
- InverseCosineTransform.m
The above two files have functions to perform Discrete Cosine Transform and Inverse Discrete Cosine Transform 
The inbuilt Matlab ZigZag function is used for zigzag scanning 

Procedure to Perform :

Encoding :

Screenshot 2024-06-07 200958

Decoding :

Screenshot 2024-06-07 201019

DCT Formula :

Screenshot 2024-06-07 201038

Steps Involved :


  • EncodingImage

    • Read The Image using imread() function
    • Convert The Image into a row matrix using reshape() function
    • Find The Unique Elements and their frequency and sort them by Highest frequency elements on the top using Hashing Method and Sorting in this Bubble Sort is used
    • Now Generate Huffman Dictionary using huffmandict()
    • Now Convert it to Binary using Huffman Encoding using the inbuilt huffmanenco()
    • Convert this matrix into a single bit binary column matrix using The matrix transform using ( : ) or ' operator

  • Embedding
    • Read The Cover Image using the imread() function
    • Now Apply 2-D DCT ( 2-Dimensional Discrete Cosine Transform ) to each 8*8 block matrix to this function is written in the CosineTransform file and the syntax goes as follows CosineTransform() function
    • Now Perform Quantization using The Quantization table provided in Research Paper - 2 :
      1. Multiple Image Steganography using LSB – DCT Technique
    • After this use the round() function to convert the high frequency valued elements to value zero after they are quantized
    • Now perform zigzag scanning to each 8*8 Block Matrix and Create a new Row Matrix of the whole greyscale image
    • Note That all these are applied to the Red Part of the image for better image quality

  • Converting
    • Embedding actually occurs here add the bit stream into the lsb of each pixel generated in the RowMatrix as a resultant of zigzag scanning
    • Now This Matrix is converted into a 2-D Matrix using the izigzag() function for each 8*8 blocks....
    • Now Perform Inverse Quantization using the same Quantization Table as above
    • Now Perform Inverse 2-D DCT to the Matrix using the function written it's syntax is as folllows InverseCosineTransform() and Now The Matrix is again obtained in the spatial domain
    • The Matrix Obtained here is nothing but the Steganographed Image with primary image hidden in it
    • Save the Image using the using the function imwrite() in-built function

  • Decoding
    • Now for the obtained Steganographed Image perform DCT and Quantization on Red part again and extract all the Least Significant Bits of each Individual pixel after applying the zigzag function again
    • Decode the Matrix using the Huffman Decoding using the huffmandeco() function along with it's Dictionary Generated in the Encoding Image part
    • Convert the Matrix into a displayable image using the mat2gray() function or just divide every element of array with 255 because max value of a coordinate is 255 in a a image
    • Save the Obtained image once again using the imwrite() inbuilt function

  • Displaying
    • This is just to diplay all the Images in the table format using figure() and nexttile()

  • Results
    The Steganographed Image obtained by two different methods (i.e by using Converting.m and Converting_n.m ) The Input Image and the Recieved Decoded Image
    Converting.m Converting_n.m
    Screenshot 2024-06-12 012827 Screenshot 2024-06-12 012704
    Message Image Decoded Image
    Finalised_Encoding_Image SecretImage

About

This is a project on implementing Image steganography in Matlab using Block - DCT and Huffman Encoding

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages