# HG changeset patch # User James Bergstra # Date 1301610487 14400 # Node ID 22f48914b3f84eb121ddc214dfe2cb0aad7f0be3 # Parent d0ae86920b1f8cba96d4e7f2aa7b4b45c9d335c8 Make tile_raster_images deal with a 3-tuple image shape as RGB spec. diff -r d0ae86920b1f -r 22f48914b3f8 pylearn/io/image_tiling.py --- 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]