denoising.py/code/bmp.py

65 lines
903 B
Python
Raw Normal View History

2015-09-06 12:54:58 +00:00
# ~*~ encoding: utf-8 ~*~ #
###########################
# TRAITEMENT D'IMAGES #
###########################
2015-09-06 14:01:17 +00:00
# classes
2015-09-09 13:52:20 +00:00
from BMPFile import *
2015-09-10 21:37:17 +00:00
from Noise import *
import random
2015-09-06 12:54:58 +00:00
import sys
def testFileIntegrity():
# lecture du fichier
with open( sys.argv[1] ) as file:
binFile = file.read()
# Instanciation du BMPFile
img = BMPFile()
2015-09-14 14:59:35 +00:00
# Instanciation du NoiseObject
noise = Noise();
# Parsing
img.parse( binFile );
2015-09-14 14:59:35 +00:00
noise.SaltAndPepper_set(10, img.content.map)
# Unparsing
2015-09-14 14:59:35 +00:00
img.unparse(newBpp=24)
print img.binData
2015-09-06 12:54:58 +00:00
2015-09-07 08:11:04 +00:00
def testManualCreation():
img = BMPFile()
for y in range(0, 100):
img.content.map.append( [] )
for x in range(0, 100):
img.content.map[y].append( RGBPixel(
random.randint(0, 255),
random.randint(0, 255),
random.randint(0, 255),
bpp=24
) );
img.unparse();
print img.binData
2015-09-07 08:24:28 +00:00
# MAIN
#testManualCreation()
testFileIntegrity()