Computer Vision
Fundamentals of Image Processing and
Filtering
Ahsan Raees
Types of Image derivatives and averages
images Filters
1 Types of images
2 Image derivatives and
averages
3 Filters
Types of Image derivatives and averages
images Filters
1 Types of images
2 Image derivatives and
averages
3 Filters
Types of Image derivatives and averages
images Filters
Binar
Gray
y
Scale
Colo
r
Types of Image derivatives and averages
images Filters
Binary image
Image is a matrix of numbers and is
represented as.
Types of Image derivatives and averages
images Filters
Gray scale image
Types of Image derivatives and averages
images Filters
Gray scale image
Types of Image derivatives and averages
images Filters
Color image - Red, Green and Blue channels
Types of images Image derivatives and averages
Filters
Image histogram
An important property/feature of an image is Histogram. The
histogram of an image shows us the distribution of grey
levels in the image i.e., what are the different grey levels in
the image and how many times they occur. Massively useful
in image processing, especially in segmentation
Types of images Image derivatives and averages
Filters
Image histogram
Types of images Image derivatives and averages
Filters
Image histogram
Types of images Image derivatives and averages
Filters
Image histogram
Types of images Image derivatives and averages
Filters
Image histogram
Types of images Image derivatives and averages
Filters
Image histogram
A selection of images
and their histograms
Notice the
relationships
between the images
and their histograms
Note that the high
contrast* image has the
most evenly spaced
*Contrast describes tones, specifically the
histogram
relationship be- tween the darkest and brightest
parts of an image. If the difference between
darkest and lightest portions of an im- age is
vast - for example, if the shadows are very dark
and the highlights are very bright - an image is
said to have high contrast.
Types of images Image derivatives and averages
Filters
Histogram Equalization
Types of images Image derivatives and averages
Filters
Histogram Equalization
Gray level No. of Pixels PDF CDF CDF*Maximu Histogram
m Gray Level Equalization
Level
Types of images Image derivatives and averages
Filters
Histogram Equalization
Types of Image derivatives and averages
images Filters
Image
noise
The images may contain noise. The noise can be
due to following reasons (but not limited to).
Light variations
Camera
electronics
Surface
reflectance Lens
The goal is to
remove/reduce the
noise from an image
Types of Image derivatives and averages
images Filters
Image noise
Let I(x, y ) be the true pixel values and n(x, y ) be the
noise at pixel (x, y ). Mathematically,
ˆI(x , y ) = I(x, y ) + n(x, y )
(1)
Types of images Image derivatives and averages
Filters
Image noise
Gaussian Noise
It is a random noise generated using a
Gaussian distribution, also known as the
normal distribution.
Adding Gaussian noise to images can be used for
various purposes, such as simulating real-world
noise in images or for image denoising algorithms.
It is represented as pixel values that follow a
Gaussian distribution with a mean µ and standard
deviation σ. The distribution is symmetric and
bell-shaped.
Types of images Image derivatives and averages
Filters
Image noise
Gaussian Noise
Mathematical
ly, −x 2
n(x ) = e (2
2σ2
)
Types of Image derivatives and averages
images Filters
1 Types of images
2 Image derivatives and
averages
3 Filters
Types of Image derivatives and averages
images Filters
Definitions
In computer vision, the important operations to
perform on images are Differentiation and
averaging.
Derivative: Rate of change
Speed is a rate of change of distance
Acceleration is a rate of change of
speed
Average (Mean)
Dividing the sum of N values by N
Types of Image derivatives and averages
images Filters
Correlation
Types of Image derivatives and averages
images Filters
Correlation
Types of Image derivatives and averages
images Filters
Convolution
Types of Image derivatives and averages
images Filters
Convolution
Types of Image derivatives and averages
images Filters
1 Types of images
2 Image derivatives and
averages
3 Filters
Types of Image derivatives and averages
images Filters
Image filtering
1 Low pass
Block high
frequencies Used
for smoothing
Removing noise
2 High pass
Block low
frequencies
Used for sharpening the
image Detecting edges
Remove background
Types of Image derivatives and averages
images Filters
Nature of filtering
1 Linear filtering
Mean/Box filter
Weighted average
filter Gaussian Filter
2 Non-linear filtering
Median
filter Min
filter Max
filter
Types of Image derivatives and averages
images Filters
A linear spatial filter performs a sum-of-products
operation between an image f and a filter kernel,
h.
The kernel is an array whose size defines the
neighbourhood of operation, and whose
coefficients determine the nature of the
filter.
Other terms used for kernel are:
Mask
Templat
e
Window
Types of Image derivatives and averages
images Filters
Averages
Mean:
Weighted mean:
Types of Image derivatives and averages
images Filters
Filtering
Modify pixels based on some function of the
neighborhood
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
The output is the linear combination of the
neighborhood pixels
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of Image derivatives and averages
images Filters
Linear
filter
Types of images Image derivatives and averages
Filters
Linear filter
Gaussian filter
−x 2 −( x 2+y 2)
g(x ) = e 2σ2 g(x, y ) = 2σ2
e
σ=
g(x ) = .011 .13 .6
1
1 .6 .13 .011
Types of images Image derivatives and averages
Filters
Linear filter
Properties of Gaussian
Most common natural model
Smooth function, it has infinite number of
derivatives Fourier Transform of Gaussian is
Gaussian Convolution of a Gaussian with itself
is a Gaussian There are cells in eye that
perform Gaussian filtering
Types of images Image derivatives and averages
Filters
Linear filter
Filtering - Gaussian
Types of images Image derivatives and averages
Filters
Linear filter
Gaussian vs. Averaging
Gaussian Smoothing by
smoothing averaging
Types of images Image derivatives and averages
Filters
Linear filter
Noise filtering
After
averaging
Gaussian
noise
After Gaussian
smoothing
Types of images Image derivatives and averages
Filters
Non-
linear A very famous example of salt and pepper
noise in an image Goal is to remove noise
filtering while preserving the other contents in the
image
Types of images Image derivatives and averages
Filters
Non-linear filtering
Let us see, what will happen if
we apply any linear filter
It did not remove the
outliers It blurred the
edges
Types of images Image derivatives and averages
Filters
Non-linear filtering
While applying the non-linear filter (Median
Filtering)
Types of images Image derivatives and averages
Filters
Non-linear filtering
Max and Min filters
Min filter replace the corresponding value with
minimum value in the masked region (helpful in
removing salt noise)
Max filter replace the corresponding value with
maximum value in the masked region (helpful in
removing pepper noise)
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
Define the kernel/filter size
Select the pixel on which we have apply the
median filter Select the neighboring pixels equal to
the size of the kernel Arrange all the pixels in
ascending order
Find the median and assign that value to the
selected pixel
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
It works well for impulse noise (e.g. salt and
pepper). It requires sorting of the image
values.
It preserves the edges better than an average
filter in the case of impulse noise.
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering vs. averaging
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
For noise density =
0.01
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
For noise density =
0.02
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
For noise density =
0.05
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
For noise density =
0.07
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
For noise density =
0.15
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
For noise density =
0.2
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
For noise density =
0.4
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
For noise density =
0.7
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
For noise density =
0.9
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
For noise density =
1.0
Types of images Image derivatives and averages
Filters
Non-linear filtering
Median filtering
Median filtering has limitations
It is not robust against more realistic noise
(especially image acquired under low lighting
conditions)