Ask Your Question

Optimization of Canny edge detector

asked 2017-12-04 01:45:27 -0500

Canny edge detector works not very well for my task so I decided to play with its parameters, but it turned out to be problematic. If I set aperture to 9, the program aborts. To 5 - it hangs. Looks like it needs more than 5 minutes to process an image of moderate size. Any hints on what I can do with parameters of this function and what I can't?

edit retag flag offensive close merge delete


Add some images and an example code. Also give us some information what system you use and than we can help you ;)

matman gravatar imagematman ( 2017-12-05 11:59:07 -0500 )edit

I just wanted to understand the possible range of each parameter and how they affect performance. Canny() accepts only grey images, but taking color into account would substantially improve sensitivity. What functions can you recommend for edge detection on color pictures?

ya_ocv_user gravatar imageya_ocv_user ( 2017-12-06 04:11:29 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2017-12-06 03:56:46 -0500

The parameter of aperture is used for the Sobel derivatives which allow values 1, 3, 5, and 7. The function itself calculates rather quickly, but with values > 3 it produces hundreds of edges. I used it with other functions so the whole program worked over 20 minutes. Sobel returns a value for the first derivative of the smoothed input image so using values greater than 3 doesn't have much sense.

All in all, the opportunity for fine-tuning is to change 2 thresholds. Using this, it is possible to reveal the lost edges and to hide the undesired efficiently.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2017-12-04 01:45:27 -0500

Seen: 922 times

Last updated: Dec 06 '17