I have raster with one band and I would like to do edge detection with Canny edge filter.
This is my raster:
I have opened it with rasterio and covert it into array :
img=srs.open("raster.tif")
array=img.read()
Then i'm trying to apply the Canny filter as following (based on this: https://scikit-image.org/docs/dev/auto_examples/edges/plot_canny.html):
# Compute the Canny filter for two values of sigma
edges1 = feature.canny(array)
edges2 = feature.canny(array,sigma=3)
but it fails with this error:
ValueError: The parameter
image
must be a 2-dimensional array
I read that this can happpen if my image is not in grey scale, but I have shown it as grey scale:
show((img,1),cmap='Greys_r')
so I tried to checl what is my array type:
type(array)
>>>numpy.ndarray
so I have no idea why I get this error message saying the image is not 2 dimensoinal as it is 1 band with X and Y axis.
My end goal - to be able to apply Canny edge on my image and to understand why I get this error