Convolution Solution? Changing size and shape

Hellooo, I have a question.

I’m very much a beginner to Processing and I’m kind of struggling to figure everything out. For an art installation I’m making right now I’m using processing to hopefully make a visual that corresponds with a webcam and the viewers movements from the webcam.

Using the Convolution example on I have found something that I like. But seeing as I’m quite the novice at this I don’t understand every part of the code. In the example on the website I added my own image and really like the look. I was just wondering if the square you move with your mouse is able to be turned into an ellipse, and if the size can be changed. Or if the shape can be changed to something more organic?

Please if you have any ideas to answer my question I would love to hear it. I’m trying to figure this out as soon as possible so any tips are greatly appreciated.

Thank you very much! :heart::heart::heart:

Welcome to the forum!

With convolutions the matrix defines what happens to a pixel (and image). In the example code there is a high-pass filter.

float[][] matrix = { { -1, -1, -1 },
                     { -1,  9, -1 },
                     { -1, -1, -1 } };

It is possible to change the shape and size of the matrix, but you need to also figure out what values to use in the matrix. GIMP documentation has some examples of other convolution matrices. GIMP also has tool to test arbitrary convolution matrix (instruction on the same doc page). I believe that value 0 in convolution matrix means that pixel has no effect to the end result, so you can use that make other shapes. 3*3 convolution matrix is most commonly used, because you can do a whole lot of things with it and bigger matrices consume more processing power.

1 Like