# Image Convolution

Image Convolution
Field: Other
Image Created By: [[Author:| ]]

Image Convolution

Image Convolution is the process of applying a filter to images

# Basic Description

Images can be convolved by applying a function to each pixel of the image. Usually, this function is precalculated inside a small two dimensional array called a kernel.

# A More Mathematical Explanation

Most generally, the convolution of two functions f and g is defined as the following: '"`UNIQ--math- [...]

Most generally, the convolution of two functions f and g is defined as the following: $(f * g)(x,y) = \sum_{v=-\infty}^{\infty} \sum_{u=-\infty}^{\infty} f(x,y) g(x - u,y - v)$ In this formula $f(x,y)$ is a function that represents the image, and $g(x,y)$ is the kernel. In practical situations, the kernel is only defined over a finite set of points, so we can modify our definition as follows: $(f * g)(x,y) = \sum_{v=-h}^{h} \sum_{u=-w}^{w} f(x,y) g(u,v)$ where $2w + 1$ is the width of the kernel and $2h + 1$ is the height of the kernel. To convolve an image, this formula is evaluated at every point in the image. The following is pseudocode to convolve an image:

for y from 0 to imageHeight
for x from 0 to imageWidth
sum := 0;
for v from -kernelHeight to kernelHeight
for u from -kernelWidth to kernelWidth
sum := sum + f( x, y ) * g( u, v );
h( x, y ) := sum;