Mercurial > ift6266
comparison transformations/Rature.py @ 125:5d3a7a4e30e9
little changes in Rature and occlusion to fit with visualisation
author | Xavier Glorot <glorotxa@iro.umontreal.ca> |
---|---|
date | Thu, 18 Feb 2010 12:58:34 -0500 |
parents | 4a29910eae93 |
children | a507adba0ce3 |
comparison
equal
deleted
inserted
replaced
124:b852dddf43a6 | 125:5d3a7a4e30e9 |
---|---|
52 self.patch=self.d[0].reshape((32,32)) #La patch de rature qui sera appliquee sur l'image | 52 self.patch=self.d[0].reshape((32,32)) #La patch de rature qui sera appliquee sur l'image |
53 | 53 |
54 def get_settings_names(self): | 54 def get_settings_names(self): |
55 return ['angle','numero','faire','crop_haut','crop_gauche','largeur_bande','smooth','nb_ratures'] | 55 return ['angle','numero','faire','crop_haut','crop_gauche','largeur_bande','smooth','nb_ratures'] |
56 | 56 |
57 def regenerate_parameters(self, complexity): | 57 def regenerate_parameters(self, complexity,next_rature = False): |
58 | 58 |
59 | 59 |
60 self.numero=random.randint(0,4999) #Ces bornes sont inclusives ! | 60 self.numero=random.randint(0,4999) #Ces bornes sont inclusives ! |
61 self.fini=0 | 61 self.fini=0 |
62 self.complexity=complexity | 62 self.complexity=complexity |
65 | 65 |
66 self.gauche=self.droite=self.haut=self.bas=-1 #Remet tout a -1 | 66 self.gauche=self.droite=self.haut=self.bas=-1 #Remet tout a -1 |
67 | 67 |
68 self.angle=int(numpy.random.normal(90,100*complexity)) | 68 self.angle=int(numpy.random.normal(90,100*complexity)) |
69 | 69 |
70 self.faire=numpy.random.binomial(1,0.15) ##### 15% d'effectuer une rature ##### | 70 self.faire=numpy.random.binomial(1,0.2) ##### 15% d'effectuer une rature ##### |
71 if next_rature: | |
72 self.faire = 1 | |
71 #self.faire=1 #Pour tester seulement | 73 #self.faire=1 #Pour tester seulement |
72 | 74 |
73 self.crop_haut=random.randint(0,17) | 75 self.crop_haut=random.randint(0,17) |
74 self.crop_gauche=random.randint(0,17) | 76 self.crop_gauche=random.randint(0,17) |
75 if complexity <= 0.25 : | 77 if complexity <= 0.25 : |
78 self.smooth=5 | 80 self.smooth=5 |
79 elif complexity <= 0.75: | 81 elif complexity <= 0.75: |
80 self.smooth=4 | 82 self.smooth=4 |
81 else: | 83 else: |
82 self.smooth=3 | 84 self.smooth=3 |
83 self.nb_ratures=int(numpy.random.normal(complexity*2,complexity*1.5))+1 | 85 self.nb_ratures=1+int(numpy.random.rand()*3) |
84 | 86 |
85 #Creation de la "patch" de rature qui sera appliquee sur l'image | 87 #Creation de la "patch" de rature qui sera appliquee sur l'image |
86 if self.faire == 1: | 88 if self.faire == 1: |
87 self.get_size() | 89 self.get_size() |
88 self.get_image_rot() #On fait la "patch" | 90 self.get_image_rot() #On fait la "patch" |
193 return image | 195 return image |
194 | 196 |
195 if self.fini == 0: #S'il faut rajouter des couches | 197 if self.fini == 0: #S'il faut rajouter des couches |
196 patch_temp=self.patch | 198 patch_temp=self.patch |
197 for w in xrange(1,self.nb_ratures): | 199 for w in xrange(1,self.nb_ratures): |
198 self.regenerate_parameters(self.complexity) | 200 self.regenerate_parameters(self.complexity,1) |
199 for i in xrange(0,32): | 201 for i in xrange(0,32): |
200 for j in xrange(0,32): | 202 for j in xrange(0,32): |
201 patch_temp[i,j]=max(patch_temp[i,j],self.patch[i,j]) | 203 patch_temp[i,j]=max(patch_temp[i,j],self.patch[i,j]) |
202 self.fini=1 | 204 self.fini=1 |
203 self.patch=patch_temp | 205 self.patch=patch_temp |