3. MAIN IDEA
The basic idea of blurring an image is that for each pixel, we average it with its
neighbour's and use a low-pass filter to reduce the amount of noise and detail in an
image.
Image blurring is used to make an image smooth in which edges of that image are not
observed.
By reducing the detail in an image we can more easily find objects that we are
interested in.
Furthermore, this allows us to focus on the larger structural objects in the image.
Most common in computer vision and image processing.
4. STEPS TO BLUR AN IMAGE
STEP 1: Retrieve the values of the centre pixel and its neighbours
STEP 2: In image Processing, we are manipulating one pixel at a time which means that
we are multiplying
STEP 3: Add them together
STEP 4: Divide by the amount of pixels we just added
STEP 5: Assign the resulting value to the centre pixel
5. CONVOLUTION
Convolution is simply the process
of taking a small matrix and
running it over all the pixels in an
image.
At every pixel, we’ll perform some
math operation involving the
values in the convolution matrix
and the values of a pixel and its
surroundings
This is done to determine the value for a
pixel in the output image.
6. GAUSSIAN BLUR
Imagine that this distribution is superimposed over a
group of pixels in an image.
It should be apparent looking at this graph, that if we
took a weighted average of the pixel’s values and the
height of the curve
This is, in essence, how Gaussian blur works.
TLDR: A Gaussian blur is applied by convolving the
image with a Gaussian function.
8. IMPLEMENTATION
We’ll need to create a separate output image.
We can’t modify the source image directly because changing the pixel
values will mess up the math for the adjacent pixel’s computation in the
next iteration.
Finally, we need to consider how we’ll handle the edges. If we were looking
at the very first pixel in an image, the kernel would extend beyond the
bounds of the image.
As a result, implementations will commonly ignore the outer most set of
pixels, duplicate the edge, or wrap the image around.
9. In our case, for ease of implementation, we’ll
ignore it pixels on the edges.
Let’s start with implementing the Gaussian
function. The first task is to identify reasonable
values for x, y, and σ.
While the kernel can technically be an arbitrary
size, we should scale σ in proportion to the kernel
size.