这篇博客我们来学习图像卷积操作(基于opencv)
一、概念
图像卷积可以看成是一个窗口区域在另外一个大的图像上移动,对每个窗口覆盖的区域都进行点乘得到的值作为中心像素点的输出值。窗口的移动是从左到右,从上到下。窗口可以理解成一个指定大小的二维矩阵,里面有预先指定的值。
二、API函数
2.1 函数原型
void cv::blur(InputArray src,
OutputArray dst,
Size ksize,
Point anchor = Point(-1,-1),
int borderType = BORDER_DEFAULT
)
2.2 参数解释:
src 输入图像; 它可以有任意数量的通道,这些通道是独立处理的,但深度应该是CV_8U,CV_16U,CV_16S,CV_32F或CV_64F。
dst 输出与src相同大小和类型的图像。
ksize 模糊内核大小。
anchor 锚点; 默认值Point(-1,-1)表示锚点位于内核中心
borderType 用于外推图像外部像素的边框模式
2.3 代码演示
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int artc, char** argv) {
Mat src = imread("C:\\Users\\Dell\\Desktop\\picture\\opencv_tutorial\\opencv_tutorial\\data\\images\\lena.png");
if (src.empty()) {
printf("could not load image...\n");
return -1;