Steps to download requirements below:
sudo apt-get install libopencv-dev python-opencv
on your terminal. p>
Edge detection principle strong >
Edge detection involves mathematical methods to find the points in an image where the brightness of the pixels changes distinctly.
Note. In computer vision, the transition from black to white is considered a positive slope, and the transition from white to black — negative.
Derived image calculation strong>
A digital image is represented by a matrix that stores the RGB / BGR / HSV value (which color space the image belongs to) of each pixel in rows and columns.
The derivative of the matrix is calculated by an operator called the Laplacian . To compute the Laplacian, you will need to compute the first two derivatives, called Sobel derivatives, each of which accounts for changes in the gradient in a particular direction: one horizontal, the other vertical.
Ratio = 11 — 2- 2- 2- 2- 2 = 3
Offset = 0
Weighted sum = 124 * 0 + 19 * (- 2) + 110 * (- 2) + 53 * 11 + 44 * (- 2) + 19 * 0 + 60 * (- 2) + 100 * 0 = 117
O [4,2] = (117/3) + 0 = 39
So at the end, to get the Laplacian (approximation), we will need to combine the two previous results (Sobelx and Sobely) and save it in Laplacians.
cv2.Sobel (original_image, ddepth, xorder, yorder, kernelsize)
where the first parameter is — original image, second parameter — depth of the target image. When ddepth = -1 / CV_64F, the destination image will have the same depth as the source. The third parameter — this is the order of the derivative of x. The fourth parameter — this is the order of the derivative y. When calculating Sobelx, we will set xorder to 1 and yorder to 0, while when calculating Sobly, the case will be the opposite. The last parameter — this is the size of the extended Sobel kernel; it should be 1, 3, 5 or 7.
cv2.Laplacian (frame, cv2.CV_64F) pre>
first parameter — the original image, and the second parameter — depth of the target image. When depth = -1 / CV_64F, the final image will have the same depth as the original image.
Applications for edge detection