diff data_generation/transformations/gimp_script.py @ 266:1e4e60ddadb1

Merge. Ah, et dans le dernier commit, j'avais oublié de mentionner que j'ai ajouté du code pour gérer l'isolation de différents clones pour rouler des expériences et modifier le code en même temps.
author fsavard
date Fri, 19 Mar 2010 10:56:16 -0400
parents dd2df78fcf47
children d5b2b6397a5a
line wrap: on
line diff
--- a/data_generation/transformations/gimp_script.py	Fri Mar 19 10:54:39 2010 -0400
+++ b/data_generation/transformations/gimp_script.py	Fri Mar 19 10:56:16 2010 -0400
@@ -30,12 +30,16 @@
     return numpy.fromstring(dest_rgn[:,:], 'UInt8').astype(numpy.float32).reshape((32,32)).T / 255.0
 
 class GIMP1():
-    def get_settings_names(self):
+    def __init__(self, blur_bool = True):
+        #This is used to avoid blurring for PNIST
+        self.blur_bool = blur_bool
+
+    def get_settings_names(self, blur_bool = True):
         return ['mblur_length', 'mblur_angle', 'pinch']
     
     def regenerate_parameters(self, complexity):
         if complexity:
-            self.mblur_length = abs(int(round(numpy.random.normal(0, 3*complexity))))
+           self.mblur_length = abs(int(round(numpy.random.normal(0, 3*complexity))))
         else:
             self.mblur_length = 0
         self.mblur_angle =  int(round(numpy.random.uniform(0,360)))
@@ -46,7 +50,7 @@
     def transform_image(self, image):
         if self.mblur_length or self.pinch:
             setpix(image)
-            if self.mblur_length:
+            if self.mblur_length and self.blur_bool:
                 pdb.plug_in_mblur(img, layer1, 0, self.mblur_length, self.mblur_angle, 0, 0)
             if self.pinch:        
                 pdb.plug_in_whirl_pinch(img, layer1, 0.0, self.pinch, 1.0)