Mercurial > ift6266
comparison transformations/affine_transform.py @ 56:d9d836d3c625
Change in affine_transform to handle float images
author | Xavier Glorot <glorotxa@iro.umontreal.ca> |
---|---|
date | Sun, 07 Feb 2010 23:09:56 -0500 |
parents | 81b9567ec4ae |
children | 859ebd7f8754 |
comparison
equal
deleted
inserted
replaced
55:27bf31dca87d | 56:d9d836d3c625 |
---|---|
25 self.d = 0. + params[3]*.4*complexity | 25 self.d = 0. + params[3]*.4*complexity |
26 self.e = 1. + params[4]*.4*complexity | 26 self.e = 1. + params[4]*.4*complexity |
27 self.f = params[5]*8.*complexity | 27 self.f = params[5]*8.*complexity |
28 | 28 |
29 | 29 |
30 def _get_current_paramteres(self): | 30 def _get_current_parameters(self): |
31 return [self.a, self.b, self.c, self.d, self.e, self.g] | 31 return [self.a, self.b, self.c, self.d, self.e, self.f] |
32 | 32 |
33 def get_settings_names(self): | 33 def get_settings_names(self): |
34 return ['a','b','c','d','e','f'] | 34 return ['a','b','c','d','e','f'] |
35 | 35 |
36 def regenerate_parameters(self, complexity): | 36 def regenerate_parameters(self, complexity): |
57 | 57 |
58 def transform_image(self,NIST_image): | 58 def transform_image(self,NIST_image): |
59 | 59 |
60 im = Image.fromarray( \ | 60 im = Image.fromarray( \ |
61 numpy.asarray(\ | 61 numpy.asarray(\ |
62 NIST_image.reshape(self.shape), dtype='uint8')) | 62 NIST_image.reshape(self.shape)*255.0, dtype='uint8')) |
63 nwim = im.transform( (32,32), Image.AFFINE, [self.a,self.b,self.c,self.d,self.e,self.f]) | 63 nwim = im.transform( (32,32), Image.AFFINE, [self.a,self.b,self.c,self.d,self.e,self.f]) |
64 return numpy.asarray(nwim) | 64 return numpy.asarray(nwim)/255.0 |
65 | 65 |
66 | 66 |
67 | 67 |
68 if __name__ =='__main__': | 68 if __name__ =='__main__': |
69 print 'random test' | 69 print 'random test' |