Long story short, I'm just simply trying to get a canny edged image of image.jpg
.
The documentation is very spotty so I'm getting very confused. If anyone can help that'd be greatly appreciated.
from scipy import misc
import numpy as np
from skimage import data
from skimage import feature
from skimage import io
im=misc.imread('image1.jpg')
edges1 = feature.canny(im)
...
And I'm getting this error
ValueError: The parameter `image` must be a 2-dimensional array
Can anyone explain how to create a 2D array from an image file? Thanks!
I suspect image1.jpg
is a color image, so im
is 3D, with shape (num_rows, num_cols, num_color_channels). One option is to tell imread
to flatten the image into a 2D array by giving it the argument flatten=True
:
im = misc.imread('image1.jpg', flatten=True)
Or you could apply canny
to just one of the color channels, e.g.
im = misc.imread('image1.jpg')
red_edges = feature.canny(im[:, :, 0])
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