def build(step): return BlockBitHider( TransformHider( SingleBitHider(ScanMapping(), BinaryQuantizationIndexModulation(step)), ImageTransform( SeparableTransform(transform.TCHEBICHEF, transform.DCT2))))
def build(step, alpha, dimension=8): CHARLIER = matrix.CharlierMatrix(dimension, alpha=alpha).get_values() return BlockBitHider( TransformHider( SingleBitHider(ScanMapping(), BinaryQuantizationIndexModulation(step)), ImageTransform(SeparableTransform(CHARLIER, transform.DCT2))))
def build(step, a, q, dimension=8): qc = QCharlierMatrix(dimension, a=a, q=q) th = TchebichefMatrix(dimension, N=dimension) transform = SeparableTransform(qc.get_values(), th.get_values()) return BlockBitHider( TransformHider( SingleBitHider(ScanMapping(), BinaryQuantizationIndexModulation(step)), ImageTransform(transform)))
def build(step, alpha, beta, gamma, dimension=8): return BlockBitHider( TransformHider( SingleBitHider(ScanMapping(), BinaryQuantizationIndexModulation(step)), ImageTransform( matrix.CharlierSobolevMatrix(dimension, alpha=alpha, beta=beta, gamma=gamma))))
def test_set_coeficient(self): ''' Test set coefficient with 8x8 row major scan ''' block = np.array(range(0, 64)).reshape(8, 8) scan = ScanMapping() scanning = scan(block) scanning[24] = 8 self.assertEqual(block[3, 0], 8)
def test_map_index_out_range(self): block = np.array(range(0, 64)).reshape(8, 8) scan = ScanMapping() scanning = scan(block) with self.assertRaises(IndexError, msg='scan index out of range'): scanning[64] with self.assertRaises(IndexError, msg='scan index out of range'): scanning[64] = 9
def test_get_coeficient(self): ''' Test get coefficient with 8x8 row major scan ''' block = np.array(range(0, 64)).reshape(8, 8) scan = ScanMapping() scanning = scan(block) self.assertEqual(scanning[0], 0) self.assertEqual(scanning[18], 18) self.assertEqual(scanning[63], 63)
def test_scanning(self): ''' Test scanning with 8x8 row major scan ''' block = np.array(range(0, 64)).reshape(8, 8) exploration = list(range(0, 64)) scan = ScanMapping() scanning = scan(block) np.testing.assert_array_equal(list(scanning), exploration)
def test_block_index_out_range(self): ''' Test raise condition when block has less dimension than the map ''' block = np.array([[0, 1, 5, 6], [2, 4, 7, 13], [3, 8, 12, 17], [9, 11, 18, 24]]) scan = ScanMapping() scanning = scan(block) with self.assertRaises(IndexError, msg='block index out of range'): scanning[63] with self.assertRaises(IndexError, msg='block index out of range'): scanning[63] = 8
def test_extract(self): embedder = MagicMock() embedder.extract = Mock(return_value=0.52259635) cover = np.array([ [0.72104381, 0.3611912], [0.54423469, 0.99351504], ]) scan = ScanMapping() hider = hiders.SingleBitHider(scan, embedder) amplitude = hider.extract(cover, index=0) embedder.extract.assert_called_once_with(.72104381) self.assertEqual(amplitude, .52259635)
def test_set_coeficient(self): ''' Test set coefficient with 8x8 zig-zag scan ''' block = np.array([[0, 1, 5, 6, 14, 15, 27, 28], [2, 4, 7, 13, 16, 26, 29, 42], [3, 8, 12, 17, 25, 30, 41, 43], [9, 11, 18, 24, 31, 40, 44, 53], [10, 19, 23, 32, 39, 45, 52, 54], [20, 22, 33, 38, 46, 51, 55, 60], [21, 34, 37, 47, 50, 56, 59, 61], [35, 36, 48, 49, 57, 58, 62, 63]]) scan = ScanMapping(map=maps.ZIGZAG_8x8) scanning = scan(block) scanning[24] = 8 self.assertEqual(block[3, 3], 8)
def test_scanning(self): ''' Test scanning with 8x8 zig-zag scan ''' block = np.array([[0, 1, 5, 6, 14, 15, 27, 28], [2, 4, 7, 13, 16, 26, 29, 42], [3, 8, 12, 17, 25, 30, 41, 43], [9, 11, 18, 24, 31, 40, 44, 53], [10, 19, 23, 32, 39, 45, 52, 54], [20, 22, 33, 38, 46, 51, 55, 60], [21, 34, 37, 47, 50, 56, 59, 61], [35, 36, 48, 49, 57, 58, 62, 63]]) exploration = list(range(0, 64)) scan = ScanMapping(map=maps.ZIGZAG_8x8) scanning = scan(block) np.testing.assert_array_equal(list(scanning), exploration)
def test_map_index_out_range(self): block = np.array([[0, 1, 5, 6, 14, 15, 27, 28], [2, 4, 7, 13, 16, 26, 29, 42], [3, 8, 12, 17, 25, 30, 41, 43], [9, 11, 18, 24, 31, 40, 44, 53], [10, 19, 23, 32, 39, 45, 52, 54], [20, 22, 33, 38, 46, 51, 55, 60], [21, 34, 37, 47, 50, 56, 59, 61], [35, 36, 48, 49, 57, 58, 62, 63]]) scan = ScanMapping(map=maps.ZIGZAG_8x8) scanning = scan(block) with self.assertRaises(IndexError, msg='scan index out of range'): scanning[64] with self.assertRaises(IndexError, msg='scan index out of range'): scanning[64] = 9
def test_insert(self): embedder = MagicMock() embedder.embed = Mock(return_value=0.52259635) cover_work = np.array([ [0.72104381, 0.3611912], [0.54423469, 0.99351504], ]) ws_work_expected = np.array([ [0.52259635, 0.3611912], [0.54423469, 0.99351504], ]) scan = ScanMapping() hider = hiders.SingleBitHider(scan, embedder) ws_work = hider.insert(cover_work, bit=1, index=0) embedder.embed.assert_called_once_with(0.72104381, 1) np.testing.assert_array_equal(ws_work, ws_work_expected)
def build(step): return BlockBitHider( TransformHider( SingleBitHider(ScanMapping(), BinaryQuantizationIndexModulation(step)), ImageTransform(DCT())))
def build(step, p, q, dimensions=8): return BlockBitHider( TransformHider( SingleBitHider(ScanMapping(), BinaryQuantizationIndexModulation(step)), ImageTransform(QKrawtchoukMatrix(dimensions, p=p, q=q))))