changeset 964:6a778bca0dec

fixed saving in image_tiling.py to work for greyscale and colour images
author James Bergstra <bergstrj@iro.umontreal.ca>
date Fri, 20 Aug 2010 09:31:24 -0400
parents 06f21a964bd8
children bf54637bb994
files pylearn/io/image_tiling.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/io/image_tiling.py	Fri Aug 20 09:30:34 2010 -0400
+++ b/pylearn/io/image_tiling.py	Fri Aug 20 09:31:24 2010 -0400
@@ -105,7 +105,13 @@
 
     Returns the PIL image that was saved
     """
-    img = Image.fromarray( tiled_img, 'RGBA')
+    if tiled_img.ndim==2:
+        img = Image.fromarray( tiled_img, 'L')
+    elif tiled_img_ndim==3:
+        img = Image.fromarray( tiled_img, 'RGBA')
+    else:
+        raise TypeError('bad ndim', tiled_img)
+
     img.save(filename)
     return img