Coder Social home page Coder Social logo

fire-keeper / blindwatermark Goto Github PK

View Code? Open in Web Editor NEW
1.2K 1.2K 176.0 6.15 MB

使用盲水印保护创作者的知识产权using invisible watermark to protect creator's intellectual property

License: GNU General Public License v3.0

Python 100.00%

blindwatermark's People

Contributors

dependabot[bot] avatar fire-keeper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

blindwatermark's Issues

Request: English Localization

I would like to request a written tutorial on how to use the software in English. And also an English localization of the software could be very nice.

抗攻击性太弱

抗攻击性太弱,截图后水印几乎无法提取,除非百分百截取;画笔涂抹后也几乎无法提取水印,不知后续还有没有优化版本
6
0

个人接触过密码学和认证相关,提出一点不成熟的建议

密钥和签名个人认为可以使用RSA这一非对称加密形式,只要私钥保存在太太手里就能有效防止反向破解,可以使用openssl实现

甚至可以使用Let's Encrypt或自签名GPG证书生成密钥和签名,保证密钥的公信力

算法方面也可以尝试对图片进行FFT之类的操作做水印

图像隐写

是跟图像隐写相关的吗,之前看过一下图像隐写,加密这部分一直不行

增加 jpg 输出质量的参数 & 一些问题

感谢作者,感觉还挺好用的。
代码还没细看,先跑了点测试。然后有些问题请教一下。

加了个jpg压缩的参数

cv2.imwrite(output_filename, img_data, [int(cv2.IMWRITE_JPEG_QUALITY), 90])

png也有对应的IMWRITE_PNG_COMPRESSION,但那个有损得比较厉害,不太用到。
jpg的还是挺常用的。

做了一些测试

同水印大小不同源图大小

  • plot_src256_wm32_block4_jpg60-100_mod16-32
    plot_src256_wm32_block4_jpg60-100_mod16-32
  • plot_src512_wm32_block4_jpg60-100_mod16-32
    plot_src512_wm32_block4_jpg60-100_mod16-32
  • plot_src1024_wm32_block4_jpg60-100_mod16-32
    plot_src1024_wm32_block4_jpg60-100_mod16-32

显然大图包含信息更多,还原更精准。(横坐标为jpg品质,纵坐标为mod)

水印刚好是图源1/8

  • plot_src256_wm32_block4_jpg60-100_mod16-32
    plot_src256_wm32_block4_jpg60-100_mod16-32
  • plot_src512_wm64_block4_jpg60-100_mod16-32
    plot_src512_wm64_block4_jpg60-100_mod16-32
  • plot_src1024_wm128_block4_jpg60-100_mod16-32
    plot_src1024_wm128_block4_jpg60-100_mod16-32

大图有好一些,但优势不明显。(个人理解是承载信息的范围和信息本身在同比增加,压缩之后干扰程度也就差不多)
接合上一条,也许水印可以有一个上限,比如128的bitmap,足够承载较多的内容。

block的影响

同样源图用到最大水印 block4->1

  • plot_src256_wm32_block4_jpg60-100_mod16-32
    plot_src256_wm32_block4_jpg60-100_mod16-32
  • plot_src256_wm128_block1_jpg60-100_mod16-32
    plot_src256_wm128_block1_jpg60-100_mod16-32

这里都是256的原图,分别用了32的水印和128的水印,明显128的品质更好,但block少了。

同样源图/水印/仅改变block

  • plot_src512_wm32_block2_jpg60-100_mod16-32
    plot_src512_wm32_block2_jpg60-100_mod16-32
  • plot_src512_wm32_block3_jpg60-100_mod16-32
    plot_src512_wm32_block3_jpg60-100_mod16-32
  • plot_src512_wm32_block4_jpg60-100_mod16-32
    plot_src512_wm32_block4_jpg60-100_mod16-32
  • plot_src512_wm32_block8_jpg60-100_mod16-32
    plot_src512_wm32_block8_jpg60-100_mod16-32

我的理解是block越多,单个block就越小,能承载的信息越少,所以解码质量越低。
这里我源码还没细看,请问block在这里的作用是什么?从原图反解码的效果来看是越少品质越好,那block增加是能实现什么效果呢?防遮挡,多处采样比较吗?

其他一些问题

  • 从多次保存等情况下看,jpg还是按60的标准来处理比较保险,那样的话貌似mod就只能取24-32这个范围。
  • 请问block具体作用是什么?有没有所谓的上限,比如4就足够应付大部分场景了?

考虑自动根据源图生成参数

  • 另外逆向出来水印的质量,除了除数,还是和图片/水印大小,block分区,压缩品质,源图大小及保护价值(源图太小就牺牲block)等各种因素相关。
  • 我现在考虑能不能自动根据源图大小(锁定源图和jpg60这两个参数),自动判断所需的block/水印尺寸/除数,这三个参数,获得一个画质和保护的平衡。
  • 解码的时候考虑方式一是通过上述的自动参数来做,二是固定水印大小(比如128/64/32/16)试个4次,变相自动。

读完源码自答一下

block有一个比较隐蔽的问题是配合dwt,要凑到8px,因为jpg是按8px来压缩的,也就是block*(2^dwt_deep)刚好。
block过小,运算量几何级数增加,效率过慢。而且block过细,会导致画面有明显噪点感。
block过大,解高压缩的jpg水印会出问题。
jpg60时,block数量的宽高,达到水印2倍后解水印质量不错。比如画布1024,dwt1次,有效画布512,block4,可记载宽度128,如果用来记载32的水印,就达到了4:1,解水印效果就很好。

文献出处?

不知这个方法是否有文献出处?没有的话完全可以发一篇文章了!并且如果是原创的话建议给这个方法取个名字,加个版本号,甚至申请个专利什么的

我多年前有实现这个功能的想法,但是没有相关的知识储备,被您做出来了真是太棒了!以后有机会我会常识把它移植到C++/C#进行高效处理!

图片还原问题

为何裁剪后必须还原到原图大小才能提取水印呢,填补后图片的像素值已经变了呀

这个算法对RGB偏移的抵抗性很差

RBG其中某一两个通道的值总体增加一点,再加上25-50%的jpg压缩,在肉眼较难分辨的情况下,可以对水印造成极大破坏。
如果想要提高抵抗性,就不能发未压缩过的原图,得先压成AV画质打上隐水印再发出去

水印经过微信传输信息必丢失

平台:Iphone11 Pro Max

原图:RGB都是220的纯背景图
image

水印图: 用PS生成四个字符的水印图,水印图是二值化的
image

合成图: 添加到RGB的背景图生成水印图。
image

过程:把水印图以图片的形式放到app里显示,然后苹果系统方式截图,截取出来的图片只要经过微信传输一定会识别不出来,尤其是1080p以上的分辨率的机型

问题:是否是水印对JPG攻击的抵抗性特别弱?
而且我发现有时把mod1调到了对水印的鲁棒性并没有多大的改善,并非越大越好,跟描述不太一致。

[关于密钥的猜想] 一次性加密水印的解决思路

众所周知,我们现在所了解到的的水印只能生效一次,是因为其密钥是对称的,只要有一个key即可加解密;正如大多数对称加密算法(如AES)的特性。
那么能否结合非对称加密的特性(比如ECC,RSA)等方式加密,对于每一个创作者生成一个私钥,然后发布一个给与大家验证的公钥,由于私钥加密的东西只有公钥可以解开,公钥加密的东西只有私钥能解开,就解决了上述的一次性加密问题。

具体原理我认为可以参考一下PGP;但请各位创作者务必保存好你的私钥。

[Bug] 在多个输入图片嵌入水印时闪退

1.导入图片 多文件 (测试文件数量4)
2.导入水印 单文件
3.嵌入时 会按导入图片数量 多次弹出 【参数错误请参考关于中的公式修改参数,使其满足公式】
并 在后台提示 【水印的大小超过图片的容量】
4.在关闭警告时 闪退

更改图片尺寸的时候无法提取

修改了图片尺寸的时候,就无法提取了。。
Traceback (most recent call last):
File "bwm.py", line 57, in
bwm.extract(args.ori_img,args.output)
File "/Users/qianhuang/workspace/git_repos/BlindWatermark/BlindWatermark/BlindWatermark.py", line 314, in extract
cv2.imwrite(out_wm_name,extract_wm.reshape(64,64))
ValueError: cannot reshape array of size 1024 into shape (64,64)

Scaling robustness

When an input image is scale towards a different dimension (even remaining aspect ratio) the software is unable to extract the watermark. But when the image is scaled back to its original dimension (even being blurry) the watermark can be recovered. Would there be a way to be scale invariant? For example by using features such as SIFT/SURF/ORB as landmarks for embedding?

bwm运行错误

GUI版闪退,使用图片:https://mysteriouspreserve.com/assets/images/sources/origin.jpg
水印:https://mysteriouspreserve.com/assets/images/sources/mark.png

python2.7: File "bwm.py", line 6
SyntaxError: Non-ASCII character '\xe5' in file bwm.py on line 6, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Python 3.7:ModuleNotFoundError: No module named BlindWatermark

已知:如果工作目录存在中文字符,则GUI版bwm检测参数是否符合公式时会崩溃。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.