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 *
2015-09-17 19:15:42 +00:00
from tests import *
2015-09-08 20:42:28 +00:00
import random
2015-09-06 12:54:58 +00:00
import sys
2015-09-14 19:58:21 +00:00
import time
2015-09-08 19:17:00 +00:00
2015-09-17 22:33:14 +00:00
# arrêt si moins de 2 arguments
if len ( sys . argv ) < 3 :
print " Require 2 args : \n * input image \n * output image "
exit ( )
2015-09-17 13:55:16 +00:00
2015-09-17 22:33:14 +00:00
################" INTERFACE "###################
print " +-------------------------+ "
2015-09-18 08:45:46 +00:00
print " | | "
2015-09-17 22:33:14 +00:00
print " | TRAITEMENT D ' IMAGE | "
2015-09-18 08:45:46 +00:00
print " | | "
2015-09-17 22:33:14 +00:00
print " +-------------------------+ "
print " | <in> %s | " % exactLength ( sys . argv [ 1 ] , 17 , - 1 )
print " | <out> %s | " % exactLength ( sys . argv [ 2 ] , 17 , - 1 )
print " +-------------------------+ "
print " | %s | " % exactLength ( " TESTS DE FICHIER " , 23 , 0 )
print " | %s | " % exactLength ( " " , 23 , 0 )
print " | 0) %s | " % exactLength ( " Creation manuelle " , 20 , - 1 )
print " | 1) %s | " % exactLength ( " Parse/Unparse " , 20 , - 1 )
print " | 2) %s | " % exactLength ( " Afficher palette " , 20 , - 1 )
print " +-------------------------+ "
print " | %s | " % exactLength ( " TESTS DE BRUIT " , 23 , 0 )
print " | %s | " % exactLength ( " " , 23 , 0 )
print " | 3) %s | " % exactLength ( " Salt&Pepper " , 20 , - 1 )
print " | 4) %s | " % exactLength ( " Additif " , 20 , - 1 )
print " +-------------------------+ "
print " | %s | " % exactLength ( " TESTS DE DIFFERENCES " , 23 , 0 )
print " | %s | " % exactLength ( " " , 23 , 0 )
print " | 5) %s | " % exactLength ( " Difference en % " , 20 , - 1 )
print " | 6) %s | " % exactLength ( " Difference en image " , 20 , - 1 )
2015-09-18 08:45:46 +00:00
print " | 7) %s | " % exactLength ( " Fusion d ' images (+) " , 20 , - 1 )
print " | 8) %s | " % exactLength ( " Fusion d ' images (-) " , 20 , - 1 )
2015-09-17 22:33:14 +00:00
print " +-------------------------+ "
print
while True :
action = int ( raw_input ( " choix: " ) )
2015-09-18 08:45:46 +00:00
if action > = 0 and action < = 8 :
2015-09-17 22:33:14 +00:00
break ;
print
print " +-------------------------+---------+ "
execTime = Timer ( ) ; execTime . reset ( ) ;
2015-09-18 08:45:46 +00:00
result = " "
2015-09-17 22:33:14 +00:00
if action == 0 :
testManualCreation ( ) # teste la création d'un fichier à partir d'une matrice uniquement
elif action == 1 :
2015-09-18 08:45:46 +00:00
result = testFileIntegrity ( ) # teste le PARSE/UNPARSE
2015-09-17 22:33:14 +00:00
elif action == 2 :
2015-09-18 08:45:46 +00:00
result = printIntPalette ( ) # affiche la palette d'une image
2015-09-17 22:33:14 +00:00
elif action == 3 :
testSaltAndPepper ( ) # teste le bruitage/débruitage de type "Sel & Poivre"
elif action == 4 :
testAdditiveNoise ( ) # teste le bruitage/débruitage de type "Additif"
elif action == 5 :
printImageQuality ( ) # compare 2 images et donne le pourcentage de ressemblance/différence
elif action == 6 :
imageForImageQuality ( ) # crée une image correspondant aux différences de 2 images
elif action == 7 :
2015-09-18 08:45:46 +00:00
mergeImagesAdditive ( ) # crée une image étant la fusion (addition) de 2 images
elif action == 8 :
mergeImagesSubstractive ( ) # crée une image étant la fusion (soustractive) de 2 images
2015-09-17 22:33:14 +00:00
else :
print " Error! aborting "
print " +-------------------------+---------+ "
print " | EXECUTION TIME | %s | " % execTime . get ( )
print " +-------------------------+---------+ "
2015-09-18 08:45:46 +00:00
print
print result
2015-09-17 13:55:16 +00:00
2015-09-16 19:14:08 +00:00
############ TESTS ############
2015-09-17 19:15:42 +00:00
# testManualCreation() # teste la création d'un fichier à partir d'une matrice uniquement
# testFileIntegrity() # teste le PARSE/UNPARSE
# printIntPalette() # affiche la palette d'une image
2015-09-16 19:14:08 +00:00
2015-09-17 19:15:42 +00:00
# testSaltAndPepper() # teste le bruitage/débruitage de type "Sel & Poivre"
# testAdditiveNoise() # teste le bruitage/débruitage de type "Additif"
2015-09-16 19:14:08 +00:00
2015-09-17 22:33:14 +00:00
# printImageQuality() # compare 2 images et donne le pourcentage de ressemblance/différence
2015-09-16 19:14:08 +00:00
2015-09-17 19:15:42 +00:00
# imageForImageQuality() # crée une image correspondant aux différences de 2 images
# mergeImages() # crée une image étant la fusion (addition) de 2 images
2015-09-16 19:14:08 +00:00
############ CALIBRATE ############
2015-09-17 19:15:42 +00:00
# calSaltAndPepper() # Calibration en créant des fichiers pour les paramètres différents de débruitage dans le dossier /SaltAndPepper (sert à comparer)