opencv:图像卷积
卷积基本概念 C++代码实现卷积 #include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace std; int main(int argc, char** argv) { Mat src = imread("f:/images/lena.jpg"); if (src.empty()) { printf("Could not find the image!\n"); return -1; } namedWindow("input", WINDOW_AUTOSIZE); imshow("input", src); int h = src.rows; int w = src.cols; Mat result = src.clone(); for (int row = 1; row < h - 1; row++) { for (int col = 1; col < w - 1; col++) { // 3x3卷积核 int sb = src.at<Vec3b>(row, col)[0] + src.at<Vec3b>(row - 1, col - 1)[0] + src.at<Vec3b>(row - 1, col)[0] + src.at<Vec3b>(row - 1, col