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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With