Edge detection
The general steps
canny operator
step
canny function
Color canny
#include<opencv2/opencv.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
using namespace cv;
int main()
{
Mat dst, edge, gray;
Mat src = imread("G://2.jpg");
Mat src1 = src.clone();
imshow("原始图", src);
dst.create(src1.size(), src1.type());
cvtColor(src1, gray, COLOR_BGR2GRAY);
blur(gray, edge, Size(3,3));
Canny(edge, edge, 3, 9, 3);
dst = Scalar::all(0);
src1.copyTo(dst, edge);
imshow("效果图",dst);
waitKey(0);
return 0;
}
copyTo function
image.copyTo (imageROI). Action is to copy the contents of the image pasted to the imageROI;
image.copyTo (imageROI, mask). Role of the mask image and overlapping the mask after the pixel value of 0 (black) corresponding to a point in the image point becomes transparent, leaving other points.
sobel operator
calculation process
Sobel function ()