Beispiel #1
0
            output_file_name='output/旋转攻击.png',
            angle=angle)
att.rot_att(input_filename='output/旋转攻击.png',
            output_file_name='output/旋转攻击_还原.png',
            angle=-angle)

# 提取水印
bwm1 = WaterMark(password_wm=1, password_img=1)
wm_extract = bwm1.extract('output/旋转攻击_还原.png', wm_shape=len_wm, mode='str')
print(f"旋转攻击angle={angle}后的提取结果:", wm_extract)
assert wm == wm_extract, '提取水印和原水印不一致'

# %%遮挡攻击
n = 60
att.shelter_att(input_filename='output/embedded.png',
                output_file_name='output/多遮挡攻击.png',
                ratio=0.1,
                n=n)

# 提取
bwm1 = WaterMark(password_wm=1, password_img=1)
wm_extract = bwm1.extract('output/多遮挡攻击.png', wm_shape=len_wm, mode='str')
print(f"遮挡攻击{n}次后的提取结果:", wm_extract)
assert wm == wm_extract, '提取水印和原水印不一致'

# %%缩放攻击
att.resize_att(input_filename='output/embedded.png',
               output_file_name='output/缩放攻击.png',
               out_shape=(400, 300))
att.resize_att(input_filename='output/缩放攻击.png',
               output_file_name='output/缩放攻击_还原.png',
               out_shape=ori_img_shape[::-1])
Beispiel #2
0
from blind_watermark import att
import numpy as np
import cv2

# %%
# 攻击
att.shelter_att('output/打上水印的图.png', 'output/多遮挡攻击.png', ratio=0.1, n=10)

# %%多遮挡攻击.png
from blind_watermark import WaterMark

bwm1 = WaterMark(password_wm=1, password_img=1)
bwm1.extract(filename='output/多遮挡攻击.png',
             wm_shape=(128, 128),
             out_wm_name='output/多遮挡攻击_提取水印.png')
Beispiel #3
0
assert np.all(wm == wm_extract), '提取水印和原水印不一致'

# %%旋转攻击
angle = 60
img_attacked = att.rot_att(input_img=embed_img, angle=angle)
img_recovered = att.rot_att(input_img=img_attacked, angle=-angle)

# 提取水印
bwm1 = WaterMark(password_wm=1, password_img=1)
wm_extract = bwm1.extract(embed_img=img_recovered, wm_shape=len_wm, mode='str')
print(f"旋转攻击angle={angle}后的提取结果:", wm_extract)
assert wm == wm_extract, '提取水印和原水印不一致'

# %%遮挡攻击
n = 60
img_attacked = att.shelter_att(input_img=embed_img, ratio=0.1, n=n)

# 提取
bwm1 = WaterMark(password_wm=1, password_img=1)
wm_extract = bwm1.extract(embed_img=img_attacked, wm_shape=len_wm, mode='str')
print(f"遮挡攻击{n}次后的提取结果:", wm_extract)
assert wm == wm_extract, '提取水印和原水印不一致'

# %%缩放攻击
img_attacked = att.resize_att(input_img=embed_img, out_shape=(400, 300))
img_recovered = att.resize_att(input_img=img_attacked,
                               out_shape=ori_img_shape[::-1])
# out_shape 是分辨率,需要颠倒一下

bwm1 = WaterMark(password_wm=1, password_img=1)
wm_extract = bwm1.extract(embed_img=img_recovered, wm_shape=len_wm, mode='str')
Beispiel #4
0
print(f"椒盐攻击ratio={ratio}后的提取结果:", wm_extract)
assert np.all(wm == wm_extract), '提取水印和原水印不一致'

# %%旋转攻击
att.rot_att('output/embedded.png', 'output/旋转攻击.png', angle=45)
att.rot_att('output/旋转攻击.png', 'output/旋转攻击_还原.png', angle=-45)

# 提取水印
bwm1 = WaterMark(password_wm=1, password_img=1)
wm_extract = bwm1.extract('output/旋转攻击_还原.png', wm_shape=len_wm, mode='bit')
print("旋转攻击后的提取结果:", wm_extract)
assert np.all(wm == wm_extract), '提取水印和原水印不一致'

# %%遮挡攻击
n = 60
att.shelter_att('output/embedded.png', 'output/多遮挡攻击.png', ratio=0.1, n=n)

# 提取
bwm1 = WaterMark(password_wm=1, password_img=1)
wm_extract = bwm1.extract('output/多遮挡攻击.png', wm_shape=len_wm, mode='bit')
print(f"遮挡攻击{n}后的提取结果:", wm_extract)
assert np.all(wm == wm_extract), '提取水印和原水印不一致'

# %%缩放攻击
att.resize_att('output/embedded.png', 'output/缩放攻击.png', out_shape=(800, 600))
att.resize_att('output/缩放攻击.png',
               'output/缩放攻击_还原.png',
               out_shape=ori_img_shape[::-1])
# out_shape 是分辨率,需要颠倒一下

bwm1 = WaterMark(password_wm=1, password_img=1)
from blind_watermark import att
import numpy as np
import cv2

# %%
# 攻击
att.shelter_att('output/打上水印的图.png', 'output/多遮挡攻击.png')

# %%多遮挡攻击.png
from blind_watermark import WaterMark

bwm1 = WaterMark(4399, 2333, 36, 20, wm_shape=(128, 128))
bwm1.extract('output/多遮挡攻击.png', 'output/多遮挡攻击_提取水印.png')