mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-11 23:08:50 +08:00
Don't return an alpha channel if it's not present. Fix return type of as_grey
This commit is contained in:
@@ -107,11 +107,17 @@ def imread_qt(filename, as_grey=False):
|
||||
else:
|
||||
img = img.reshape((qtimg.height(), pixelsPerLine))
|
||||
img = img[:, :qtimg.width()]
|
||||
# Strip alpha channel if needed
|
||||
if bytesPerPixel == 4 and not qtimg.hasAlphaChannel():
|
||||
img = img[:, :, 0:3]
|
||||
if as_grey and bytesPerPixel > 1:
|
||||
# Stolen from fits_plugin
|
||||
# these are the values that wikipedia says are typical
|
||||
transform = numpy.array([ 0.30, 0.59, 0.11])
|
||||
return numpy.dot(img, transform)
|
||||
if img.shape[2] == 4:
|
||||
# these are the values that wikipedia says are typical
|
||||
transform = np.array([ 0.30, 0.59, 0.11, 0])
|
||||
else:
|
||||
transform = np.array([ 0.30, 0.59, 0.11])
|
||||
return np.dot(img, transform).astype('uint8')
|
||||
return img
|
||||
|
||||
if sip.SIP_VERSION >= 0x040c00:
|
||||
|
||||
Reference in New Issue
Block a user