mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-06-28 03:06:14 +02:00
Improved code style.
This commit is contained in:
parent
9b216d9d59
commit
71f6c08c28
19 changed files with 335 additions and 253 deletions
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
#-*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from .parity import *
|
||||
from .statistics import *
|
||||
|
|
|
@ -32,26 +32,28 @@ from PIL import Image
|
|||
from collections import Counter
|
||||
from collections import OrderedDict
|
||||
|
||||
|
||||
def steganalyse(img):
|
||||
"""
|
||||
Steganlysis of the LSB technique.
|
||||
"""
|
||||
encoded = img.copy()
|
||||
width, height = img.size
|
||||
colours_counter = Counter() # type: typing.Counter[int]
|
||||
colours_counter = Counter() # type: typing.Counter[int]
|
||||
for row in range(height):
|
||||
for col in range(width):
|
||||
r, g, b = img.getpixel((col, row))
|
||||
colours_counter[r] += 1
|
||||
|
||||
most_common = colours_counter.most_common(10)
|
||||
dict_colours = OrderedDict(sorted(list(colours_counter.items()),
|
||||
key=lambda t: t[1]))
|
||||
dict_colours = OrderedDict(
|
||||
sorted(list(colours_counter.items()), key=lambda t: t[1])
|
||||
)
|
||||
|
||||
colours = 0 # type: float
|
||||
colours = 0 # type: float
|
||||
for colour in list(dict_colours.keys()):
|
||||
colours += colour
|
||||
colours = colours / len(dict_colours)
|
||||
|
||||
#return colours.most_common(10)
|
||||
# return colours.most_common(10)
|
||||
return list(dict_colours.keys())[:30], most_common
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue