Converted image not displaying

30 views
Skip to first unread message

Abder-Rahman Ali

unread,
Jan 21, 2016, 6:46:10 AM1/21/16
to scikit-image

I'm trying to convert a color image to a grayscale image, as follows:


from skimage import io
from skimage.color import rgb2gray 
img = io.imread('baboon.png')
img_grayscale = rgb2gray(img)
io.imshow(img_grayscale)


The code works fine, but the image does not get displayed, why is that?


Thanks.

Emmanuelle Gouillart

unread,
Jan 21, 2016, 6:55:06 AM1/21/16
to scikit...@googlegroups.com
Did you try addind io.show() at the end of your script?

Cheers,
Emmanuelle

Himanshu Mishra

unread,
Jan 21, 2016, 6:55:13 AM1/21/16
to scikit...@googlegroups.com
Do  io.show() for the image to pop up. It's similar to the matplotlib drawing where you first draw and then show.

You can also use skimage.viewer.ImageViewer to view the image. Although, I actually don't know why simply imshow did not pop out the image in the viewer.



--
You received this message because you are subscribed to the Google Groups "scikit-image" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scikit-image...@googlegroups.com.
To post to this group, send email to scikit...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/2e444147-2d96-4100-87fd-e375fd737494%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Himanshu Mishra

Abder-Rahman Ali

unread,
Jan 21, 2016, 1:07:25 PM1/21/16
to scikit-image
Thanks a lot for your replies. The code that works for me looks as follows:

import skimage.io as io
from skimage.color import rgb2gray 
img = io.imread('baboon.png')
img_grayscale = rgb2gray(img)
show_grayscale = io.imshow(img_grayscale)
io.show()
Reply all
Reply to author
Forward
0 new messages