changeset 1449:22f48914b3f8

Make tile_raster_images deal with a 3-tuple image shape as RGB spec.
author James Bergstra <bergstrj@iro.umontreal.ca>
date Thu, 31 Mar 2011 18:28:07 -0400
parents d0ae86920b1f
children c421bac46a97
files pylearn/io/image_tiling.py
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/io/image_tiling.py	Thu Mar 31 18:27:25 2011 -0400
+++ b/pylearn/io/image_tiling.py	Thu Mar 31 18:28:07 2011 -0400
@@ -40,7 +40,19 @@
     :rtype: a 2-d array with same dtype as X.
 
     """
-    if isinstance(X, tuple): 
+    if len(img_shape)==3 and img_shape[2]==3:
+        # make this save an rgb image
+
+        return tile_raster_images(
+                (X[:,0::3], X[:,1::3], X[:,2::3], None),
+                img_shape=img_shape[:2],
+                tile_shape=tile_shape,
+                tile_spacing=tile_spacing,
+                scale_rows_to_unit_interval=scale_rows_to_unit_interval,
+                output_pixel_vals=output_pixel_vals,
+                min_dynamic_range=min_dynamic_range)
+
+    if isinstance(X, tuple):
         n_images_in_x = X[0].shape[0]
     else:
         n_images_in_x = X.shape[0]