Blind Watermark in Python
Project description
blind-watermark
Blind watermark based on wavelet transform.
- Documentation: https://BlindWatermark.github.io/blind_watermark/#/en/
- 文档: https://BlindWatermark.github.io/blind_watermark/#/zh/
- 中文 readme README_cn.md
- Source code: https://github.com/guofei9987/blind_watermark
install
pip install blind-watermark
For the current developer version:
git clone git@github.com:guofei9987/blind_watermark.git
cd blind_watermark
pip install .
How to use
How to embed watermark:
from blind_watermark import WaterMark
bwm1 = WaterMark(password_wm=1, password_img=1)
# read original image
bwm1.read_img('pic/ori_img.jpg')
# read watermark
bwm1.read_wm('pic/watermark.png')
# embed
bwm1.embed('output/embedded.png')
How to extract watermark
bwm1 = WaterMark(password_wm=1, password_img=1)
# notice that wm_shape is necessary
bwm1.extract(filename='output/embedded.png', wm_shape=(128, 128), out_wm_name='output/extracted.png', )
demos:
| origin image | watermark |
|---|---|
| image embedded with watermark | extracted watermark |
|---|---|
Attack on the embedded image
| attack method | image after attack | extracted watermark |
|---|---|---|
| Rotate 45 Degrees 旋转攻击.py |
||
| Many Coverage 多遮挡攻击.py |
||
| 50% Horizontal Crop 横向裁剪攻击.py |
||
| 50% Vertical Crop 纵向裁剪攻击.py |
||
| Resize(1200X1920->600X800) 缩放攻击.py |
||
| Pepper Noise 椒盐击.py |
||
| Brightness 10% Up 亮度调高攻击.py |
||
| Brightness 10% Down 亮度调暗攻击.py |
embed string
Embed:
from blind_watermark import WaterMark
bwm1 = WaterMark(password_img=1, password_wm=1)
bwm1.read_img('pic/ori_img.jpg')
wm = '@guofei9987 开源万岁!'
bwm1.read_wm(wm, mode='str')
bwm1.embed('output/embedded.png')
len_wm = len(bwm1.wm_bit)
print('Put down the length of wm_bit {len_wm}'.format(len_wm=len_wm))
Extract:
bwm1 = WaterMark(password_img=1, password_wm=1)
wm_extract = bwm1.extract('output/embedded.png', wm_shape=len_wm, mode='str')
print(wm_extract)
Output:
@guofei9987 开源万岁!
embed array of bits
As demo, we embed 6 bytes data:
wm = [True, False, True, True, True, False]
Embed:
from blind_watermark import WaterMark
bwm1 = WaterMark(password_img=1, password_wm=1)
bwm1.read_ori_img('pic/ori_img.jpg')
bwm1.read_wm([True, False, True, True, True, False], mode='bit')
bwm1.embed('output/embedded.png')
Extract:
bwm1 = WaterMark(password_img=1, password_wm=1, wm_shape=6)
wm_extract = bwm1.extract('output/打上水印的图.png', mode='bit')
print(wm_extract)
Notice that wm_shape (shape of watermark) is necessary
The output wm_extract is an array of float. set a threshold such as 0.5.
Concurrency
WaterMark(..., processes=None)
processes: number of processes, can be integer. DefaultNone, meaning use all processes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file blind_watermark-0.3.1.tar.gz.
File metadata
- Download URL: blind_watermark-0.3.1.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fbbd3592e6654c9ac93ff59c50bc99ef66996f690d8f6fbbd0ac7ca764aa0fa
|
|
| MD5 |
063271f816d13a73e4cb47f8a53989ac
|
|
| BLAKE2b-256 |
9eafbcd538e6471f986dff3a9054e74a5a007251ea9efa07c045b1de6fe0e3fe
|
File details
Details for the file blind_watermark-0.3.1-py3-none-any.whl.
File metadata
- Download URL: blind_watermark-0.3.1-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba1938553d40b3fe3e6a2b60556e4328b11cd37b120e9dbc1d66cd972d22b57c
|
|
| MD5 |
5b557064aa5fa73fa0cf498238085254
|
|
| BLAKE2b-256 |
48bd2d2d3b8630702b49a5ba387d91964964417751a8053ac1e845243eb9978e
|