Reputation: 159
I'm trying to save a sci-kit image, but I'm getting the error:
ValueError: Image is not numeric, but ndarray.
Code:
from skimage import *
import skimage.io
import skimage.morphology as morphology
def loadImage(f):
return skimage.img_as_float(skimage.io.imread(f))
img = img_as_bool(loadImage("images/metric_map_processed.PNG"))
imgSk = morphology.medial_axis(img)
skimage.io.imsave("medial.png", imgSk)
According to the docs, the passed in array should be a ndarray, so why am I getting an error?
Upvotes: 3
Views: 5657
Reputation: 1804
The problem is that pixel type in png
is uint8. And when you apply img_as_bool
you get boolean array. And this mismatch of type generate error.
You need to convert it to uint8
. As suggest Alex use img_as_uint
function.
Upvotes: 1
Reputation: 159
Just realised that my image was being converted to binary
Replacing
skimage.io.imsave("medial.png", imgSk)
with
skimage.io.imsave("medial.png", img_as_uint(imgSk))
worked for me
Upvotes: 3