Mercurial > ift6266
diff transformations/slant.py @ 45:f8a92292b299
merge de 4 fevrier
author | SylvainPL <sylvain.pannetier.lebeuf@umontreal.ca> |
---|---|
date | Thu, 04 Feb 2010 10:27:58 -0500 |
parents | 0f1337994716 |
children |
line wrap: on
line diff
--- a/transformations/slant.py Wed Feb 03 10:14:33 2010 -0500 +++ b/transformations/slant.py Thu Feb 04 10:27:58 2010 -0500 @@ -6,8 +6,7 @@ this module add a slant effect to the image. -To obtain the slant effect, each row of the array is shifted proportionately by a step -controlled by the complexity. +To obtain the slant effect, each row of the array is shifted proportionately by a step controlled by the complexity. ''' @@ -74,19 +73,26 @@ # Test function +# Load an image in local and create several samples of the effect on the +# original image with different parameter. All the samples are saved in a single image, the 1st image being the original. + def test_slant(): - img_name = "3.png" - dest_img_name = "slanted.png" - im = Image.open(img_name,) + import scipy + img_name = "test_img/mnist_0.png" + dest_img_name = "test_img/slanted.png" + nb_samples = 10 + im = Image.open(img_name) im = im.convert("L") image = numpy.asarray(im) + image_final = image + slant = Slant() + for i in range(nb_samples): + slant.regenerate_parameters(1) + image_slant = slant.transform_image(image) + image_final = scipy.hstack((image_final,image_slant)) - slant = Slant() - slant.regenerate_parameters(1) - image = slant.transform_image(image) - - im = Image.fromarray(image.astype('uint8'), "L") + im = Image.fromarray(image_final.astype('uint8'), "L") im.save(dest_img_name) # Test