JuliaImages / Images.jl

An image library for Julia
http://juliaimages.org/
Other
535 stars 143 forks source link

Not so canny canny method? #914

Open JobJob opened 4 years ago

JobJob commented 4 years ago
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...)

zygmuntszpak commented 4 years ago

Thanks for reporting this. You are right, line 411 should be forwarding the threshold argument.

johnnychen94 commented 3 years ago

@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?

ashwani-rathee commented 3 years ago

thinning algorithms have also been implemented in ImageEdgeDetection.jl and they also need to be properly deprecated here in Images.jl I think

Devanik21 commented 7 months ago

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.

Devanik21 commented 7 months ago

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)))