changeset 78:9936c4886299

Mise a niveau specifications parametres deterministes, bruitage moins aggressif et transformations toutes pareilles tant qu'on ne rappelle pas regenerate_parameters()
author SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca>
date Wed, 10 Feb 2010 14:51:18 -0500
parents aee278ebc827
children c32a968851f5
files transformations/PermutPixel.py
diffstat 1 files changed, 24 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/transformations/PermutPixel.py	Wed Feb 10 14:42:40 2010 -0500
+++ b/transformations/PermutPixel.py	Wed Feb 10 14:51:18 2010 -0500
@@ -21,11 +21,15 @@
         self.proportion=0.3
         
     def get_settings_names(self):
+        return []
+    
+    def get_settings_name_determined_by_complexity(self):
         return ['nombre']
 
     def regenerate_parameters(self, complexity):
-        self.proportion=float(complexity)
+        self.proportion=float(complexity)/3
         self.nombre=int(256*self.proportion)*4   #Par multiple de 4 (256=1024/4)
+        self.echantillon=random.sample(xrange(0,1024),self.nombre)  #Les pixels qui seront permutes
         return self._get_current_parameters()
 
     def _get_current_parameters(self):
@@ -37,29 +41,28 @@
     def transform_image(self, image):
         image=image.reshape(1024,1)
         temp=0  #variable temporaire
-        #constitution de l'echantillon
-        echantillon=random.sample(xrange(0,1024),self.nombre)
-        for i in xrange(0,self.nombre,4):
+
+        for i in xrange(0,self.nombre,4):   #Par bonds de 4
             #gauche
-            if echantillon[i] > 0:
-                temp=image[echantillon[i]-1]
-                image[echantillon[i]-1]=image[echantillon[i]]
-                image[echantillon[i]]=temp
+            if self.echantillon[i] > 0:
+                temp=image[self.echantillon[i]-1]
+                image[self.echantillon[i]-1]=image[self.echantillon[i]]
+                image[self.echantillon[i]]=temp
             #droite
-            if echantillon[i+1] < 1023:
-                temp=image[echantillon[i+1]+1]
-                image[echantillon[i+1]+1]=image[echantillon[i+1]]
-                image[echantillon[i+1]]=temp
+            if self.echantillon[i+1] < 1023:
+                temp=image[self.echantillon[i+1]+1]
+                image[self.echantillon[i+1]+1]=image[self.echantillon[i+1]]
+                image[self.echantillon[i+1]]=temp
             #haut
-            if echantillon[i+2] > 31:
-                temp=image[echantillon[i+2]-32]
-                image[echantillon[i+2]-32]=image[echantillon[i+2]]
-                image[echantillon[i+2]]=temp
+            if self.echantillon[i+2] > 31:
+                temp=image[self.echantillon[i+2]-32]
+                image[self.echantillon[i+2]-32]=image[self.echantillon[i+2]]
+                image[self.echantillon[i+2]]=temp
             #bas
-            if echantillon[i+3] < 992:
-                temp=image[echantillon[i+3]+32]
-                image[echantillon[i+3]+32]=image[echantillon[i+3]]
-                image[echantillon[i+3]]=temp
+            if self.echantillon[i+3] < 992:
+                temp=image[self.echantillon[i+3]+32]
+                image[self.echantillon[i+3]+32]=image[self.echantillon[i+3]]
+                image[self.echantillon[i+3]]=temp
             
             
         return image.reshape((32,32))
@@ -91,6 +94,6 @@
     from pylearn.io import filetensor as ft
     import pylab
     for i in xrange(0,5):
-        _test(0.5)
+        _test(0)