#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
/**
*opencv自带的掩膜操作API
*/
int test2()
{
Mat img1, img2, img3;
img1 = imread("D://images//4.jpg");
if (!img1.data)
{
cout << "图片不存在" << endl;
return -1;
}
namedWindow("win1", CV_WINDOW_AUTOSIZE);
imshow("win1", img1);
Mat kernel = (Mat_<char>(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
filter2D(img1,img2,img1.depth(),kernel);
namedWindow("win2", CV_WINDOW_AUTOSIZE);
imshow("win2", img2);
//imwrite("6-2.jpg",img2);
}
int main()
{
int k2 = test2();
waitKey(0);
return 0;
}