I am trying to use scipy to do erosion and dilation of an image. It seems pretty straightforward using scipy -> binary_erosion / dialation
. However, the output is n
You have two problems: as noted in the comment by @theta, binary ops expect input consisting only of 0 and 1. The second issue is the nd
in ndimage
--- you supply in an array of shape (nx, ny, 3)
. The last length-3 axis is considered to be a third spatial dimension, not the three color channels.
I was using the binary erosion instead of the grey erosion array. I converted the original image to greyscale by using flatten=true
like so:
im = scipy.misc.imread('flower.png', flatten=True).astype(np.uint8)
then called:
im1 = ndimage.grey_erosion(im, size=(15,15))
And got a nicely eroded picture, although it is greyscale.