#include<opencv2\opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
Mat src;
src = imread("C:/Users/89899/Desktop/th.jpg");
if (src.empty()) {
cout << "there is no image " << endl;
return -1;
}
namedWindow("001", CV_WINDOW_AUTOSIZE);
imshow("001", src);
/*src = Scalar(127, 0, 255);
namedWindow("003", CV_WINDOW_AUTOSIZE);
imshow("003", src);*/
/*Mat dst;
dst = Mat(src.size(), src.type());
dst = Scalar(127, 0, 255);//红蓝绿,三个位置。可以创建纯色图像。
namedWindow("002", CV_WINDOW_AUTOSIZE);
imshow("002", dst);*/
/*Mat dst;
dst = src.clone();//clone生成完全一致的图片
namedWindow("002", CV_WINDOW_AUTOSIZE);
imshow("002", dst);*/
/*Mat dst;
src.copyTo(dst);//将src拷贝到dst中
namedWindow("002", CV_WINDOW_AUTOSIZE);
imshow("002", dst);*/
Mat dst;
namedWindow("output", CV_WINDOW_AUTOSIZE);
/*cvtColor(src, dst, CV_BGR2BGRA);//CV_BGR2GRAY将第二位置的图像转换为灰度图。
cout << "the channel of the input image is" << src.channels() << endl;
cout << "the channel of the output image is " << dst.channels() << endl;*/
Mat csrc;
Mat kernel = (Mat_<float>(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
filter2D(src, csrc,-1,kernel);
imshow("output", csrc);
waitKey(0);
return 0;
}
Opencv_C++(2)
猜你喜欢
转载自blog.csdn.net/qq_38436175/article/details/103759202
今日推荐
周排行