Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scikit-image saves binary image as completely black image

So, I am trying to get binary image with scikit-image and save it on disk with the following code:

gray = color.rgb2gray(img)
thresh = filters.threshold_otsu(gray)
binary = gray >= thresh
io.imsave("./testout/" + img_name, binary)

When I do io.imshow(binary), I get what I expected. But the imsave() return to me completely black image, as if it turn both True and False values into (0,0,0) in rgb or something.

So what is the right way to do it?

like image 530
kuzkokov Avatar asked Dec 18 '22 18:12

kuzkokov


1 Answers

from skimage import img_as_uint
# ...
io.imsave("./testout/" + img_name, img_as_uint(binary))

This seems to work, but I'm not sure it's the best way to do it.

Also, there's an issue opened on scikit-image repo: https://github.com/scikit-image/scikit-image/issues/1623

like image 184
bbogdan Avatar answered Dec 21 '22 11:12

bbogdan