File size: 856 Bytes
06242ba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python3

import stc
import numpy as np
import imageio
from scipy import signal

input_image = 'files/1.pgm'

def HILL(input_image):
    H = np.array(
       [[-1,  2, -1],
        [ 2, -4,  2],
        [-1,  2, -1]])
    L1 = np.ones((3, 3)).astype('float32')/(3**2)
    L2 = np.ones((15, 15)).astype('float32')/(15**2)
    I = imageio.imread(input_image)
    costs = signal.convolve2d(I, H, mode='same')  
    costs = abs(costs)
    costs = signal.convolve2d(costs, L1, mode='same')  
    costs = 1/costs
    costs = signal.convolve2d(costs, L2, mode='same')  
    costs[costs == np.inf] = 1
    return costs

costs = HILL(input_image)
print(costs)

stc.embed(input_image, costs, 'files/message.txt', 's3cr3t', 'files/stego.png')
stc.extract('files/stego.png', 's3cr3t', 'files/output.txt')

print(open('files/output.txt', 'r').read())