Création de la fonction de calibrage attente du résultat... ajout des paramètres seuil et borne au débruiteur (Salt&Pepper uniquement)

This commit is contained in:
xdrm-brackets 2015-09-16 21:35:01 +02:00
parent 1a281d4f1d
commit 2ff53c2a6b
6 changed files with 18 additions and 40 deletions

View File

@ -6,7 +6,7 @@ class Noise:
# ajout de bruit "poivre & sel" avec un seuil (% de l'image bruité) # ajout de bruit "poivre & sel" avec un seuil (% de l'image bruité)
def SaltAndPepper_set(self, seuil, pixelMap): def SaltAndPepper_set(self, pixelMap, seuil=10):
seuil = float(seuil); seuil = float(seuil);
while seuil >= 1: while seuil >= 1:
@ -25,12 +25,17 @@ class Noise:
# enlève le bruit "poivre et sel" # enlève le bruit "poivre et sel"
def SaltAndPepper_unset(self, pixelMap): def SaltAndPepper_unset(self, pixelMap, seuil=10, borne=20):
width = len( pixelMap[0] ) width = len( pixelMap[0] )
height = len( pixelMap ) height = len( pixelMap )
borne = 50 while seuil >= 1:
seuil = int( .1 * 256 ); seuil /= 100
while borne > 100:
borne /= 100
seuil = int( seuil * 256 );
for y in range(0, len(pixelMap)): for y in range(0, len(pixelMap)):
for x in range(0, len(pixelMap[y])): for x in range(0, len(pixelMap[y])):

View File

@ -1 +0,0 @@
Mauvais format (erreur de taille)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 768 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 768 KiB

View File

@ -9,7 +9,7 @@ from Noise import *
import random import random
import sys import sys
import time import time
from copy import deepcopy
class Timer: class Timer:
def __init__(self): def __init__(self):
@ -221,45 +221,19 @@ def calSaltAndPepper():
img = BMPFile(); # Instanciation du BMPFile img = BMPFile(); # Instanciation du BMPFile
noise = Noise(); # Instanciation du NoiseObject noise = Noise(); # Instanciation du NoiseObject
# Parsing
print "Parsing file -",; t.reset();
img.parse( binFile ); img.parse( binFile );
print "Done in %s s" % (t.get())
for seuil in range(0,100,10):
for borne in range(0,45,5):
newBMPFile = deepcopy(img)
print "Creating Salt&Pepper -",; t.reset(); print "SaltAndPepper (%s) (%s) -" % (seuil, borne),; t.reset();
noise.SaltAndPepper_set(50, img.content.map) noise.SaltAndPepper_unset(newBMPFile.content.map, seuil=seuil, borne=borne)
print "Done in %s s" % (t.get()) newBMPFile.unparse(newBpp=8)
newBMPFile.write( "SaltAndPepper/%s_%s.bmp" % (seuil, borne) )
print "Done in %s s" % (t.get())
# Unparsing
print "Unparsing file -",; t.reset();
img.unparse(newBpp=8)
print "Done in %s s" % (t.get())
# image to stdout
print "Writing file -",; t.reset();
img.write( "SaltAndPepper.bmp" )
print "Done in %s s" % (t.get())
print "Removing Salt&Pepper -",; t.reset();
noise.SaltAndPepper_unset(img.content.map)
print "Done in %s s" % (t.get())
# Unparsing
print "Unparsing file -",; t.reset();
img.unparse(newBpp=8)
print "Done in %s s" % (t.get())
# image to stdout
print "Writing file -",; t.reset();
img.write( sys.argv[2] )
print "Done in %s s" % (t.get())
print "\nExecution Time: %s seconds" % total.get() print "\nExecution Time: %s seconds" % total.get()