JuliaImages/ImageEdgeDetection.jl

Detection of circles in image with measuring radius and center doesn't work

ashwani-rathee opened this issue · 1 comments

@zygmuntszpak When I was trying to use ImageEdgeDetection.jl with ImageFeatures.jl and tried to measure circular objects in image.came across the issue that hough_circle_gradient() doesn't work with Canny() and It shouldn't I think since old canny() is implemented very differently.Would we need a new implementation of hough transform?or should we stick with old canny() to get hough_circle_gradient() work?

Also faced issue that I had to manually tweak the Percentiles for high ,low ,spatial_scale especially with this image with extra white padded border,I felt it was some bug at first..then realized I had to set low above a certain value then it worked just fine...is there a method to automatically detect that specific low?

I had a brief look at hough_circle_gradient and as far as I can see it you should be able to use the ImageEdgeDetection.jl package to obtain the necessary inputs to that function.

The function wants:

  • img_edges = edges of the image
  • img_phase = phase of the gradient image

The detect_edges function should give you the output you need for img_edges. The second argument is asking for the edge orientations and you should be able to obtain them as follows:

using ImageFiltering
g₁, g₂ = imgradients(img, KernelFactors.sobel)
img_phase = detect_gradient_orientation(g₁, g₂,  OrientationConvention())

(I haven't tested this prior to writing this reply).

With regard to automatically detecting a suitable threshold for the low and high hysteresis, I don't think that there is an automatic way that works reliably for all possible images. Usually, these low and high values are fiddling parameters that need to be tuned to each problem domain. The use of percentiles already lifts the problem to a slightly higher level of abstraction, because the thresholds are set based on the distribution of edge magnitudes rather than raw values.

A path to more automation might involve using the HistogramThreshold.jl package on the edge magnitudes.