I am learning about the Convolution Matrix, and I understand how they work, but I don’t understand how to know before hand what the output of a Matrix will look like. For example lets say I want to add a blur to an image, I could guess 10,000+ different combinations of numbers before I get the correct one.
I do know though that this formula will give me a blur effect, but I have no idea why.
float[] sharpen = new float[] {
1/9f, 1/9f, 1/9f,
1/9f, 1/9f, 1/9f,
1/9f, 1/9f, 1/9f
};
Can anyone either explain to me how this works or point me to some article, that explains this? I would like to know before hand what a possible output of the matrix will be without guessing.
Basically I would like to know why do we put that number in the filed, and why not some other number?
This link that explains how the convolution matrix works with a simple example.
The reason the matrix you have in your question blurs the image is because each pixel becomes an average of all its surrounding pixels. In other words, the pixel that’s in the center of the action area has its new value equal to the following formula:
The new value is 1/9th of 9 pixels (including the original pixel value) which turns out to be an “average” value for the 3×3 square operated on by the matrix. This “average” effect creates the blur that you see after applying the matrix.
Picking values for a convolution matrix all depends on what effect you want to achieve. Keep in mind that the matrix is applied to the original image and the new pixel value is copied over to the destination image. This means that the new values don’t factor into the application of the matrix on neighboring pixels…it’s only the original values that get fed into the matrix.