# HG changeset patch # User youssouf # Date 1265233379 18000 # Node ID 0f13379947168d2e400a050bbaec50431da07b71 # Parent 17caecc9254454bd06ac8e07f40b83590cd0ebe7 modified the test function in slant.py in order to generate multiple transformation sample diff -r 17caecc92544 -r 0f1337994716 transformations/slant.py --- a/transformations/slant.py Tue Feb 02 21:17:11 2010 -0500 +++ b/transformations/slant.py Wed Feb 03 16:42:59 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