Canny边缘检测

#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;
}

Canny边缘检测_第1张图片

void cvCanny
(
    const CvArr* image,
    CvArr* edges,
    double threshold1,
    double threshold2,
    int aperture_size = 3
);
/*
    const CvArr* image:输入图像
    CvArr* edges:输出边缘图像
    double threshold1:第一个阈值
    double threshold2:第二个阈值
    int aperture_size = 3:Sobel算子内核大小
*/
void Canny
(
    InputArray image, 
    OutputArray edges, 
    double threshold1, 
    double threshold2, 
    int apertureSize=3, 
    bool L2gradient=false 
);
/*
    InputArray image:输入图像
    OutputArray edges:输出边缘图像
    double threshold1:第一个阈值
    double threshold2:第二个阈值
    int apertureSize = 3:Sobel算子内核大小
*/

你可能感兴趣的:(OpenCV&&QT)