changeset 111:259439a4f9e7

Changed a bit the code for BruitGauss.py for simplicity
author Xavier Glorot <glorotxa@iro.umontreal.ca>
date Tue, 16 Feb 2010 17:24:21 -0500
parents 93b4b84d86cf
children 1b315470a566
files transformations/BruitGauss.py
diffstat 1 files changed, 21 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/transformations/BruitGauss.py	Tue Feb 16 17:12:35 2010 -0500
+++ b/transformations/BruitGauss.py	Tue Feb 16 17:24:21 2010 -0500
@@ -35,39 +35,39 @@
         self.regenerate_parameters(complexity)
         
     def get_settings_names(self):
-        return ['nb_chng','sigma_gauss','grandeur','effectuer']
+        return ['nb_chng','sigma_gauss','grandeur']
 
     def regenerate_parameters(self, complexity):
-        self.nb_chng=3+int(numpy.random.rand()*self.nb_chngmax*complexity)
+        self.effectuer =numpy.random.binomial(1,0.25)    ##### On a 25% de faire un bruit #####
+
         
-        if float(complexity) > 0:
+        if self.effectuer and complexity > 0:
+            self.nb_chng=3+int(numpy.random.rand()*self.nb_chngmax*complexity)
             self.sigma_gauss=2.0 + numpy.random.rand()*self.sigmamax*complexity
             self.grandeur=12+int(numpy.random.rand()*self.grandeurmax*complexity)
-            self.effectuer =numpy.random.binomial(1,0.25)    ##### On a 25% de faire un bruit #####
+                        #creation du noyau gaussien
+            self.gauss=numpy.zeros((self.grandeur,self.grandeur))
+            x0 = y0 = self.grandeur/2.0
+            for i in xrange(self.grandeur):
+                for j in xrange(self.grandeur):
+                    self.gauss[i,j]=numpy.exp(-((i-x0)**2 + (j-y0)**2) / self.sigma_gauss**2)
+            #creation de la fenetre de moyennage
+            self.moy=numpy.zeros((self.grandeur,self.grandeur))
+            x0 = y0 = self.grandeur/2
+            for i in xrange(0,self.grandeur):
+                for j in xrange(0,self.grandeur):
+                    self.moy[i,j]=((numpy.sqrt(2*(self.grandeur/2.0)**2) -\
+                                 numpy.sqrt(numpy.abs(i-self.grandeur/2.0)**2+numpy.abs(j-self.grandeur/2.0)**2))/numpy.sqrt((self.grandeur/2.0)**2))**5
         else:
-            self.effectuer = 0
             self.sigma_gauss = 1 # eviter division par 0
             self.grandeur=1
-        #Un peu de paranoia ici, mais on ne sait jamais
+            self.nb_chng = 0
+            self.effectuer = 0
         
-        #creation du noyau gaussien
-        self.gauss=numpy.zeros((self.grandeur,self.grandeur))
-        x0 = y0 = self.grandeur/2.0
-        for i in xrange(self.grandeur):
-            for j in xrange(self.grandeur):
-                self.gauss[i,j]=numpy.exp(-((i-x0)**2 + (j-y0)**2) / self.sigma_gauss**2)
-        #creation de la fenetre de moyennage
-        self.moy=numpy.zeros((self.grandeur,self.grandeur))
-        x0 = y0 = self.grandeur/2
-        for i in xrange(0,self.grandeur):
-            for j in xrange(0,self.grandeur):
-                self.moy[i,j]=((numpy.sqrt(2*(self.grandeur/2.0)**2) - numpy.sqrt(numpy.abs(i-self.grandeur/2.0)**2+numpy.abs(j-self.grandeur/2.0)**2))/\
-                                numpy.sqrt((self.grandeur/2.0)**2))**5
-
         return self._get_current_parameters()
 
     def _get_current_parameters(self):
-        return [self.nb_chng,self.sigma_gauss,self.grandeur,self.effectuer]
+        return [self.nb_chng,self.sigma_gauss,self.grandeur]
 
     
     def transform_image(self, image):