Images.jl
Images.jl copied to clipboard
Not so canny canny method?
img = rand(RGB{N0f8}, 100, 100)
canny(img, (Percentile(80), Percentile(20)))
Gives a
ERROR: MethodError: no method matching canny(::Array{Gray{Normed{UInt8,8}},2})
Stacktrace:
[1] canny(::Array{RGB{Normed{UInt8,8}},2}, ::Tuple{Percentile{Int64},Percentile{Int64}}) at Images/7FSUM/src/edge.jl:410
Seems this code just needs to forward the threshold
argument:
https://github.com/JuliaImages/Images.jl/blob/3951d87ab2ccb06b7b854b42908504e9fa0e7dd9/src/edge.jl#L410-L411
i.e. canny(convert(Array{Gray}, img), threshold, args...)
though a warning suggests that maybe it should be canny(Gray.(img), threshold, args...)
Thanks for reporting this. You are right, line 411 should be forwarding the threshold argument.
@zygmuntszpak Given that ImageEdgeDetection already implements Canny
, what's the current status of this issue? My guess is that we only need to properly deprecate the old canny
in src/edge.jl
in favor of ImageEdgeDetection
, and then this issue gets solved?
thinning algorithms have also been implemented in ImageEdgeDetection.jl and they also need to be properly deprecated here in Images.jl I think
To fix the error you're encountering with the canny function, you need to convert the image to grayscale before applying the Canny edge detection algorithm. Here are steps-
Convert the RGB image to grayscale. Apply the Canny edge detection algorithm to the grayscale image.
#try this code, it can fix the error using Images using ImageFiltering img = rand(RGB{N0f8}, 100, 100) gray_img = Gray.(img)
canny_img = canny(gray_img, (Percentile(80), Percentile(20)))