#include
#include
#include
using namespace cv;
int main()
{
Mat srcImage = imread("cannyDetection.jpg");
namedWindow("【原始图】Canny边缘检测");
namedWindow("【灰度图】Canny边缘检测");
namedWindow("【效果图】Canny边缘检测");
imshow("【原始图】Canny边缘检测", srcImage);
Mat dstImage;
Mat edge;
Mat grayImage;
dstImage.create(srcImage.size(), srcImage.type());
cvtColor(srcImage, grayImage, COLOR_BGR2GRAY);
blur(grayImage, edge, Size(3, 3));
Canny(edge, edge, 3, 9, 3);
imshow("【灰度图】Canny边缘检测", grayImage);
imshow("【效果图】Canny边缘检测", edge);
waitKey(0);
return 0;
}
void cvCanny
(
const CvArr* image,
CvArr* edges,
double threshold1,
double threshold2,
int aperture_size = 3
);
void Canny
(
InputArray image,
OutputArray edges,
double threshold1,
double threshold2,
int apertureSize=3,
bool L2gradient=false
);