Edge detection opencv - Laplacian

sobel operator the article said, Sobel operator is simulated first derivation, the greater the number of local guide explained the more violent transformation, the more likely the edge.

But if it continues to f '(t) derivative of it?

Can be found "at the edges" of the second derivative = 0. We can use this feature to find the edges of the image. Note that there is a problem, the second order derivative of 0. may be meaningless position

Laplacian derivation

Example solved in the x-direction:
first difference: f '(x) = f (x) - f (x - 1)
second order difference: f' '(x) = f' (x + 1) - f '( x) = (f (x + 1) - f (x)) - (f (x) - f (x - 1))
after simplification: f '' (x) = f (x - 1) - 2 f (x)) + f (x + 1)
extracted in front of coefficients: [1, -2, 1]

Similarly the y direction obtained coefficients [1, 2,1]

In this case, add up to get the Laplace matrix

opencv achieve

Laplacian api

Default ksize = 1, ksize = 3, and the effect is the same, it is used in the above-described Laplacian matrix of the original image deconvolution

What about specific filter that can function getDerivKernels get

dx, dy represents the number of first derivation.

def cal_filter(dx,dy,ksize):
    kx, ky=cv.getDerivKernels(dx, dy, ksize)
    print(kx)
    print(ky)
                                                                  
cal_filter(2,2,1)   
cal_filter(2,2,3) 
cal_filter(2,2,5)

Output
can be seen ksize = 1 and ksize = 3 is actually the same.

import cv2 as cv
def test():
    src = cv.imread("/home/sc/disk/keepgoing/opencv_test/sidetest.jpeg")
    src = cv.GaussianBlur(src, (3, 3), 0)
    gray = cv.cvtColor(src, cv.COLOR_BGR2GRAY)
    
    dst1 = cv.Laplacian(gray, -1,3)
    dst2 = cv.Laplacian(gray, -1,1)
    
    cv.imshow("origin",src)
    cv.imshow("dst1",dst1)
    cv.imshow("dst2",dst2)
    if 27 == cv.waitKey():
        cv.destroyAllWindows()

test()

Results are as follows:

laplace are relatively simple and sobel edge detection algorithm, the current commonly used is canny, behind the blog will be written.
When searching for a variety of application scenarios edge detection algorithm and found that most of the articles talk about how to achieve in the opencv and are copied each other to copy to. speak personally think that a good two link given below
https://blog.csdn.net/xiaojiegege123456/article/details/7714863
https://dsp.stackexchange.com/questions / 74 / what-factors-should -i-consider-in-choosing-an-edge-detection-algorithm

The second derivative of the gradation type may also be described mutation. In some cases, such as a uniform change in grayscale image, using only the first derivative may not find a boundary, then the second derivative can provide useful information. The second derivative is also more sensitive to noise, the solution is to smoothing the image, eliminate some noise, and then edge detection. However, the use of second derivative algorithm is based on information of the detected zero-crossing, the edge points obtained thus less conducive to subsequent processing and recognizing work

To summarize that: Laplace more sensitive to noise, but little change in the image gray edge detection operator is better effect Bisuobeier such as cattle and the tree of FIG gray conversion is not particularly strong.

The most commonly used is canny algorithm actually used . Bowen will do behind the introduction.

Guess you like

Origin www.cnblogs.com/sdu20112013/p/11611691.html