懒了,就这样吧
#include <opencv2/opencv.hpp>
#include <stdio.h>
#include <stdlib.h>
using namespace cv;
using namespace std;
char file[] = "1.jpg";
int main(int argc, char** argv)
{
Mat img = imread(file, -1);
pyrDown(img, img, Size(img.cols/2, img.rows/2));
imshow("1",img);
Mat gray, canny, final;
//转灰度 注意输入图像一定是8位灰度图像
cvtColor(img, gray, CV_BGR2GRAY);
//candy计算
Canny(img, canny, 60, 150, 3, false);
imshow("canny",canny);imwrite("canny.jpg",canny);
final.create(img.size(), img.type());
img.copyTo(final, canny);
imshow("final", final);imwrite("final.jpg", final);
waitKey();
return 1;
}
原图
gray
canny
final