0% found this document useful (0 votes)
6 views27 pages

Convolutionniuhiu Siusd

Uploaded by

jajilima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views27 pages

Convolutionniuhiu Siusd

Uploaded by

jajilima
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Image Formation

Image
• Digital Images are electronic snapshots
taken of a scene or scanned from
documents, such as photographs,
manuscripts, printed texts, and artwork.
• The digital image is sampled and mapped
as a grid of dots or picture elements
(pixels).
• Each pixel is assigned a tonal value
(black, white, shades of gray or color),
which is represented in binary code.
Image formation
The concept of pixel
• Pixel is the smallest element of an image. Each pixel
correspond to any one value.
• In an 8-bit gray scale image, the value of the pixel
between 0 and 255.
• The value of a pixel at any point correspond to the
intensity of the light photons striking at that point. Each
pixel store a value proportional to the light intensity at
that particular location.
Image convolution filtering
• Image filtering, in the context of computer vision, refers to a
process of modifying or enhancing an image by applying a
specific algorithm or a set of mathematical operations to its
pixels.
• In basic terms, a convolution is a mathematical operation on two
functions that produce a third function.
• The goal of image filtering is to manipulate the image in such a
way that certain features become more prominent , making it
easier to extract relevant information or to improve the image’s
overall quality.
• Grayscale images have 1 channel that goes from a scale from
0 to 255 where 0 is black and 255 is white. Colored images
typically have 3 channels and stored as 3 bytes: red, green,
blue (RGB) values each ranging from 0 to 255 depending on
intensity. Therefore, a picture can be represented as a matrix of
values.
• Image filters are typically represented by a small matrix or
kernel, which is slide over the entire image.
• At each position, the kernel is multiplied with the pixel values
within its neighborhood, and the resulting values are combined
to form a new value for the central pixel.
• The size and values of the kernel determine the nature of the
filtering operation.
The process of convolution
• In image convolution, involves a kernel, or matrix that is applied
over the input image’s pixels to generate an output image.
• The kernel size and values determine the effect the kernel has
on the image. The dimensions of the kernel should be smaller
or equal to that of the input image’s.
• The kernel typically is square shaped and has an odd kernel
size out of convenience.
• How is the kernel applied in a convolution? The first step is that
the kernel is flipped both horizontally and vertically.
• This is done by definition of a convolution. Using a non-flipped
kernel would be doing a cross-correlation rather than a
convolution. In the case of a symmetric kernel, the
cross-correlation is equivalent to its convolution.
• The animation below visually demonstrates how a 3x3 kernel is
applied over a 5x5 input image generating a 3x3 output image.
Note that the kernel slides along the input image.
• The output image pixels are calculated by performing an
element by element multiplication with the kernel and the
covered section of the input image and then summing them up.
• Given an example kernel and input image, an example of the
calculation is shown below with the first pixel.
Mathematically, convolution in 2 dimensions is defined as
follows:

k, l represents the row, length indices of the kernel


respectively. x(n,m) is the input and y(n,m) is the output
images. n,m is the row, column indices of the input and
output images.
• Notice that the output image size is smaller than the input image
size.
• A larger kernel size would further decrease the output image
dimensions. One way to fix this downsizing is to pad the input
image. You can populate the padded image by extending the
pixel values at the edge.
• Extending the edge pixels is one of many methods of padding.
Below shows the input image padded by 1 pixel. The padded
pixels are outlined in blue dotted lines.
• The updated illustration with padding is shown below. Now, the
output image has the same dimension as the original input
image.
• Mathematical Example :
• Let’s walk through a step-by-step mathematical example of image filtering
using a simple 3x3 kernel and a grayscale image.
• Suppose we have the following grayscale image:
• Original Image:
[ 100, 150, 200 ]
[ 50, 75, 125 ]
[ 25, 175, 250 ]
• And we want to apply the following 3x3 kernel/filter:
• Kernel:
[ 1, 0, -1 ]
[ 2, 0, -2 ]
[ 1, 0, -1 ]
• Here’s how the image filtering process works step-by-step:
• Step 1: Place the kernel on the top-left corner of the image.
• [ 100, 150, 200 ]
[ 50, 75, 125 ]
[ 25, 175, 250 ]
• Kernel:
[ 1, 0, -1 ]
[ 2, 0, -2 ]
[ 1, 0, -1 ]
• Step 2: Perform element-wise multiplication between the kernel and the image
pixels that are overlapped by the kernel.
• (1 * 100) + (0 * 150) + (-1 * 200) +(2 * 50) + (0 * 75) + (-2 * 125) +(1 * 25) + (0 *
175) + (-1 * 250) = 100 + 0–200 + 100 + 0–250 + 25 + 0–250 = -175
•:
• Step 3: Place the result of the convolution (which is -175 in this case) at the center pixel of
a new output image.
• Step 4: Slide the kernel one pixel to the right and repeat steps 2 and 3 until the entire row
is covered. Then, move the kernel down one pixel and repeat the process until the entire
image is covered.
• Continuing the process for the entire image, we get the output:
• Output Image:
[ -175, -125, 25 ]
[ -225, -125, 0 ]
[ 225, 50, 0 ]
• This output image is the result of applying the 2D convolutional filter to the original image
using the given kernel.
• Using an example image of the dog shown below, here are
some resulting images produced by the following kernels.
• The following kernel sharpens the image.
• One application of convolutional filtering is with edge detection. This kernel
is a diagonal edge detecting kernel. It rewards changes in color along a
diagonal.

• This is a blurring kernel. The output pixels
are determined by a combination of the
central pixel and neighboring pixels.

You might also like