1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #include<iostream> #include<opencv2/opencv.hpp> using namespace cv; using namespace std; int main() { Mat image1, output_image; image1 = imread("lena.png"); if (image1.empty()) { cout << "读取错误" << endl; return -1; } Mat kernel = (Mat_<char>(3,3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
filter2D(image1, output_image, image1.depth(), kernel);
imshow("image1", image1); imshow("output_image", output_image); waitKey(0); return 0; }
|