Skip to content

ShadyNikooei/Matlab-audio-watermarking

Repository files navigation

MP3 Audio Watermarking in Images (Byte-Level and Bit-Level Methods)

This project demonstrates how to embed an MP3 audio file invisibly into a grayscale image and later recover it. Two watermarking methods are implemented:

  1. Byte-level embedding: Each pixel stores one full byte of the audio data.
  2. Bit-level embedding (LSB): Each audio byte is spread across 8 least-significant bits (LSBs) of consecutive pixels.

Features

  • Encode and decode raw MP3 audio into an image without noticeable distortion.
  • Support for Byte-level and Bit-level (LSB) watermarking.
  • Metadata embedding for reliable recovery (start position, step, data length).
  • Robust handling of grayscale images (color images are converted to grayscale automatically).
  • Lossless watermark storage using BMP format (avoids JPEG compression artifacts).

Functions Overview

1. readMp3(dir_voise)

  • Input: Path to a directory containing an .mp3 file.
  • Output: A vector of raw bytes extracted from the MP3 file.

2. WM_Byte_code_coding(rMp3, dir_image, dir_img_s)

  • Embeds audio bytes directly into pixels of a grayscale image.
  • Metadata (start row, start column, step, length) is stored in the first row.
  • Output: Watermarked image waterMarker_byte.bmp.

3. WM_Byte_code_decoding(dir_img_s)

  • Extracts raw bytes from a watermarked image created by byte-level encoding.
  • Output: Reconstructed audio file recovered_byte.mp3.

4. WM_Bit_code_coding(vector_voise, dir_image, dir_img_s)

  • Embeds audio data at the bit level by storing each bit in the LSB of a pixel.
  • Uses 32-bit metadata fields for robustness.
  • Output: Watermarked image waterMarker.bmp.

5. WM_Bit_code_decoding(dir_img_s)

  • Extracts embedded bits from an LSB watermarked image.
  • Output: Reconstructed audio file recovered.mp3.

Requirements

  • MATLAB R2020a or newer
  • Input image in PNG format
  • Audio file in MP3 format
  • Output watermarked images are saved in BMP format

Important Notes

  • Capacity Check:
    • Byte-level: Each pixel stores 1 byte. Capacity ≈ available pixels.
    • Bit-level: Each byte requires 8 pixels. Capacity ≈ available pixels ÷ 8.
  • Metadata Consistency: Parameters start_r, start_c, step, and num_byte_voise must be consistent between encoding and decoding.
  • File Formats: Always use BMP as the watermarked output format to avoid compression loss.
  • Limitations: The watermark is not robust against image transformations (compression, resizing, filtering). This project demonstrates basic steganography, not robust watermarking.

Possible Extensions

  • Activate and improve the capacity check for the byte-level method.
  • Add key-based pseudo-random embedding for higher security.
  • Implement progress reporting and error logging.
  • Support for larger files via compression or segmentation.

License

This project is licensed under the MIT License. See LICENSE for details.


Attribution

Project author: Shady Nikooei - Digital Image Processing

About

This MATLAB project enables embedding and extracting MP3 audio in grayscale images using invisible byte-level and bit-level watermarking. Metadata is included for accurate recovery. It demonstrates digital watermarking, steganography, and image processing techniques for educational and practical purposes

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages