Skip to content

Commit

Permalink
Add discrete cosine transform
Browse files Browse the repository at this point in the history
  • Loading branch information
ww23 committed Dec 21, 2018
1 parent 5f806c7 commit 922a734
Show file tree
Hide file tree
Showing 6 changed files with 324 additions and 197 deletions.
108 changes: 67 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,90 @@

# BlindWatermark
[![Travis (.org)](https://img.shields.io/travis/USER/REPO.svg)](https://travis-ci.org/ww23/BlindWatermark)
[![Build Status](https://travis-ci.org/ww23/BlindWatermark.svg?branch=master)](https://travis-ci.org/ww23/BlindWatermark)

Java 盲水印
在图片上加肉眼无法分辨的水印
在图片上加肉眼很难分辨的水印

* 原理
* Encode:
原图 --- 傅立叶变换 ---> 频域图 + 水印 --- 逆变换 ---> 带水印图
原图 --- 变换 ---> 变换域 + 水印 --- 逆变换 ---> 带水印图
* Decode(文字水印):
带水印图 --- 傅立叶变换 ---> 频域图
带水印图 --- 变换 ---> 变换域
* Decode(图片水印):
原图 --- 傅立叶变换 --> 原图频域图
带水印图 --- 傅立叶变换 ---> 频域图 - 原图频域图

* 文件
├── gakki-img-dc.png * 反解水印图(图片水印)
├── gakki-text-dc.png * 反解水印图(文字水印)
├── gakki-wm-img.png * 带图片盲水印的图
├── gakki-wm-text.png * 带文字盲水印的图
├── gakki.png * 原图
└── wm.png * 图片水印

### Usage:
原图 --- 变换 --> 原图变换域
带水印图 --- 变换 ---> 变换域 - 原图变换域

### Usage

Usage: java -jar BlindWatermark.jar <commands> [args...]
commands:
encode <option> <image-src> <watermark-text> <image-encoded(text)>
encode <option> <image-src> <watermark-image> <image-encoded(image)>
decode <image-encode(text)> <image-decode>
decode <image-src> <image-encoded(image)> <image-decode>
encode <option> <image-src> <watermark-text> <image-encoded(text)>
encode <option> <image-src> <watermark-image> <image-encoded(image)>
decode <option> <image-encode(text)> <image-decode>
decode <option> <image-src> <image-encoded(image)> <image-decode>
options:
-i add image watermark
-t add text watermark
### Build:
-c discrete cosine transform
-f discrete fourier transform
-i image watermark
-t text watermark
example:
encode -ft input.png watermark output.png
### Build

gradle build

### Demo:
### Demo

原图:
![image](https://github.com/ww23/BlindWatermark/blob/master/gakki.png)
![image](gakki-src.png)

加文字水印(DFT):
java -jar BlindWatermark.jar encode -ft gakki-src.png mywife gakki-dft-text-ec.png
![image](gakki-dft-text-ec.png)

文字水印解码(DFT):
java -jar BlindWatermark.jar decode -ft gakki-dft-text-ec.png gakki-dft-text-dc.png
![image](gakki-dft-text-dc.png)

加图片水印(DFT):
java -jar BlindWatermark.jar encode -fi gakki-src.png watermark.png gakki-dft-img-ec.png
![image](gakki-dft-img-ec.png)

图片水印解码(DFT):
java -jar BlindWatermark.jar decode -fi gakki-src.png gakki-dft-img-ec.png gakki-dft-img-dc.png
![image](gakki-dft-img-dc.png)

加文字水印(DCT):
java -jar BlindWatermark.jar encode -ct gakki-src.png mywife gakki-dct-text-ec.jpg
![image](gakki-dct-text-ec.jpg)

文字水印解码(DCT):
java -jar BlindWatermark.jar decode -ct gakki-dct-text-ec.jpg gakki-dct-text-dc.jpg
![image](gakki-dct-text-dc.jpg)

加图片水印(DCT):
java -jar BlindWatermark.jar encode -ci gakki-src.png watermark.png gakki-dct-img-ec.jpg
![image](gakki-dct-img-ec.jpg)

图片水印解码(DCT):
java -jar BlindWatermark.jar decode -ci gakki-src.png gakki-dct-img-ec.jpg gakki-dct-img-dc.jpg
![image](gakki-dct-img-dc.jpg)

### Reference

加文字水印:
java -jar BlindWatermark.jar encode -t gakki.png mywife gakki-wm-text.png
![image](https://github.com/ww23/BlindWatermark/blob/master/gakki-wm-text.png)
* [OpenCV Discrete Fourier Transform](https://docs.opencv.org/3.4/d8/d01/tutorial_discrete_fourier_transform.html)

加图片水印:
java -jar BlindWatermark.jar encode -i gakki.png wm.png gakki-wm-img.png
![image](https://github.com/ww23/BlindWatermark/blob/master/wm.png)
![image](https://github.com/ww23/BlindWatermark/blob/master/gakki-wm-img.png)
### License

文字水印解码:
java -jar BlindWatermark.jar decode gakki-wm-text.png gakki-text-dc.png
![image](https://github.com/ww23/BlindWatermark/blob/master/gakki-text-dc.png)
Copyright 2018 ww23(https://github.com/ww23/BlindWatermark).

图片水印解码:
java -jar BlindWatermark.jar decode gakki.png gakki-wm-img.png gakki-img-dc.png
![image](https://github.com/ww23/BlindWatermark/blob/master/gakki-img-dc.png)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

### Reference:
http://www.apache.org/licenses/LICENSE-2.0

* [OpenCV](https://docs.opencv.org/3.4/d8/d01/tutorial_discrete_fourier_transform.html) Discrete Fourier Transform
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Binary file added gakki-dct-img-dc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gakki-dct-img-ec.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gakki-dct-text-dc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gakki-dct-text-ec.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 922a734

Please sign in to comment.