【发布时间】:2016-11-21 12:25:38
【问题描述】:
我使用 OpenCV Blur
得到了我的预期结果void blur()
{
blur(image1, image2, cv::Size(3, 3));
imshow("Orginal", image1);
imshow("Filtered", image2);
waitKey(0);
}
我还从 OpenCV: Understanding Kernel
但我想学习如何在不使用 OpenCV 功能的情况下进行过滤,但我在理解 将图像与某些内核卷积时遇到了一些问题
来自https://en.wikipedia.org/wiki/Kernel_(image_processing)
我尝试使用我目前所了解的知识,并
这是我的代码(“ 3x3 矩阵 ),但accumulator = image1.at<Vec3b>(x, y) * kernelarray[x + k][y + l]; 出现错误
Mat image1 = imread("Balloon.jpg", CV_LOAD_IMAGE_ANYCOLOR);
void filter(Mat image1)
{
const int kernelWidth = 3;
const int kernelHeight = 3;
float kernelarray[kernelWidth][kernelHeight];
int accumulator;
for (int x = 0;x < image1.rows;x++)
for (int y = 0; y < image1.cols;y++) {
accumulator = 0;
for (int k = 0;k < 3;k++)
{
for (int l = 0;l < 3;l++)
{
accumulator = image1.at<Vec3b>(x, y) * kernelarray[x + k][y + l];
}
image1.at<Vec3b>(x, y) = accumulator;
}
}
}
我应该怎么做才能获得我想要的预期结果?
【问题讨论】:
标签: c++ image opencv image-processing convolution