Mercurial > pylearn
changeset 877:533b9a0a14f3
Added support for still images in float storage to glviewer
author | James Bergstra <bergstrj@iro.umontreal.ca> |
---|---|
date | Mon, 16 Nov 2009 13:37:52 -0500 |
parents | 04115110bb67 |
children | faa9f880d0d2 |
files | pylearn/dataset_ops/glviewer.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pylearn/dataset_ops/glviewer.py Mon Nov 16 13:37:01 2009 -0500 +++ b/pylearn/dataset_ops/glviewer.py Mon Nov 16 13:37:52 2009 -0500 @@ -57,7 +57,16 @@ glPixelStorei(GL_UNPACK_ALIGNMENT,1) return glTexImage2D(GL_TEXTURE_2D, 0, 3, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf[::-1].flatten()) + elif str(x.dtype).startswith('float'): + rows, cols = x.shape + buf = numpy.zeros((rows, cols, 4), dtype='uint8') + buf += x.reshape( (rows, cols, 1)) * 255 + glPixelStorei(GL_UNPACK_ALIGNMENT,1) + debug( 'HHUH? %f'% buf.sum()) + return glTexImage2D(GL_TEXTURE_2D, 0, 3, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, + buf[::-1].flatten()) else: + debug('NOOO....') raise NotImplementedError() elif x.ndim == 3: rows, cols, channels = x.shape