Blind Watermark
A Rust library and CLI tool for blind image watermarking using DWT (Discrete Wavelet Transform), DCT (Discrete Cosine Transform), and SVD (Singular Value Decomposition). The algorithm is originally implemented in python by Guo Fei at this repository. This is the rust rewritten and modified version.
Features
- Blind Watermarking: Extract the watermark without needing the original image.
- Robust Algorithm: Combines DWT, DCT, and SVD for embedding watermarks in the frequency domain.
- High Performance: Developed in Rust, leveraging the
faercrate for efficient matrix computations andrayonfor multi-threading support. - Flexible: Supports embedding arbitrary binary data (e.g.
Vec<u8>). String watermarking is natively supported. - Random Strategy: Supports randomized block selection for embedding watermarks, enhancing security.
- CLI Tool: A command-line interface for easy embedding and extracting watermarks.
Original Image

Processed Image

Installation
Add this to your Cargo.toml:
[]
= "0.1"
As for the CLI tool, pre-compiled binaries are available at GitHub Releases. If you have Rust toolchain installed and want to install from source, use:
Usage
CLI
You can get help by running:
Library
Embedding a Watermark
use *;
OR
use *;
use ;
Extracting a Watermark
To extract the watermark, you only need the watermarked image and the length of the watermark.
use *;
OR
use *;
use *;
use ImageReader;
Algorithm Details
The library implements a hybrid DWT-DCT-SVD watermarking scheme:
- Preprocessing: The image is converted to YCbCr color space.
- DWT: A Discrete Wavelet Transform is applied to decompose the image into frequency subbands (LL, HL, LH, HH).
- Block Selection: The LL (Low-Low) subband is divided into 4x4 blocks.
- DCT & SVD: Each block undergoes Discrete Cosine Transform (DCT) followed by Singular Value Decomposition (SVD).
- Embedding: The watermark bits are embedded by quantizing the singular values of the blocks.
- Reconstruction: The inverse transformations (ISVD, IDCT, IDWT) are applied to generate the watermarked image.
This approach ensures that the watermark is embedded in the significant features of the image, providing robustness while maintaining visual quality.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.