learning opencv3 chapter 1

canny edge detection algorithm, you need to convert RGB images to grayscale images, use the following command

cv::cvtColor( img_rgb, img_gry, cv::COLOR_BGR2GRAY);

 

The entire algorithm flow is as follows: 

#include <opencv2/opencv.hpp>
    int main( int argc, char** argv ) {
    cv::Mat img_rgb, img_gry, img_cny;
    cv::namedWindow( "Example Gray", cv::WINDOW_AUTOSIZE );
    cv::namedWindow( "Example Canny", cv::WINDOW_AUTOSIZE );
    img_rgb = cv::imread( argv[1] );
    cv::cvtColor( img_rgb, img_gry, cv::COLOR_BGR2GRAY);
    cv::imshow( "Example Gray", img_gry );
    cv::Canny( img_gry, img_cny, 10, 100, 3, true );
    cv::imshow( "Example Canny", img_cny );
    cv::waitKey(0);
}

The effect is as follows

  

Guess you like

Origin blog.csdn.net/Gussss/article/details/89351382