learning opencv3第一章

canny边缘检测算法,需要把RGB图片转成灰度图片,用如下命令

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

 

整个算法流程如下: 

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

效果如下

learning opencv3第一章_第1张图片

  

你可能感兴趣的:(learning opencv3第一章)