Convolutional Kernels have already been researched upon by a lot of people but this blog contains everything I research upon, maybe for future use? So. Convolutions.
Convolutional Kernels are basically an array that slides over another array, the base array, and performs a specific mathematical operation on the values that the kernel encompasses over the array. The result is another array that has been convolved upon. Too hard to understand? Here’s my favourite gif.
In the gif, there’s an array(the darker one) sliding on top of the base array(blue) to form the resulting green array.
The values of the kernel array are made to óperate over the array and the mathematical array operation (addition, substraction, mean average) gives the output on the resulting array. This is convolution.
This is much more efficient than multiplying whole arrays together and greatly reduces processing time.
Why use Kernels
Kernels are used to implement whatever mathematical operation we want to on an array. The operation can be used to extract specific features from the base array, give weighted means and averages or make filters on an image! Yes. Like Snapchat and Instagram filters. Say you want that very aesthetic blur ( how is it aesthetic though) . You convolve a kernel filled with 1s of whichever size u want (higher is more computational time but possibly more accurate) and it’ll give u a mean blur of deviation 1. It’s an image. U did something on it and it looks different. That’s basically a filter right?
Filters on Images
Most people learn convolutions and kernels as part of the CNN tutorials. I say no. The AI and ML hype is getting to my nerves. I’ll rant on it in another post but for now, I’m gonna make my own filter. Bwahaha. Ground up (Imma use numpy. Not building that from scratch, I am nowhere near the people who made numpy). So. FILTERS ON IMAGES. WEEE. I’m sorry I’ll just start writing the code and explain it.
But first, a little note on what images are.
Images are basically arrays containing numbers, each number indicating how much of something is present in that pixel. Each sqaure in the array is a pixel. Images are stacks of these arrays. In simple terms, images are made of 3 channels with a 4th intensity or alpha channel(photoshop users, this is your opacity). R, G, B, and A are all arrays (2 dimensional). The size of the array is the resolution of the image. So a 1080p image is of size 1920×1080 (in the 16:9 ratio).
