ImageItem bugfix
This commit is contained in:
parent
dcf45b03e2
commit
2a80205dd4
@ -309,11 +309,12 @@ class ImageItem(GraphicsObject):
|
|||||||
|
|
||||||
# if the image data is a small int, then we can combine levels + lut
|
# if the image data is a small int, then we can combine levels + lut
|
||||||
# into a single lut for better performance
|
# into a single lut for better performance
|
||||||
if self.levels is not None and self.levels.ndim == 1 and image.dtype in (np.ubyte, np.uint16):
|
levels = self.levels
|
||||||
|
if levels is not None and levels.ndim == 1 and image.dtype in (np.ubyte, np.uint16):
|
||||||
if self._effectiveLut is None:
|
if self._effectiveLut is None:
|
||||||
eflsize = 2**(image.itemsize*8)
|
eflsize = 2**(image.itemsize*8)
|
||||||
ind = np.arange(eflsize)
|
ind = np.arange(eflsize)
|
||||||
minlev, maxlev = self.levels
|
minlev, maxlev = levels
|
||||||
if lut is None:
|
if lut is None:
|
||||||
efflut = fn.rescaleData(ind, scale=255./(maxlev-minlev),
|
efflut = fn.rescaleData(ind, scale=255./(maxlev-minlev),
|
||||||
offset=minlev, dtype=np.ubyte)
|
offset=minlev, dtype=np.ubyte)
|
||||||
@ -327,8 +328,7 @@ class ImageItem(GraphicsObject):
|
|||||||
lut = self._effectiveLut
|
lut = self._effectiveLut
|
||||||
levels = None
|
levels = None
|
||||||
|
|
||||||
|
argb, alpha = fn.makeARGB(image.transpose((1, 0, 2)[:image.ndim]), lut=lut, levels=levels)
|
||||||
argb, alpha = fn.makeARGB(image.transpose((1, 0, 2)[:image.ndim]), lut=lut, levels=self.levels)
|
|
||||||
self.qimage = fn.makeQImage(argb, alpha, transpose=False)
|
self.qimage = fn.makeQImage(argb, alpha, transpose=False)
|
||||||
|
|
||||||
def paint(self, p, *args):
|
def paint(self, p, *args):
|
||||||
|
@ -250,6 +250,14 @@ def test_makeARGB():
|
|||||||
im2, alpha = pg.makeARGB(im1, lut=lut, levels=(512, 2**16-256))
|
im2, alpha = pg.makeARGB(im1, lut=lut, levels=(512, 2**16-256))
|
||||||
checkImage(im2, np.clip(np.linspace(257, 2, 256), 0, 255).astype('ubyte'), alpha, False)
|
checkImage(im2, np.clip(np.linspace(257, 2, 256), 0, 255).astype('ubyte'), alpha, False)
|
||||||
|
|
||||||
|
lut = np.zeros(2**16, dtype='ubyte')
|
||||||
|
lut[1000:1256] = np.arange(256)
|
||||||
|
lut[1256:] = 255
|
||||||
|
im1 = np.arange(1000, 1256).astype('uint16')[:, None]
|
||||||
|
im2, alpha = pg.makeARGB(im1, lut=lut)
|
||||||
|
checkImage(im2, np.arange(256).astype('ubyte'), alpha, False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# float data tests
|
# float data tests
|
||||||
im1 = np.linspace(1.0, 17.0, 256)[:, None]
|
im1 = np.linspace(1.0, 17.0, 256)[:, None]
|
||||||
|
Loading…
Reference in New Issue
Block a user