diff --git a/code/Noise.py b/code/Noise.py index 488c86b..6063755 100644 --- a/code/Noise.py +++ b/code/Noise.py @@ -18,7 +18,7 @@ class Noise: nbPixel = int( len(pixelMap) * len(pixelMap[0]) * seuil ) - for bruit in range(0, nbPixel ): + for bruit in range(0, nbPixel): x = random.randint(0, len(pixelMap[0]) - 1 ) y = random.randint(0, len(pixelMap) - 1 ) @@ -54,7 +54,7 @@ class Noise: # si couleur proche du blanc ou noir (en fonction de la borne) if pMoy >= 255-borne or pMoy <= borne: - xmin, ymin, xmax, ymap = x, y, x, y; # les bornes ducarré 3x3 autour du pixel + xmin, ymin, xmax, ymax = x, y, x, y; # les bornes ducarré 3x3 autour du pixel rMoy, gMoy, bMoy, count = 0.0, 0.0, 0.0, 0 # initialisation des variables de moyennes et de total rInterval, gInterval, bInterval, rgbInterval = 0, 0, 0, 0 # initialisation des variables d'intervalles entre les couleurs @@ -222,6 +222,7 @@ class Noise: pixels = [ pixelMap[y][xmin], pixelMap[y][xmax], pixelMap[ymin][x], pixelMap[ymax][x] ]; + for p in pixels: if p != pixelMap[y][x]: rMoy += p.r; @@ -251,6 +252,35 @@ class Noise: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + # lissage de l'image def smooth(self, pixelMap, seuil=5): width = len( pixelMap[0] ) @@ -341,31 +371,7 @@ class Noise: def MultiplicativeNoise_set(self, pixelMap, seuil=10): - seuil = float(seuil); - - while seuil >= 1: - seuil /= 100.0 - - nbPixel = int( len(pixelMap) * len(pixelMap[0]) * seuil ) - - for bruit in range(0, nbPixel ): - x = random.randint(0, len(pixelMap[0]) - 1 ) - y = random.randint(0, len(pixelMap) - 1 ) - - - - if random.randint(0,1) == 1: - maxColor = max(pixelMap[y][x].r, pixelMap[y][x].g, pixelMap[y][x].b) - randomAdd = random.randint(0, (255-maxColor) / 10 ) - else: - minColor = min(pixelMap[y][x].r, pixelMap[y][x].g, pixelMap[y][x].b) - randomAdd = - random.randint(0, minColor / 10 ) - - pixelMap[y][x].setRGB( - pixelMap[y][x].r + randomAdd, - pixelMap[y][x].g + randomAdd, - pixelMap[y][x].b + randomAdd - ); + pass def MultiplicativeNoise_unset(self, pixelMap, seuil=5): pass diff --git a/code/created/AdditiveNoise(onlyadd).bmp b/code/created/AdditiveNoise(onlyadd).bmp new file mode 100644 index 0000000..150726b Binary files /dev/null and b/code/created/AdditiveNoise(onlyadd).bmp differ diff --git a/code/created/additiveNoise_more_less.png b/code/created/additiveNoise_more_less.png new file mode 100644 index 0000000..a458d70 Binary files /dev/null and b/code/created/additiveNoise_more_less.png differ diff --git a/code/created/comparaison_ori_add_removeadd_salt.png b/code/created/comparaison_ori_add_removeadd_salt.png new file mode 100644 index 0000000..edb27be Binary files /dev/null and b/code/created/comparaison_ori_add_removeadd_salt.png differ diff --git a/code/created/compare_ori_add_removesalt_salt.png b/code/created/compare_ori_add_removesalt_salt.png new file mode 100644 index 0000000..d73cca0 Binary files /dev/null and b/code/created/compare_ori_add_removesalt_salt.png differ diff --git a/code/images/gaussian.bmp b/code/images/gaussian.bmp new file mode 100644 index 0000000..a9c678e Binary files /dev/null and b/code/images/gaussian.bmp differ diff --git a/code/images/piaf.bmp b/code/images/piaf.bmp new file mode 100644 index 0000000..865597a Binary files /dev/null and b/code/images/piaf.bmp differ diff --git a/code/new.bmp b/code/new.bmp deleted file mode 100644 index b98211e..0000000 Binary files a/code/new.bmp and /dev/null differ