comparison transformations/testtransformations.py @ 80:4407ab3f7805

small display change in testtransformation
author Xavier Glorot <glorotxa@iro.umontreal.ca>
date Wed, 10 Feb 2010 15:03:40 -0500
parents 6846136b2201
children 104e0b8a1c70
comparison
equal deleted inserted replaced
79:53ee1097c02c 80:4407ab3f7805
13 from PoivreSel import PoivreSel 13 from PoivreSel import PoivreSel
14 from thick import Thick 14 from thick import Thick
15 from BruitGauss import BruitGauss 15 from BruitGauss import BruitGauss
16 from DistorsionGauss import DistorsionGauss 16 from DistorsionGauss import DistorsionGauss
17 from PermutPixel import PermutPixel 17 from PermutPixel import PermutPixel
18 #from gimp_script import GIMPTransformation 18 #from gimp_script import GIMP1
19 from Rature import Rature 19 from Rature import Rature
20 from contrast import Contrast 20 from contrast import Contrast
21 from local_elastic_distortions import LocalElasticDistorter 21 from local_elastic_distortions import LocalElasticDistorter
22 from slant import Slant 22 from slant import Slant
23 #from Occlusion import Occlusion 23 from Occlusion import Occlusion
24 from add_background_image import AddBackground 24 from add_background_image import AddBackground
25 from affine_transform import AffineTransformation 25 from affine_transform import AffineTransformation
26 26
27 ###---------------------order of transformation module 27 ###---------------------order of transformation module
28 MODULE_INSTANCES = [Thick(),Slant(),AffineTransformation(), LocalElasticDistorter(), PermutPixel(), Rature(), BruitGauss(),PoivreSel(), Contrast()] 28 MODULE_INSTANCES = [Slant(),Thick(),AffineTransformation(),LocalElasticDistorter(), PermutPixel(), Rature(), Occlusion(), BruitGauss(),PoivreSel(),AddBackground(), Contrast()]
29 29
30 ###---------------------complexity associated to each of them 30 ###---------------------complexity associated to each of them
31 complexity = [0.6,0.7,0.5,0.4,0.1,0.5,0.03,0.03,0.5] 31 complexity = [0.5,0.6,0.5,0.4,0.1,0.5,0.5,0.5,0.5,0.5,0.5]
32 complexity = [0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.]
33
32 34
33 35
34 nbmodule = len(MODULE_INSTANCES) 36 nbmodule = len(MODULE_INSTANCES)
35 37
36 datapath = '/data/lisa/data/nist/by_class/' 38 datapath = '/data/lisa/data/nist/by_class/'
40 d = d[0:1000,:]/255.0 42 d = d[0:1000,:]/255.0
41 43
42 pygame.surfarray.use_arraytype('numpy') 44 pygame.surfarray.use_arraytype('numpy')
43 45
44 pygame.display.init() 46 pygame.display.init()
45 screen = pygame.display.set_mode((4*(nbmodule+1)*32,4*32+20),0,8) 47 screen = pygame.display.set_mode((4*(nbmodule+1)/2*32,2*(4*32+20)),0,8)
46 anglcolorpalette=[(x,x,x) for x in xrange(0,256)] 48 anglcolorpalette=[(x,x,x) for x in xrange(0,256)]
47 screen.set_palette(anglcolorpalette) 49 screen.set_palette(anglcolorpalette)
48 50
49 pygame.font.init() 51 pygame.font.init()
50 52
57 new=pygame.transform.scale2x(new) 59 new=pygame.transform.scale2x(new)
58 new.set_palette(anglcolorpalette) 60 new.set_palette(anglcolorpalette)
59 screen.blit(new,(0,0)) 61 screen.blit(new,(0,0))
60 62
61 offset = 4*32 63 offset = 4*32
64 offset2 = 0
62 ct = 0 65 ct = 0
63 for j in MODULE_INSTANCES: 66 for j in MODULE_INSTANCES:
64 #max dilation 67 #max dilation
65 68
66 #random 69 #random
71 74
72 new=pygame.surfarray.make_surface(c) 75 new=pygame.surfarray.make_surface(c)
73 new=pygame.transform.scale2x(new) 76 new=pygame.transform.scale2x(new)
74 new=pygame.transform.scale2x(new) 77 new=pygame.transform.scale2x(new)
75 new.set_palette(anglcolorpalette) 78 new.set_palette(anglcolorpalette)
76 screen.blit(new,(offset,0)) 79 screen.blit(new,(offset,offset2))
77 font = pygame.font.SysFont('liberationserif',18) 80 font = pygame.font.SysFont('liberationserif',18)
78 text = font.render(j.__module__,0,(255,255,255),(0,0,0)) 81 text = font.render(j.__module__,0,(255,255,255),(0,0,0))
79 screen.blit(text,(offset,4*32)) 82 screen.blit(text,(offset,offset2+4*32))
80 offset += 4*32 83 if ct == len(MODULE_INSTANCES)/2-1:
84 offset = 0
85 offset2 = 4*32+20
86 else:
87 offset += 4*32
81 ct+=1 88 ct+=1
82 pygame.display.update() 89 pygame.display.update()
83 raw_input('Press Enter') 90 raw_input('Press Enter')
84 91
85 pygame.display.quit() 92 pygame.display.quit()