-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright (c) 2019 ww23(https://github.com/ww23/BlindWatermark). | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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. | ||
*/ | ||
|
||
package me.ww23.image; | ||
|
||
import me.ww23.image.coder.Decoder; | ||
import me.ww23.image.coder.Encoder; | ||
import me.ww23.image.coder.ImageEncoder; | ||
import me.ww23.image.coder.TextEncoder; | ||
import me.ww23.image.converter.Converter; | ||
import me.ww23.image.converter.DctConverter; | ||
import me.ww23.image.converter.DftConverter; | ||
import me.ww23.image.util.Supporter; | ||
import org.bytedeco.javacpp.opencv_core; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.bytedeco.javacpp.opencv_core.*; | ||
|
||
class BlindWatermarkTest { | ||
|
||
private Converter converterDct = new DctConverter(); | ||
|
||
@Test | ||
void dct() { | ||
Converter converter = new DctConverter(); | ||
Encoder encoder = new ImageEncoder(converter); | ||
encoder.encode("image/gakki-src.png", "image/watermark.png", "image/gakki-dct-img-ec.jpg"); | ||
Decoder decoder = new Decoder(converter); | ||
decoder.decode("image/gakki-dct-img-ec.jpg", "image/gakki-dct-img-dc.jpg"); | ||
encoder = new TextEncoder(converter); | ||
encoder.encode("image/gakki-src.png", "test", "image/gakki-dct-text-ec.jpg"); | ||
decoder.decode("image/gakki-dct-text-ec.jpg", "image/gakki-dct-text-dc.jpg"); | ||
} | ||
|
||
@Test | ||
void dft() { | ||
Converter converter = new DftConverter(); | ||
Encoder encoder = new ImageEncoder(converter); | ||
encoder.encode("image/gakki-src.png", "image/watermark.png", "image/gakki-dft-img-ec.png"); | ||
Decoder decoder = new Decoder(converter); | ||
decoder.decode("image/gakki-dft-img-ec.png", "image/gakki-dft-img-dc.png"); | ||
encoder = new TextEncoder(converter); | ||
encoder.encode("image/gakki-src.png", "test", "image/gakki-dft-text-ec.png"); | ||
decoder.decode("image/gakki-dft-text-ec.png", "image/gakki-dft-text-dc.png"); | ||
} | ||
|
||
@Test | ||
void speedGray() { | ||
opencv_core.Mat src = Supporter.read("image/gakki-src.png", CV_8U); | ||
converterDct.addTextWatermark(converterDct.start(src), "test"); | ||
converterDct.inverse(src); | ||
} | ||
} |