Mercurial > pylearn
changeset 1473:91a475ca9b6d
image_tiling with better scaling for integer inputs
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Wed, 18 May 2011 10:52:22 -0400 |
parents | ddda8d93c162 |
children | a57f4839a9d8 |
files | pylearn/io/image_tiling.py |
diffstat | 1 files changed, 5 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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