# HG changeset patch # User James Bergstra # Date 1305730342 14400 # Node ID 91a475ca9b6d586373d940e5f27af9074820cd08 # Parent ddda8d93c162217426daae4e4dd7281c15e2c48f image_tiling with better scaling for integer inputs diff -r ddda8d93c162 -r 91a475ca9b6d pylearn/io/image_tiling.py --- a/pylearn/io/image_tiling.py Wed May 18 10:51:50 2011 -0400 +++ b/pylearn/io/image_tiling.py Wed May 18 10:52:22 2011 -0400 @@ -100,6 +100,10 @@ H, W = img_shape Hs, Ws = tile_spacing + out_scaling = 1 + if output_pixel_vals and str(X.dtype).startswith('float'): + out_scaling = 255 + out_array = numpy.zeros(out_shape, dtype='uint8' if output_pixel_vals else X.dtype) for tile_row in xrange(tile_shape[0]): for tile_col in xrange(tile_shape[1]): @@ -121,7 +125,7 @@ tile_row * (H+Hs):tile_row*(H+Hs)+H, tile_col * (W+Ws):tile_col*(W+Ws)+W ] \ - = this_img * (255 if output_pixel_vals else 1) + = this_img * out_scaling return out_array