Tutorial 1 - Spatial Filtering Part 1
Tutorial 1 - Spatial Filtering Part 1
TUTORIAL 1
➢ Image Processing
It is a method to perform some operations on an image, in order
to get an enhanced image or to extract some useful information
from it (eg: recognition of individual objects).
➢ Computer Vision
It is a field of computer science that deals with how computers can
gain high-level understanding from digital images or videos in the
same way that human vision does, and then provide appropriate
output.
Digital Image
▪ It is a representation of a two-dimensional
picture.
M rows
➢ Pixel
N columns
It denotes the elements of a digital image.
Digital Image Types
➢ Binary Image
2D array of integer numbers where each pixel intensity has two
possible values (0,1) or (0, 255) for an 8-bit image.
➢ Grayscale Image
2D array of integer numbers where each pixel has a value most
commonly in range [0-255] for an 8-bit image.
➢ RGB Image
3D array that defines red, green, and blue color components
for each individual pixel. Each of the three values is in the
range [0-255] for an 8-bit image.
Image Enhancement in Spatial Domain
➢ Image Enhancement
Image enhancement is the process of making images more
useful visually.
• Highlight interesting details.
• Removing noise.
➢ Spatial Filtering
For any specific location (x, y), the value of g at filter
filter
Spatial Filtering Example
Spatial Filtering Example
Linear vs Non-linear Filters
Example
z = 5a -3b + 2c linear
z = max(a, b) non-linear filter
Filter Types
➢ Used for
1. Blurring and noise reduction.
2. Removing small details prior to object extraction.
3. Bridging small gaps in lines and curves.
➢ Includes
A. Averaging Filters.
B. Order-Statistics Filters.
- Median Filter.
- Maximum Filter.
- Minimum Filter.
1.A Averaging Filter
➢ Used for
1. Highlight transitions in intensities→ highlight
edges.
2. Remove blurring → enhance details.
➢ Includes
A. Gradient Filter (First Derivative).
B. Laplacian Filter (Second Derivative).
2. Sharpening Filter
➢ Conditions
1. The elements of the filter contain both
positive and negative weights.
2. Filter elements sum to 0.
➢ Hyperparameters
1. Filter size (3x3, 5x5, ….).
2. Filter weights.
2. Sharpening Filter
2.A Gradient Filter
➢ Formula f
f Gx x
= f ( x + 1) − f ( x) Thus, f = = f
x G y
y
▪ Gradient magnitude: provides information
about edge strength.
▪ Sobel Filter
2.B Laplacian Filter
➢ Formula
▪ In x-direction: 2 f
= f ( x + 1, y ) + f ( x − 1, y ) − 2 f ( x, y )
x
2
▪ In y-direction: 2 f
= f ( x, y + 1) + f ( x, y − 1) − 2 f ( x, y )
y
2
Let
• c = 1 if the filter’s center is positive.
• c = -1 if the filter’s center is negative.
Laplacian variants
2.B Laplacian Filter