使用卷积执行图像过滤时,我到底应该改变什么?

时间:2022-09-11 10:36:18

So I'm supposed to write this image processing program using convolution. This is the header:CImg FilterImage(const CImg& image,const CImg& filter) and we can only access width, height, depth and spectrum. I understand how convolution works but I don't know what should I change. Should I change the spectrum? Also is it just one giant method? I'm very confused by the setup of this thing. Can anyone tell me what should I do?

所以我应该用卷积来编写这个图像处理程序。这是标题:CImg FilterImage(const CImg&image,const CImg&filter),我们只能访问宽度,高度,深度和光谱。我理解卷积是如何工作的,但我不知道应该改变什么。我应该更改频谱吗?它也只是一种巨大的方法吗?我很困惑这个东西的设置。谁能告诉我该怎么办?

1 个解决方案

#1


0  

Your question sounds confused. I think you are trying to use CImg although you haven't tagged it as such, to perform an image convolution.

你的问题听起来很混乱我认为您正在尝试使用CImg,尽管您没有标记它,以执行图像卷积。

So, I think you want something like this:

所以,我认为你想要这样的东西:

#include <iostream>
#include "CImg.h"
using namespace std;
using namespace cimg_library;

int main(int argc, char** const argv)
{
    // 9x9 simple box filter (all coefficients are 1)
    CImg<unsigned char> box(9,9,1,1,1);
    CImg<unsigned char> image("start.pgm");

    CImg<unsigned short> result;
    result=image.get_convolve(box);
    (image,result).display();
}

The start image is shown on the left and the box-filtered image on the right:

左侧显示起始图像,右侧显示框过滤后的图像:

使用卷积执行图像过滤时,我到底应该改变什么?

#1


0  

Your question sounds confused. I think you are trying to use CImg although you haven't tagged it as such, to perform an image convolution.

你的问题听起来很混乱我认为您正在尝试使用CImg,尽管您没有标记它,以执行图像卷积。

So, I think you want something like this:

所以,我认为你想要这样的东西:

#include <iostream>
#include "CImg.h"
using namespace std;
using namespace cimg_library;

int main(int argc, char** const argv)
{
    // 9x9 simple box filter (all coefficients are 1)
    CImg<unsigned char> box(9,9,1,1,1);
    CImg<unsigned char> image("start.pgm");

    CImg<unsigned short> result;
    result=image.get_convolve(box);
    (image,result).display();
}

The start image is shown on the left and the box-filtered image on the right:

左侧显示起始图像,右侧显示框过滤后的图像:

使用卷积执行图像过滤时,我到底应该改变什么?