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/
- 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)
# 读取原图
bwm1.read_img('pic/ori_img.jpg')
# 读取水印
bwm1.read_wm('pic/watermark.png')
# 打上盲水印
bwm1.embed('output/embedded.png')
How to extract watermark
bwm1 = WaterMark(password_wm=1, password_img=1)
# 注意需要设定水印的长宽wm_shape
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 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.
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
blind_watermark-0.0.2.tar.gz
(6.8 kB
view hashes)
Built Distribution
Close
Hashes for blind_watermark-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afa6cc00e2c1fac2f43a85b6263d7458280243160004f3b12e3966e1be2db57b |
|
MD5 | 7fb27d3a796123c7a2adce4db3354c73 |
|
BLAKE2b-256 | 351b5521762fb0af6c2af8a8d5ee4dcaeb4af3ef2b1e2962bad63369cff55427 |