Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not so canny canny method? #914

Open
JobJob opened this issue Sep 7, 2020 · 5 comments
Open

Not so canny canny method? #914

JobJob opened this issue Sep 7, 2020 · 5 comments
Labels

Comments

@JobJob
Copy link

JobJob commented Sep 7, 2020

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:

Images.jl/src/edge.jl

Lines 410 to 411 in 3951d87

canny(img::AbstractMatrix, threshold::Tuple{N,N}, args...) where {N<:Union{NumberLike,Percentile{NumberLike}}} =
canny(convert(Array{Gray}, img), args...)

i.e. canny(convert(Array{Gray}, img), threshold, args...) though a warning suggests that maybe it should be canny(Gray.(img), threshold, args...)

@JobJob JobJob changed the title Not so canny canny method Not so canny canny method? Sep 7, 2020
@zygmuntszpak
Copy link
Member

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

@johnnychen94
Copy link
Member

johnnychen94 commented Mar 28, 2021

@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
Copy link
Member

ashwani-rathee commented Mar 28, 2021

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

@Devanik21
Copy link

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants