def UpdateImage(self, axis, position):
object = self.object
idx = position - 1
if axis == 1:
imagedata = numpy.array(object[idx,:,:])
elif axis == 2:
imagedata = numpy.array(object[:,idx,:])
else:
imagedata = numpy.array(object[:,:,idx])
imagedata[imagedata < 1e-6] = 1.0
imagedata = numpy.log(imagedata)
imagedata = imagedata - imagedata.min()
if imagedata.max() > 0:
imagedata = (255.0/imagedata.max())*imagedata
else:
imagedata = 255.0*imagedata
imagedatalow = numpy.uint8(imagedata)
self.impil = Image.fromarray(imagedatalow, 'L').resize((self.sx,self.sy))
if IsNotWX4():
self.imwx = wx.EmptyImage( self.impil.size[0], self.impil.size[1] )
else:
self.imwx = wx.Image( self.impil.size[0], self.impil.size[1] )
self.imwx.SetData( self.impil.convert( 'RGB' ).tobytes() )
if IsNotWX4():
bitmap = wx.BitmapFromImage(self.imwx)
else:
bitmap = wx.Bitmap(self.imwx)
self.bmp = bitmap
self.image.SetBitmap(bitmap)
self.Refresh()
self.Layout()
评论列表
文章目录