mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-12 09:08:31 +02:00
added: test cases for shi-tomashi generator
Signed-off-by: thundersparkf <devagastya0@gmail.com>
This commit is contained in:
parent
8ea1553538
commit
c774e9e91c
3 changed files with 1049 additions and 0 deletions
1000
tests/expected-results/shi_tomashi.txt
Normal file
1000
tests/expected-results/shi_tomashi.txt
Normal file
File diff suppressed because it is too large
Load diff
|
@ -27,6 +27,8 @@ __license__ = "GPLv3"
|
|||
|
||||
import unittest
|
||||
import itertools
|
||||
import cv2
|
||||
import numpy as np
|
||||
|
||||
from stegano.lsbset import generators
|
||||
|
||||
|
@ -166,6 +168,41 @@ class TestGenerators(unittest.TestCase):
|
|||
tuple(int(line) for line in f),
|
||||
)
|
||||
|
||||
def test_shi_tomashi(self):
|
||||
""" Test the Shi Tomashi generator
|
||||
"""
|
||||
|
||||
# The expected results are only for tests/sample-files/Montenach.png file and
|
||||
# the below mentioned shi-tomashi configuration.
|
||||
# If the values below are changed,
|
||||
# please ensure the tests/expected-results/shi_tomashi.txt
|
||||
# is also appropriately modified
|
||||
# Using the shi_tomashi_reconfigure static method
|
||||
|
||||
image = cv2.imread("tests/sample-files/Montenach.png")
|
||||
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||
corners = cv2.goodFeaturesToTrack(gray, 1000, 0.001, 10)
|
||||
corners = np.int0(corners)
|
||||
corners = corners.reshape(corners.shape[0], -1)
|
||||
test_file = np.loadtxt("tests/expected-results/shi_tomashi.txt")
|
||||
test_file_reshaped = test_file.reshape(test_file.shape[0], test_file.shape[1])
|
||||
self.assertIsNone(np.testing.assert_array_equal(corners, test_file_reshaped))
|
||||
|
||||
@staticmethod
|
||||
def shi_tomashi_reconfigure(file_name: str,
|
||||
corners: int = 1000,
|
||||
quality: float = 0.001,
|
||||
min_distance: int = 10):
|
||||
"""
|
||||
Method to update/reconfigure Shi-Tomashi for various images and configuration
|
||||
"""
|
||||
image = cv2.imread(file_name)
|
||||
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||
corners = cv2.goodFeaturesToTrack(gray, corners, quality, min_distance)
|
||||
corners = np.int0(corners)
|
||||
corners = corners.reshape(corners.shape[0], -1)
|
||||
np.savetxt('tests/expected-results/shi_tomashi.txt', corners)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -68,6 +68,18 @@ class TestLSBSet(unittest.TestCase):
|
|||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_hide_and_reveal_with_shi_tomashi(self):
|
||||
messages_to_hide = ["foo bar"]
|
||||
for message in messages_to_hide:
|
||||
secret = lsbset.hide(
|
||||
"./tests/sample-files/Lenna.png", message, generators.shi_tomashi("./tests/sample-files/Lenna.png")
|
||||
)
|
||||
secret.save("./image.png")
|
||||
|
||||
clear_message = lsbset.reveal("./image.png", generators.shi_tomashi("./tests/sample-files/Lenna.png"))
|
||||
|
||||
self.assertEqual(message, clear_message)
|
||||
|
||||
def test_hide_and_reveal_with_shift(self):
|
||||
messages_to_hide = ["a", "foo", "Hello World!", ":Python:"]
|
||||
for message in messages_to_hide:
|
||||
|
|
Loading…
Add table
Reference in a new issue