mirror of
https://github.com/cedricbonhomme/Stegano.git
synced 2025-05-12 17:18:30 +02:00
Improved type check in statistics.py. mypy check added in travis configuration file.
This commit is contained in:
parent
98682932b5
commit
4122358571
2 changed files with 7 additions and 5 deletions
|
@ -9,6 +9,7 @@ install:
|
|||
|
||||
script:
|
||||
- nosetests --with-coverage --cover-package=stegano
|
||||
- mypy --ignore-missing-imports --follow-imports skip --check-untyped-defs stegano/
|
||||
|
||||
after_success:
|
||||
- coveralls
|
||||
|
|
|
@ -37,16 +37,17 @@ def steganalyse(img):
|
|||
"""
|
||||
encoded = img.copy()
|
||||
width, height = img.size
|
||||
colours = Counter()
|
||||
colours_counter = Counter() # type: Counter[int]
|
||||
for row in range(height):
|
||||
for col in range(width):
|
||||
r, g, b = img.getpixel((col, row))
|
||||
colours[r] += 1
|
||||
colours_counter[r] += 1
|
||||
|
||||
most_common = colours.most_common(10)
|
||||
dict_colours = OrderedDict(sorted(list(colours.items()), key=lambda t: t[1]))
|
||||
most_common = colours_counter.most_common(10)
|
||||
dict_colours = OrderedDict(sorted(list(colours_counter.items()),
|
||||
key=lambda t: t[1]))
|
||||
|
||||
colours = 0
|
||||
colours = 0 # type: float
|
||||
for colour in list(dict_colours.keys()):
|
||||
colours += colour
|
||||
colours = colours / len(dict_colours)
|
||||
|
|
Loading…
Add table
Reference in a new issue