Fourier Transform In Image Steganography

Roshan
4 min readJun 22, 2024

--

Introduction

What is Steganography?

Steganography is the art of hiding information within other data in such a way that it is not easily detectable, steganography aims to conceal the existence of the message itself. It can be either photo, video or audio.

Overview

Here I demonstrate an image steganography technique that embeds a hidden image within a cover image using the “Lab” colour space (a type like RGB colour space)and the Discrete Fourier Transform (DFT). This method covers the properties of the Lab color space to minimize perceptual changes and uses the DFT to embed information in the high-frequency components, making the hidden image less detectable.

Lab colour space
  • L (Luminance): This component represents the lightness of the color, ranging from 0 (black) to 100 (white). It does not convey any color information, only the intensity of light.
  • a (Green-Red Chrominance) This component represents the color information along the green-to-red axis. Negative values indicate green, while positive values indicate red.
  • b (Blue-Yellow Chrominance): This component represents the color information along the blue-to-yellow axis. Negative values indicate blue, while positive values indicate yellow.

Why especially Lab ?

The advantage of using the Lab color space in image processing is that it separates the luminance information (L) from the colour information (a and b). This separation can be very useful for our application and tasks that involve manipulating colour without affecting brightness or vice versa. In the context of this, the Lab colour space allows us to embed a hidden image into the chrominance components (a and b) while leaving the luminance component (L) largely unaffected, which helps in maintaining the visual appearance of the cover image.

Methodology

  • Load Images
  • Convert Cover Image to Lab Color Space
  • Compute the Discrete Fourier Transform
  • Prepare the Hidden Image
  • Create and Apply High-Frequency Mask
  • Modify the Chrominance Channel and Reconstruct the Image
  • Combine and Convert Back to image (combine the colour spaces)
  • Extract the Hidden Image

Code and Explanation — with concepts

Extracting Lab from image

L = lab_cover(:,:,1); % Luminance channel
a = lab_cover(:,:,2); % Chrominance a channel
b = lab_cover(:,:,3); % Chrominance b channel

Computing Discrete Fourier transform

F_L_cover = fft2(L); 
F_a = fft2(a);
F_b = fft2(b);

Magnitude and Phase Separation

By separating the magnitude and phase, you can independently manipulate these components. For example, you can modify the magnitude to enhance or suppress certain frequencies while keeping the phase unchanged, which allows for various filtering techniques.

This part is done as the hidden image is embedded into the high-frequency components of the chrominance channels. This is achieved by manipulating the magnitude spectrum. The phase is kept unchanged to preserve the overall structure of the image.

mag_L_cover = abs(F_L_cover); 
phase_L_cover = angle(F_L_cover);
mag_a = abs(F_a);
phase_a = angle(F_a);
mag_b = abs(F_b);
phase_b = angle(F_b);

explanation for above

Magnitude Spectrum:

  • The magnitude of the Fourier transform represents how much of each frequency component is present in the image.
  • It tells you the strength or intensity of each frequency component.

Phase Spectrum:

  • The phase of the Fourier transform represents the positional information of the frequency components.
  • It tells you where each frequency component is located in the image.
  • The phase contains crucial information about the structure and spatial arrangement of the image. For example, it determines the position of edges and other structural features.

High-Frequency Mask Creation

A Gaussian filter is a type of linear filter used in image processing to blur images and remove noise. It is based on the Gaussian function, which is a smooth, bell-shaped curve defined by the standard deviation (σ). This filter is widely used due to its properties of preserving edges while reducing noise.

high_freq_mask = fspecial('gaussian', size(mag_a), 10);
high_freq_mask = 1 - high_freq_mask / max(high_freq_mask(:));
  • fspecial('gaussian', size(mag_a), 10): This creates a Gaussian filter with the same size as mag_a. The standard deviation of the Gaussian filter is set to 10.
  • The Gaussian filter typically has high values at the center and lower values towards the edges.
  • high_freq_mask = 1 - high_freq_mask / max(high_freq_mask(:)): This inverts the Gaussian filter. The result is a mask that has low values at the center (low frequencies) and high values at the edge

how it is inverted

Center high values (1) <--- Values decrease towards edges (0)

Center 1 <--- Values between 1 and 0 ---> Edge 0

Center 0 <--- Values between 0 and 1 ---> Edge 1

The high-frequency mask created by this inversion is used to emphasize high-frequency components of the cover image. When you multiply this mask with the normalized hidden image, it ensures that the hidden image affects mainly the high-frequency components of the cover image. This is crucial for steganography because The human visual system is less sensitive to high-frequency changes. Embedding information in high-frequency components makes it less likely to be noticed.

Further embeddingpart will be in PART 2 — CLICK here

Let me know if you need further assistance!

Linkedin: https://www.linkedin.com/in/roshantwinn09/

Github:https://github.com/Twinn-github09

--

--