MCPcopy
hub / github.com/guofei9987/blind_watermark

github.com/guofei9987/blind_watermark @0.2.1 sqlite

repository ↗ · DeepWiki ↗ · release 0.2.1 ↗
46 symbols 191 edges 22 files 1 documented · 2%
README

blind-watermark

Blind watermark based on wavelet transform.

PyPI Build Status codecov License Python Platform stars fork Downloads Discussions

demonstration

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

Use in bash

cd examples
# embed watermark into image:
blind_watermark --embed -p 1x1 pic/ori_img.jpg pic/watermark.png output/embedded.png
# extract watermark from image:
blind_watermark --extract -p 1x1 --wm_shape 128x128 output/embedded.png output/wm_extract.png

Use in Python

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

See it here

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

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, meaning use all processes.

Related Project

text_blind_watermark: https://github.com/guofei9987/text_blind_watermark
Embed string into string.

Core symbols most depended-on inside this repo

extract
called by 30
blind_watermark/bwm_core.py
read_img
called by 6
blind_watermark/bwm_core.py
read_wm
called by 5
blind_watermark/bwm_core.py
embed
called by 5
blind_watermark/bwm_core.py
read_file
called by 2
setup.py
read_img
called by 2
blind_watermark/blind_watermark.py
read_wm
called by 2
blind_watermark/blind_watermark.py
embed
called by 2
blind_watermark/blind_watermark.py

Shape

Function 21
Method 21
Class 4

Languages

Python100%

Modules by API surface

blind_watermark/bwm_core.py15 symbols
blind_watermark/att.py10 symbols
blind_watermark/blind_watermark.py8 symbols
blind_watermark/pool.py5 symbols
examples/命令行.py3 symbols
setup.py2 symbols
docs/make_doc.py2 symbols
blind_watermark/cli_tools.py1 symbols

Dependencies from manifests, versioned

numpy1.17.0 · 1×

For agents

$ claude mcp add blind_watermark \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact