I’m trying solve a challenging problem in C++ with the concepts I’m not familiar with.
I’m trying to apply a filter to a matrix. However like I said I’m quite new at this and after some investigation I’ve found this link where it shows applying a filter is basically a multiplication
However what confuses me that what if my filter is [0,1,0] and I have to apply it to a 5×5 matrix. How would I be able to do that?
EDIT:Second link really confused me. I am pretty much right now trying to decide the “application” process. If I follow the idea of creating a 3×3 matrix with only diagonal [0,1,0] am i going to apply it like in the second link or do I have to apply it to every single cell in matrix. Or if its really going to be a 1-D filter should I,again, apply it to every single cell or leave out the edges and corners?
I think the thing that’s being overlooked is that the multiplication is repeated for every element of the input array using subsets of the input data.
The GIMP example showed how to filter a 5×5 image using a 3×3 filter for a single pixel:
I’ve labelled one input pixel with a
@and its neighbors with-. You use the smaller matrix:Sum up the numbers in the resultant 3×3 array, and store that value into the new image, in place of the
@pixel.To take this to your example, when filtering a 5×5 image using a 3×1 filter:
You’ll use a smaller subset of the input array, to match your kernel;
Then, again, sum the numbers in the resultant array, and store that value into the new image in place of the
@pixel.