opencv
#include <opencv2/opencv.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/highgui/highgui.hpp> #include <iostream> using namespace cv; using namespace std; int main(int argc, char** argv) { Mat src = imread("C:\\Users\\Administrator\\Desktop\\0001.jpg"); if (src.empty()) { cout << "open pic wrong" << endl; return -1; } /*namedWindow("opencv window", CV_WINDOW_AUTOSIZE); imshow("opencv demo", src); namedWindow("output window", CV_WINDOW_AUTOSIZE); Mat output_image; cvtColor(src, output_image, CV_BGR2GRAY); imshow("output window", output_image); imwrite("pic.tif", output_image); */ imshow("原始图", src); //将原始图转为灰度图 Mat edge, grayImage; cvtColor(src, grayImage, CV_BGR2GRAY); //降噪 blur(grayImage, edge, Size(3, 3)); //用canny算子 Canny(edge, edge, 3, 9, 3); //显示效果图 imshow("效果图", edge); waitKey(0); return 0; }
Aiden的技术屋 文章被收录于专栏
虽然还是个菜鸟,但是总有一天会长大,翱翔于天空,热爱技术