-
-
Notifications
You must be signed in to change notification settings - Fork 732
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
0 parents
commit 486b18a
Showing
56 changed files
with
3,119 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
language: python | ||
python: | ||
- "3.8" | ||
|
||
|
||
# command to install dependencies | ||
install: | ||
- pip install -r requirements.txt | ||
- pip install numpy==1.18.1 | ||
- pip install coverage codecov | ||
- python setup.py install | ||
|
||
# command to run tests | ||
script: | ||
- cd examples | ||
- coverage run -p example_no_writing.py | ||
- coverage run -p example_bit.py | ||
- coverage run -p example_str.py | ||
- coverage run -p example_img.py | ||
- cp .coverage.* .. | ||
- cd .. | ||
|
||
# Push the results back to codecov | ||
after_success: | ||
- coverage combine | ||
- codecov |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 郭飞 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,194 @@ | ||
<table border="0" width="10%"> | ||
<tr> | ||
<td><img src="https://img1.github.io/tmp/1.jpg" height="80" width="82"></td> | ||
<td><img src="https://img1.github.io/tmp/2.jpg" height="80" width="82"></td> | ||
<td><img src="https://img1.github.io/tmp/3.jpg" height="80" width="82"></td> | ||
</tr> | ||
<tr> | ||
<td><img src="https://img1.github.io/tmp/4.jpg" height="80" width="82"></td> | ||
<td><img src="https://img.shields.io/github/stars/guofei9987/blind_watermark.svg?style=social"></td> | ||
<td><img src="https://img1.github.io/tmp/6.jpg" height="82" width="82"></td> | ||
</tr> | ||
<tr> | ||
<td><img src="https://img1.github.io/tmp/7.jpg" height="82" width="82"></td> | ||
<td><img src="https://img1.github.io/tmp/8.jpg" height="82" width="82"></td> | ||
<td><img src="https://img1.github.io/tmp/9.jpg" height="82" width="82"></td> | ||
</tr> | ||
</table> | ||
|
||
|
||
|
||
# blind-watermark | ||
|
||
Blind watermark based on dct and svd. | ||
|
||
|
||
[](https://pypi.org/project/blind_watermark/) | ||
[](https://travis-ci.com/guofei9987/blind_watermark) | ||
[](https://codecov.io/gh/guofei9987/blind_watermark) | ||
[](https://github.com/guofei9987/blind_watermark/blob/master/LICENSE) | ||
 | ||
 | ||
[](https://github.com/guofei9987/blind_watermark/) | ||
[](https://github.com/guofei9987/blind_watermark/fork) | ||
[](https://pepy.tech/project/blind-watermark) | ||
[](https://github.com/guofei9987/blind_watermark/discussions) | ||
|
||
|
||
- **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/) | ||
- **中文 readme** [README_cn.md](README_cn.md) | ||
- **Source code:** [https://github.com/guofei9987/blind_watermark](https://github.com/guofei9987/blind_watermark) | ||
|
||
|
||
|
||
# install | ||
```bash | ||
pip install blind-watermark | ||
``` | ||
|
||
For the current developer version: | ||
```bach | ||
git clone [email protected]:guofei9987/blind_watermark.git | ||
cd blind_watermark | ||
pip install . | ||
``` | ||
|
||
# How to use | ||
|
||
|
||
## Use in bash | ||
|
||
|
||
```bash | ||
# embed watermark into image: | ||
blind_watermark --embed --pwd 1234 examples/pic/ori_img.jpeg "watermark text" examples/output/embedded.png | ||
# extract watermark from image: | ||
blind_watermark --extract --pwd 1234 --wm_shape 111 examples/output/embedded.png | ||
``` | ||
|
||
|
||
|
||
## Use in Python | ||
|
||
Original Image + Watermark = Watermarked Image | ||
|
||
 + '@guofei9987 开源万岁!' =  | ||
|
||
|
||
See the [codes](/examples/example_str.py) | ||
|
||
Embed watermark: | ||
```python | ||
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 watermark: | ||
```python | ||
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 开源万岁! | ||
### attacks on Watermarked Image | ||
|
||
|
||
|attack method|image after attack|extracted watermark| | ||
|--|--|--| | ||
|Rotate 45 Degrees||'@guofei9987 开源万岁!'| | ||
|Random crop||'@guofei9987 开源万岁!'| | ||
|Masks|  |'@guofei9987 开源万岁!'| | ||
|Vertical cut||'@guofei9987 开源万岁!'| | ||
|Horizontal cut||'@guofei9987 开源万岁!'| | ||
|Resize||'@guofei9987 开源万岁!'| | ||
|Pepper Noise||'@guofei9987 开源万岁!'| | ||
|Brightness 10% Down||'@guofei9987 开源万岁!'| | ||
|
||
|
||
|
||
|
||
|
||
|
||
### embed images | ||
|
||
embed watermark: | ||
```python | ||
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') | ||
``` | ||
|
||
|
||
Extract watermark: | ||
```python | ||
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', ) | ||
``` | ||
|
||
|
||
|attack method|image after attack|extracted watermark| | ||
|--|--|--| | ||
|Rotate 45 Degrees||| | ||
|Random crop||| | ||
|Mask|  || | ||
|
||
|
||
### embed array of bits | ||
|
||
See it [here](/examples/example_bit.py) | ||
|
||
|
||
As demo, we embed 6 bytes data: | ||
```python | ||
wm = [True, False, True, True, True, False] | ||
``` | ||
|
||
Embed: | ||
```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/embedded.png') | ||
``` | ||
|
||
Extract: | ||
```python | ||
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 | ||
|
||
```python | ||
WaterMark(..., processes=None) | ||
``` | ||
- `processes`: number of processes, can be integer. Default `None`, meaning use all processes. | ||
|
||
## Related Project | ||
|
||
text_blind_watermark: [https://github.com/guofei9987/text_blind_watermark](https://github.com/guofei9987/text_blind_watermark) | ||
Embed message into text. |
Oops, something went wrong.