Mercurial > ift6266
changeset 40:0f1337994716
modified the test function in slant.py in order to generate multiple transformation sample
author | youssouf |
---|---|
date | Wed, 03 Feb 2010 16:42:59 -0500 |
parents | 17caecc92544 |
children | fdb0e0870fb4 |
files | transformations/slant.py |
diffstat | 1 files changed, 16 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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