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
|
||||
# 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:
|
||||
eflsize = 2**(image.itemsize*8)
|
||||
ind = np.arange(eflsize)
|
||||
minlev, maxlev = self.levels
|
||||
minlev, maxlev = levels
|
||||
if lut is None:
|
||||
efflut = fn.rescaleData(ind, scale=255./(maxlev-minlev),
|
||||
offset=minlev, dtype=np.ubyte)
|
||||
@ -327,8 +328,7 @@ class ImageItem(GraphicsObject):
|
||||
lut = self._effectiveLut
|
||||
levels = None
|
||||
|
||||
|
||||
argb, alpha = fn.makeARGB(image.transpose((1, 0, 2)[:image.ndim]), lut=lut, levels=self.levels)
|
||||
argb, alpha = fn.makeARGB(image.transpose((1, 0, 2)[:image.ndim]), lut=lut, levels=levels)
|
||||
self.qimage = fn.makeQImage(argb, alpha, transpose=False)
|
||||
|
||||
def paint(self, p, *args):
|
||||
|
@ -249,6 +249,14 @@ def test_makeARGB():
|
||||
lut = (np.arange(512, 2**16)[::-1] // 256).astype('ubyte')
|
||||
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)
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user