Mercurial > ift6266
changeset 84:104e0b8a1c70
testtransformation now work with all the transformations and save image files (.PNG) to a hard coded path
author | Xavier Glorot <glorotxa@iro.umontreal.ca> |
---|---|
date | Wed, 10 Feb 2010 17:38:17 -0500 |
parents | f75f5acad4eb |
children | 8aadb0f59a64 |
files | transformations/testtransformations.py |
diffstat | 1 files changed, 17 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/transformations/testtransformations.py Wed Feb 10 17:37:00 2010 -0500 +++ b/transformations/testtransformations.py Wed Feb 10 17:38:17 2010 -0500 @@ -15,7 +15,7 @@ from BruitGauss import BruitGauss from DistorsionGauss import DistorsionGauss from PermutPixel import PermutPixel -#from gimp_script import GIMP1 +from gimp_script import GIMP1 from Rature import Rature from contrast import Contrast from local_elastic_distortions import LocalElasticDistorter @@ -25,11 +25,11 @@ from affine_transform import AffineTransformation ###---------------------order of transformation module -MODULE_INSTANCES = [Slant(),Thick(),AffineTransformation(),LocalElasticDistorter(), PermutPixel(), Rature(), Occlusion(), BruitGauss(),PoivreSel(),AddBackground(), Contrast()] +MODULE_INSTANCES = [Slant(),Thick(),AffineTransformation(),LocalElasticDistorter(),GIMP1(), PermutPixel(),DistorsionGauss(), Rature(), Occlusion(),AddBackground(), BruitGauss(),PoivreSel(), Contrast()] ###---------------------complexity associated to each of them -complexity = [0.5,0.6,0.5,0.4,0.1,0.5,0.5,0.5,0.5,0.5,0.5] -complexity = [0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.] +complexity = [0.7,0.7,0.7,0.7,0.7,0.3,0.3,0.5,0.5,0.1,0.3,0.3,0.5] +#complexity = [0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.] @@ -43,21 +43,23 @@ pygame.surfarray.use_arraytype('numpy') -pygame.display.init() -screen = pygame.display.set_mode((4*(nbmodule+1)/2*32,2*(4*32+20)),0,8) +#pygame.display.init() +screen = pygame.Surface((4*(nbmodule+1)/2*32,2*(4*32+20)),depth=32) + anglcolorpalette=[(x,x,x) for x in xrange(0,256)] -screen.set_palette(anglcolorpalette) +#pygame.Surface.set_palette(anglcolorpalette) +#screen.set_palette(anglcolorpalette) pygame.font.init() for i in range(10000): a=d[i,:] b=N.asarray(N.reshape(a,(32,32))) - c=N.asarray(N.reshape(a*255.0,(32,32))).T + c=N.asarray([N.reshape(a*255.0,(32,32))]*3).T new=pygame.surfarray.make_surface(c) new=pygame.transform.scale2x(new) new=pygame.transform.scale2x(new) - new.set_palette(anglcolorpalette) + #new.set_palette(anglcolorpalette) screen.blit(new,(0,0)) offset = 4*32 @@ -67,15 +69,15 @@ #max dilation #random - print j.get_settings_names(), j.regenerate_parameters(complexity[ct]) + print j.get_settings_names(), j.regenerate_parameters(N.random.rand()*complexity[ct]) b=j.transform_image(b) - c=N.asarray(b*255).T + c=N.asarray([b*255]*3).T new=pygame.surfarray.make_surface(c) new=pygame.transform.scale2x(new) new=pygame.transform.scale2x(new) - new.set_palette(anglcolorpalette) + #new.set_palette(anglcolorpalette) screen.blit(new,(offset,offset2)) font = pygame.font.SysFont('liberationserif',18) text = font.render(j.__module__,0,(255,255,255),(0,0,0)) @@ -86,7 +88,7 @@ else: offset += 4*32 ct+=1 - pygame.display.update() - raw_input('Press Enter') + pygame.image.save(screen,'/u/glorotxa/exemples/%s.BMP'%i) + #raw_input('Press Enter') -pygame.display.quit() +#pygame.display.quit()