-
-
Notifications
You must be signed in to change notification settings - Fork 708
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fecc672
commit f0b90d4
Showing
10 changed files
with
197 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# blind-watermark | ||
|
||
基于小波变换的数字盲水印 | ||
|
||
|
||
[![PyPI](https://img.shields.io/pypi/v/blind_watermark)](https://pypi.org/project/blind_watermark/) | ||
[![Build Status](https://travis-ci.com/guofei9987/blind_watermark.svg?branch=master)](https://travis-ci.com/guofei9987/blind_watermark) | ||
[![codecov](https://codecov.io/gh/guofei9987/blind_watermark/branch/master/graph/badge.svg)](https://codecov.io/gh/guofei9987/blind_watermark) | ||
[![License](https://img.shields.io/pypi/l/blind_watermark.svg)](https://github.com/guofei9987/blind_watermark/blob/master/LICENSE) | ||
![Python](https://img.shields.io/badge/python->=3.5-green.svg) | ||
![Platform](https://img.shields.io/badge/platform-windows%20|%20linux%20|%20macos-green.svg) | ||
[![Downloads](https://pepy.tech/badge/blind-watermark)](https://pepy.tech/project/blind-watermark) | ||
[![Join the chat at https://gitter.im/guofei9987/blind_watermark](https://badges.gitter.im/guofei9987/blind_watermark.svg)](https://gitter.im/guofei9987/blind_watermark?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
|
||
|
||
- **Documentation:** [https://BlindWatermark.github.io/blind_watermark/#/en/](https://BlindWatermark.github.io/blind_watermark/#/en/) | ||
- **文档:** [https://BlindWatermark.github.io/blind_watermark/#/zh/](https://BlindWatermark.github.io/blind_watermark/#/zh/) | ||
- **English readme** [readme.md](readme.md) | ||
- **Source code:** [https://github.com/guofei9987/blind_watermark](https://github.com/guofei9987/blind_watermark) | ||
|
||
|
||
# 安装 | ||
```bash | ||
pip install blind-watermark | ||
``` | ||
|
||
或者安装最新开发版本 | ||
```bach | ||
git clone git@github.com:guofei9987/blind_watermark.git | ||
cd blind_watermark | ||
pip install . | ||
``` | ||
|
||
## 如何使用 | ||
|
||
嵌入水印 | ||
```python | ||
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/打上水印的图.png') | ||
``` | ||
|
||
|
||
提取水印 | ||
```python | ||
bwm1 = WaterMark(password_wm=1, password_img=1) | ||
# 注意需要设定水印的长宽wm_shape | ||
bwm1.extract(filename='output/打上水印的图.png', wm_shape=(128, 128), out_wm_name='output/解出的水印.png', ) | ||
``` | ||
|
||
## 效果展示 | ||
|
||
|原图|水印| | ||
|--|--| | ||
|![原图](docs/原图.jpg)|![水印](docs/水印.png)| | ||
|
||
|打上水印的图|提取的水印| | ||
|--|--| | ||
|![打上水印的图](docs/打上水印的图.jpg)|![提取的水印](docs/解出的水印.png)| | ||
|
||
|
||
|
||
### 各种攻击后的效果 | ||
|
||
|
||
|攻击方式|攻击后的图片|提取的水印| | ||
|--|--|--| | ||
|旋转攻击45度<br>[旋转攻击.py](examples/旋转攻击.py)|![旋转攻击](docs/旋转攻击.jpg)|![](docs/旋转攻击_提取水印.png)| | ||
|多遮挡<br>[多遮挡攻击.py](examples/多遮挡攻击.py)| ![多遮挡攻击](docs/多遮挡攻击.jpg) |![多遮挡_提取水印](docs/多遮挡攻击_提取水印.png)| | ||
|横向裁剪50%<br>[横向裁剪攻击.py](examples/横向裁剪攻击.py)|![横向裁剪攻击](docs/横向裁剪攻击.jpg)|![](docs/横向裁剪攻击_提取水印.png)| | ||
|纵向裁剪50%<br>[纵向裁剪攻击.py](examples/纵向裁剪攻击.py)|![纵向裁剪攻击](docs/纵向裁剪攻击.jpg)|![纵向裁剪](docs/纵向裁剪攻击_提取水印.png)| | ||
|缩放攻击(1200X1920->600X800)<br>[缩放攻击.py](examples/缩放攻击.py)|![缩放攻击](docs/缩放攻击.jpg)|![](docs/缩放攻击_提取水印.png)| | ||
|椒盐攻击<br>[椒盐击.py](examples/椒盐攻击.py)|![椒盐攻击](docs/椒盐攻击.jpg)|![](docs/椒盐攻击_提取水印.png)| | ||
|亮度提高10%<br>[亮度调高攻击.py](examples/亮度调高攻击.py)|![亮度调高攻击](docs/亮度调高攻击.jpg)|![](docs/亮度调高攻击_提取水印.png)| | ||
|亮度调低10%<br>[亮度调暗攻击.py](examples/亮度调低攻击.py)|![亮度调低攻击](docs/亮度调低攻击.jpg)|![](docs/亮度调低攻击_提取水印.png)| | ||
|
||
|
||
|
||
|
||
### 隐水印还可以是二进制数据 | ||
|
||
作为 demo, 如果要嵌入是如下长度为6的二进制数据 | ||
```python | ||
wm = [True, False, True, True, True, False] | ||
``` | ||
|
||
嵌入水印 | ||
|
||
```python | ||
# 除了嵌入图片,也可以嵌入比特类数据 | ||
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/打上水印的图.png') | ||
``` | ||
|
||
解水印:(注意设定水印形状 `wm_shape`) | ||
```python | ||
bwm1 = WaterMark(password_img=1, password_wm=1, wm_shape=6) | ||
wm_extract = bwm1.extract('output/打上水印的图.png', mode='bit') | ||
print(wm_extract) | ||
``` | ||
|
||
解出的水印是一个0~1之间的实数,方便用户自行卡阈值。如果水印信息量远小于图片可容纳量,偏差极小。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .blind_watermark import WaterMark | ||
from .att import * | ||
|
||
__version__ = '0.0.1' | ||
__version__ = '0.0.2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.