Some improvements on the canny edge detection algorithm

Source: Internet
Author: User

The traditional canny edge detection algorithm is an effective and relatively simple algorithm, which can get good results (refer to the implementation of canny edge detection algorithm). But the canny algorithm itself has some flaws that can be improved.

1. Canny edge detection The first step is to use Gaussian blur to remove the noise, but also smooth edges, so that the edge information is weakened, it is possible to omit some of the necessary edges in the subsequent steps, especially weak edges and isolated edges, may be eliminated in the double threshold and Unicom Calculation. It is natural to foresee that if the radius of Gaussian blur is increased, the smoothing of the noise is increased, but the edges of the resulting edge graph will be significantly reduced. Here still use Lena diagram as an example, maintain the canny algorithm high threshold value 100, low threshold value of 50, the Gaussian radius is 2,3,5 canny edge binary image as Follows. It is known that Gaussian blur blurs a lot of useful edge information, so how to select the Gaussian radius accurately is very important.

Gaussian radius 2 Gauss radius 3 Gauss radius 5

2. In the initial canny algorithm is the smallest 2x2 field used to calculate the gradient Amplitude. This method is sensitive to noise, and it is easier to detect pseudo-edges or missing true Edges. In the last algorithm implementation, the 3x3 Sobel gradient operator is actually used, which is a better choice.

3. The dual-valve value of the traditional canny algorithm is globally fixed, so the choice of double-valve size has a great impact on the final result, and some experience, such as choosing a low threshold value of 0.4 or 0.5 of the high THRESHOLD. however, after all, it is an empirical choice, and the determination of the threshold is still difficult to determine an optimal Value. and the different local areas of an image may require varying thresholds to pinpoint real edges, so the global threshold is less appropriate.

4. Traditional algorithms can still produce an edge with a width greater than 1, which does not reach a satisfactory high-precision single-point Response. That is, you need to continue refining the Edges.

Here are some things you can do to improve your Discussion.

Instead of Gaussian Blur

Noise is a high frequency signal, and the edge signal is also a high frequency signal. Since the Gaussian Blur does not differentiate all the high-frequency information blurred, The effect is naturally not satisfactory. Then naturally think of a variety of selective smoothing methods with reserved edges, which seems to be more appropriate here than the Gaussian blur, so let's try it Out. The basic idea of a smoothing method with reserved edges is not to allow all pixels in the domain to participate in the calculation of the smoothing method, but rather to set a threshold that only allows pixels with a difference in the grayscale of the center pixel to participate in the Calculation. So pixels that are too large for the center pixel are considered to have valid information, not noise, and do not participate in smoothing calculations, thus preserving these useful high-frequency signals, then the edge signal is naturally in the reserved range. The specific algorithm can refer to this article http://www.cnblogs.com/Imageshop/p/4694540.html, has been made very clear. Whether the mean is smooth, the median is smooth, the surface is blurred, you can refer to this algorithm to achieve selective BLUR.

After using selective blur with reserved edges instead of Gaussian blur, it can be found that the radius value of the fuzzy domain basically does not affect the result of canny detection, and the final result is only related to the selection of the threshold of fuzzy setting. The following is an example of mean ambiguity, canny detection of the high threshold value of 100 low threshold 50 unchanged, mean value of fuzzy threshold 30, different fuzzy radius results. In different domain radius, The final result is not very big.

Mean blur radius 2, threshold value 30 mean blur radius 5, threshold value 30 mean blur radius 15, threshold 30

While maintaining the fuzzy radius of 5 unchanged, using different threshold thresholds, the greater the threshold, that is, the more domain pixels involved in the fuzzy calculation, the last remaining edge is less.

Mean blur radius 5, threshold 40 mean blur radius 5, threshold 50

Relative to Gaussian blur, under the same radius, it can be seen that the application of the reserved edge function of the selective blur, can obviously retain more edge details, so that many relatively weak edge of the proud Retained.

Gradient operator Selection

For the calculation of the gradient in the algorithm, the gradient operator can have many Choices. I tried, if using a ladder operator, Robert crossover operator, They are 2x2 operators, to replace the sobel, to maintain a Gaussian blur radius of 2, high threshold 100 low threshold value of 50 unchanged, the results are as Follows. It is important to note that since both the one-step operator and the Robert operator are 2x2 operators, the gradient they calculate is less than the Sobel operator in Amplitude. Even with the same high and low thresholds, the final result is not comparable. therefore, referring to the amplitude of the Sobel operator, the x, y direction gradients of the 2x2 operator are multiplied by the corresponding multiples (4 times times), and finally Compared.

First order difference Robert Cross gradient Sobel operator

It can be seen that the final result of first order difference is the worst in the connectivity of the edge, the Robert operator is better, and the Sobel operator is the Best. Among these options, it seems that the Sobel operator is the best choice. In addition, Prewitt operators and 5x5sobel operators can be Used. Prewitt operators are also 3x3, with only different parameters, slightly inferior to the Sobel operator in smoothing Performance. In general, for example, on Lena graphs, the results of canny edge and the result of Sobel operator are not very different. 5x5sobel operators need to be stronger in smoothing performance.

Some improvements on the canny edge detection algorithm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.