theory :

In the second derivative , The value at the maximum change is 0, That is, the edge is zero , Calculation by second derivative , According to this theory, we can calculate the second derivative of the image , Extract edge .

Laplance operator
Second derivative I won't , don't worry -> Laplace operator (Laplanceoperator)
Opencv Relevant information has been provided APl- cv::Laplance

Processing flow :

Gaussian blur - De noise GaussianBlur()

Convert to grayscale image cvtColor()
Laplace - Second derivative calculation Laplacian()

Take absolute value convertScaleAbs()
Display results

code :
#include<opencv2/opencv.hpp> #include<iostream> using namespace cv; int
main(int argc, char** argv) { Mat src, dst; src =
imread("C:/Users/ThinkPad/Desktop/1.PNG"); if (!src.data) { printf("could not
find"); return -1; } namedWindow("demo", cv::WINDOW_AUTOSIZE); imshow("demo",
src); Mat gray_src, edge_image; // Gaussian blur GaussianBlur(src, dst, Size(3, 3), 0,
0); // Convert to grayscale cvtColor(dst, gray_src, COLOR_BGR2GRAY); // Laplace operation
Laplacian(gray_src, edge_image, CV_16S, 3); // Absolute value conversion convertScaleAbs(edge_image,
edge_image); // Process edge image threshold(edge_image, edge_image, 0, 255, THRESH_OTSU |
THRESH_BINARY); imshow("final result", edge_image); waitKey(0); return 0; }
Laplace operation without processing , You can see that the noise is a little serious . 

add to threshold After processing :

threshold(edge_image, edge_image, 0, 255, THRESH_OTSU | THRESH_BINARY);

 

Technology
©2019-2020 Toolsou All rights reserved,
C++ of string of compare usage Python Study notes ( one )evo Tool usage problems ——Degenerate covariance rank, Umeyama alignment is not possibleRISC-V_GD32VF103-TIMER0 timer interrupt java Array subscript variable _Java Basic grammar : array be based on stm32 Control four-wheel trolley motor drive ( one ) be based on redis Design of liking function Software engineering career planning mysql Query random data by conditions _MySQL Random query of several qualified records centos7 install RabbitMq