- fixed ImageItem handling of rgb images
- fixed makeARGB re-ordering of color channels
This commit is contained in:
parent
bd2330af9f
commit
71ee4deb84
@ -783,25 +783,6 @@ def makeARGB(data, lut=None, levels=None, scale=None, useRGBA=False):
|
|||||||
if levels is not None and not isinstance(levels, np.ndarray):
|
if levels is not None and not isinstance(levels, np.ndarray):
|
||||||
levels = np.array(levels)
|
levels = np.array(levels)
|
||||||
|
|
||||||
## sanity checks
|
|
||||||
#if data.ndim == 3:
|
|
||||||
#if data.shape[2] not in (3,4):
|
|
||||||
#raise Exception("data.shape[2] must be 3 or 4")
|
|
||||||
##if lut is not None:
|
|
||||||
##raise Exception("can not use lookup table with 3D data")
|
|
||||||
#elif data.ndim != 2:
|
|
||||||
#raise Exception("data must be 2D or 3D")
|
|
||||||
|
|
||||||
#if lut is not None:
|
|
||||||
##if lut.ndim == 2:
|
|
||||||
##if lut.shape[1] :
|
|
||||||
##raise Exception("lut.shape[1] must be 3 or 4")
|
|
||||||
##elif lut.ndim != 1:
|
|
||||||
##raise Exception("lut must be 1D or 2D")
|
|
||||||
#if lut.dtype != np.ubyte:
|
|
||||||
#raise Exception('lookup table must have dtype=ubyte (got %s instead)' % str(lut.dtype))
|
|
||||||
|
|
||||||
|
|
||||||
if levels is not None:
|
if levels is not None:
|
||||||
if levels.ndim == 1:
|
if levels.ndim == 1:
|
||||||
if len(levels) != 2:
|
if len(levels) != 2:
|
||||||
@ -814,16 +795,6 @@ def makeARGB(data, lut=None, levels=None, scale=None, useRGBA=False):
|
|||||||
else:
|
else:
|
||||||
print(levels)
|
print(levels)
|
||||||
raise Exception("levels argument must be 1D or 2D.")
|
raise Exception("levels argument must be 1D or 2D.")
|
||||||
#levels = np.array(levels)
|
|
||||||
#if levels.shape == (2,):
|
|
||||||
#pass
|
|
||||||
#elif levels.shape in [(3,2), (4,2)]:
|
|
||||||
#if data.ndim == 3:
|
|
||||||
#raise Exception("Can not use 2D levels with 3D data.")
|
|
||||||
#if lut is not None:
|
|
||||||
#raise Exception('Can not use 2D levels and lookup table together.')
|
|
||||||
#else:
|
|
||||||
#raise Exception("Levels must have shape (2,) or (3,2) or (4,2)")
|
|
||||||
|
|
||||||
prof.mark('1')
|
prof.mark('1')
|
||||||
|
|
||||||
@ -885,7 +856,7 @@ def makeARGB(data, lut=None, levels=None, scale=None, useRGBA=False):
|
|||||||
imgData[..., i] = data[..., 0]
|
imgData[..., i] = data[..., 0]
|
||||||
else:
|
else:
|
||||||
for i in range(0, data.shape[2]):
|
for i in range(0, data.shape[2]):
|
||||||
imgData[..., order[i]] = data[..., order[i]]
|
imgData[..., i] = data[..., order[i]]
|
||||||
|
|
||||||
prof.mark('5')
|
prof.mark('5')
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ class ImageItem(GraphicsObject):
|
|||||||
#print lut.shape
|
#print lut.shape
|
||||||
#print self.lut
|
#print self.lut
|
||||||
|
|
||||||
argb, alpha = fn.makeARGB(self.image.T, lut=lut, levels=self.levels)
|
argb, alpha = fn.makeARGB(self.image.transpose((1, 0, 2)[:self.image.ndim]), lut=lut, levels=self.levels)
|
||||||
self.qimage = fn.makeQImage(argb, alpha, transpose=False)
|
self.qimage = fn.makeQImage(argb, alpha, transpose=False)
|
||||||
prof.finish()
|
prof.finish()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user