plt.imread falls back to PIL/pillow for tiff reading which does not always handle high-bit depth tiffs well. I (as a lead mpl dev) would discourage `plt.imread` for 'production' use, there are many better options out there (ex skimage, http://imageio.github.io/ , http://soft-matter.github.io/pims/v0.3.3/ , http://imread.readthedocs.io/en/latest/ ).
Tom On Sun, Dec 11, 2016 at 2:04 PM wine lover <winecod...@gmail.com> wrote: > Hi Imanol, > > It works fine now, thanks for your suggestions. > > Regarding the second part of my question. If I read the image using > matlibplot instead of skimage, > i.e., output=plt.imread(os.path.join(image_path,raw_image_name)) > > I found that the pixel values of output were all changed, and they becomes > either 255. or 0. which causes the image shown as all black. What are the > possible reasons for plt.imread. Thanks. > > Yuanyuan > > On Sun, Dec 11, 2016 at 4:54 AM, Imanol Luengo < > imanol.lue...@nottingham.ac.uk> wrote: > > Dear Yuanyuan, > > The reason why you are looking at a *color* image is due to the colormaps: > > http://matplotlib.org/users/colormaps.html > > The default colormap (to map from numbers to colors) is not grayscale, as > matplotlib is not primarly focus on images, and grayscale is not an > *adequate* colormap to represent other types of plots. > > To properly visualize your image specify a colormap to the plot function: > > plt.imshow(output, 'gray') > > Cheers, > > Imanol > > On 11/12/16 06:46, wine lover wrote: > > 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 > > > _______________________________________________ > scikit-image mailing > listscikit-image@python.orghttps://mail.python.org/mailman/listinfo/scikit-image > > > > > This message and any attachment are intended solely for the addressee > and may contain confidential information. If you have received this > message in error, please send it back to me, and immediately delete it. > > Please do not use, copy or disclose the information contained in this > message or in any attachment. Any views or opinions expressed by the > author of this email do not necessarily reflect the views of the > University of Nottingham. > > This message has been checked for viruses but the contents of an > attachment may still contain software viruses which could damage your > computer system, you are advised to perform your own checks. Email > communications with the University of Nottingham may be monitored as > permitted by UK legislation. > > > _______________________________________________ > scikit-image mailing list > scikit-image@python.org > https://mail.python.org/mailman/listinfo/scikit-image > > > _______________________________________________ > scikit-image mailing list > scikit-image@python.org > https://mail.python.org/mailman/listinfo/scikit-image >
_______________________________________________ scikit-image mailing list scikit-image@python.org https://mail.python.org/mailman/listinfo/scikit-image