comparison transformations/PoivreSel.py @ 76:42e3e2f67626

Mise a niveau specifications parametres deterministes et invariance des bites changees entre les appels de regenerate_parameters()
author SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
date Wed, 10 Feb 2010 14:24:35 -0500
parents 8b9fca879543
children ab57cd2b252c
comparison
equal deleted inserted replaced
75:9e5463ebd044 76:42e3e2f67626
23 def __init__(self): 23 def __init__(self):
24 self.proportion_bruit=0.1 #Le pourcentage des pixels qui seront bruites 24 self.proportion_bruit=0.1 #Le pourcentage des pixels qui seront bruites
25 self.nb_chng=10 #Le nombre de pixels changes. Seulement pour fin de calcul 25 self.nb_chng=10 #Le nombre de pixels changes. Seulement pour fin de calcul
26 26
27 def get_settings_names(self): 27 def get_settings_names(self):
28 return []
29
30 def get_settings_name_determined_by_complexity(self):
28 return ['proportion_bruit'] 31 return ['proportion_bruit']
29 32
30 def regenerate_parameters(self, complexity): 33 def regenerate_parameters(self, complexity):
31 self.proportion_bruit = float(complexity)/5 34 self.proportion_bruit = float(complexity)/5
32 self.nb_chng=int(1024*self.proportion_bruit) 35 self.nb_chng=int(1024*self.proportion_bruit)
36 self.changements=random.sample(xrange(1024),self.nb_chng) #Les pixels qui seront changes
33 return self._get_current_parameters() 37 return self._get_current_parameters()
34 38
35 def _get_current_parameters(self): 39 def _get_current_parameters(self):
36 return [] 40 return []
37 41
38 def get_parameters_determined_by_complexity(self, complexity): 42 def get_parameters_determined_by_complexity(self, complexity):
39 return [self.proportion_bruit] 43 return [self.proportion_bruit]
40 44
41 def transform_image(self, image): 45 def transform_image(self, image):
42 image=image.reshape(1024,1) 46 image=image.reshape(1024,1)
43 changements=random.sample(xrange(numpy.size(image)),self.nb_chng) #Les pixels qui seront changes
44 for j in xrange(0,self.nb_chng): 47 for j in xrange(0,self.nb_chng):
45 image[changements[j]]=numpy.random.random() #On determine les nouvelles valeurs des pixels changes 48 image[self.changements[j]]=numpy.random.random() #On determine les nouvelles valeurs des pixels changes
46 return image.reshape(32,32) 49 return image.reshape(32,32)
47 50
48 51
49 #---TESTS--- 52 #---TESTS---
50 53