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?
Asked
Active
Viewed 181 times
0
-
This sounds like an assignment. Is it? Were you given instructions? – Retired Ninja Oct 01 '17 at 03:53
1 Answers
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.
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:

VC.One
- 14,790
- 4
- 25
- 57

Mark Setchell
- 191,897
- 31
- 273
- 432
-
Yea but I should implement the convolution method I can't use the method in the library. So i have to change the pixel values myself... I'm just not sure what value should I change is it spectrum or some other values? – Nathan Oct 01 '17 at 21:35
-
Mmmm... the spectrum is just the number of channels in the image, 1 for greyscale or 3 for colour. You'll need to write a `for_xy()` loop to do a convolution. – Mark Setchell Oct 02 '17 at 06:18