This side project is to implement basic steganography with images. Encode the first 7-K
bits of the watermark into the last K
bits of the target image. You can put these two files in folder ./src
and set the configurations in ./config
. For details, please refer to the comments in the codes.
- Import watermark (A) and target (B) as numpy arrays.
- Encode the first
7-K
bits of A into the lastK
bits of B. - Decode the last
K
bits of B and left-shift7-K
bits to reconstruct the A.
Target image | Watermark image |
Encode to last 1 bit | Encode to last 2 bits | Encode to last 3 bits |
Decode from last 1 bit | Decode from last 2 bits | Decode from last 3 bits |
It's easy to encode A to B. As more bits are encoded, the more it affects the quality of the target image. On the contrary, the fewer bits the watermarks are encoded, the lower the quality of it can be restored.
Python 3.9.6
MacOS 12.6
-
Install the dependencies
pip install -r requirements.txt
-
Update the
config.py
if needed -
Run the
main.py
python main.py