• Stars
    star
    5,391
  • Rank 7,379 (Top 0.2 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 5 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Blind&Invisible Watermark ,图片盲水印,提取水印无须原图!

blind-watermark

Blind watermark based on DWT-DCT-SVD.

PyPI Build Status codecov License Python Platform stars fork Downloads Discussions

install

pip install blind-watermark

For the current developer version:

git clone [email protected]:guofei9987/blind_watermark.git
cd blind_watermark
pip install .

How to use

Use in 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

origin_image + '@guofei9987 开源万岁!' = 打上水印的图

See the codes

Embed watermark:

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:

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:

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:

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

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. Default None, which means using all processes.

Related Project

text_blind_watermark: https://github.com/guofei9987/text_blind_watermark
Embed message into text.

More Repositories

1

scikit-opt

Genetic Algorithm, Particle Swarm Optimization, Simulated Annealing, Ant Colony Optimization Algorithm,Immune Algorithm, Artificial Fish Swarm Algorithm, Differential Evolution and TSP(Traveling salesman)
Python
5,015
star
2

text_blind_watermark

文本盲水印:把信息隐匿到文本中,put invisible blind watermark into a text.
Python
1,242
star
3

HideInfo

一些小而美的信息隐藏技术:幻影坦克、藏物于音等
Python
329
star
4

guofei9987.github.io

个人博客,欢迎fork
JavaScript
99
star
5

pyLSHash

Locality Sensitive Hashing, fuzzy-hash, min-hash, simhash, aHash, pHash, dHash。基于 Hash值的图片相似度、文本相似度
Python
48
star
6

fourier_artist

用几个圆画任意图(傅里叶变换)
Python
40
star
7

github_star_counter

Count a GitHub user's total stars and forks
Python
28
star
8

vulgar_language_generator

俗不可耐语言生成器(中文)-俗不可耐的古风诗歌生成器,震惊体生成器
Python
24
star
9

star_counter

Count a GitHub user's stars and forks(在线统计账号star数量)
JavaScript
20
star
10

get_data

从知乎获取点赞数、收藏数、关注数,并自动推送,每小时运行
Python
18
star
11

pygraphs

A graph database based on Python,一个轻量级图数据库
Python
15
star
12

AHP

层次分析法
Python
14
star
13

hibird_python

Python调用C的例子(混合编程)
Python
11
star
14

guofei9987

Python
10
star
15

chrplotlib

plot graphs using chars
Python
10
star
16

python-maze

Generate a maze using Python
Python
9
star
17

text-blind-watermark

Text Blind Watermark in Rust
Rust
8
star
18

file2tree

file2tree
Python
7
star
19

c-algorithm

C语言实现动态数组、链表、Hash表、KMP等算法/数据结构
C
7
star
20

rs-graphs

Graph algorithms in Rust。用 Rust 实现的图算法
Rust
6
star
21

rust-algo

Rust 实现链表等数据结构
Rust
6
star
22

fuzzy-hash

fuzzy hash in python (from ssdeep)
C
5
star
23

plot2svg

A simple plot tool to generate small SVG files
Python
5
star
24

donate

打赏小控件
CSS
5
star
25

rs_lib

Rust调用C的例子(混合编程)
Rust
4
star
26

MyKnowledge

笔记记录,已迁移到 https://github.com/guofei9987/guofei9987.github.io
Python
4
star
27

pictures_for_blog

Pictures in my blog
JavaScript
2
star
28

plans

已废弃
Python
2
star
29

CrypTool

密码学相关算法
Python
1
star
30

slides

JavaScript
1
star
31

pybert

一行代码实现bert,中文文本分类。基于 torch
Python
1
star
32

logging4

a tiny logging tool
Python
1
star
33

tmp

测试
Python
1
star
34

spank

Python
1
star
35

python_with_rust

Python 调用 Rust 项目
Rust
1
star