changeset 753:0eee6693f149

better numeric stability in tile_image
author James Bergstra <bergstrj@iro.umontreal.ca>
date Tue, 02 Jun 2009 20:21:21 -0400
parents 80123baa4544
children 390d8c5a1fee
files pylearn/io/image_tiling.py
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/io/image_tiling.py	Tue Jun 02 20:20:48 2009 -0400
+++ b/pylearn/io/image_tiling.py	Tue Jun 02 20:21:21 2009 -0400
@@ -5,10 +5,10 @@
 import numpy
 from PIL import Image
 
-def scale_to_unit_interval(ndar):
+def scale_to_unit_interval(ndar,eps=1e-8):
     ndar = ndar.copy()
     ndar -= ndar.min()
-    ndar *= 1.0 / ndar.max()
+    ndar *= 1.0 / (ndar.max()+eps)
     return ndar
 
 def tile_raster_images(X, img_shape, tile_shape, tile_spacing=(0,0),