[scikit-image] pixel value changes during reading image and showing images using skimage and matplotlib

wine lover winecoding at gmail.com
Sun Dec 11 01:46:04 EST 2016


Dear All,

I have a tif images, its type is float32, shape is (128*128) (a grayscale
image). All the pixel values are of range [0.0, 1.0]

 I am trying to read it using skimage and show it on screen using matplotlib
.

from skimage import ioimport matplotlib.pyplot as plt
output=io.imread(os.path.join(image_path,raw_image_name))print(output.dtype)print(output.shape)print(output.max())print(output.min())
plt.imshow(output)
plt.show()

The output image looks like color image instead of gray image as shown
originally. I attached the screenshot as the capture-1.jpg.

However, when I read the image using matplotlib instead,i.e.,
output=plt.imread(os.path.join(image_path,raw_image_name)). I found that
pixel value will become 255 and 0. The dtype is still float32. But when I
print output, the pixel values are either 0. or 255.

The output image will become black as shown in the second image
(capture-2.jpg). I am confused how does this work? My guess is that there
are some dtype changes happening during the reading image and showing
image,


Thanks,

Yuanyuan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20161211/83b37333/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Capture-1.JPG
Type: image/jpeg
Size: 44467 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20161211/83b37333/attachment-0002.jpe>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Capture_2.JPG
Type: image/jpeg
Size: 28963 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20161211/83b37333/attachment-0003.jpe>


More information about the scikit-image mailing list