You are on page 1of 28

University of Baghdad

Al-Khwarizmi College of Engineering


Biomedical Engineering Department

Image processing for BME 1


5th Stage

Lecture 5
Spatial Domain Filtering

By:
Dr. Noor Kamal
PhD in Biomedical Engineering
Image processing for BME 2_Lec 5_ 2020 1
Concepts

• Noise in digital images can result from image


acquisition (digitization) and transmission
• Imaging sensors can be affected by ambient conditions
• Interference can be added to an image during transmission

• Common types of image noise include:


• Salt and pepper noise: contains random occurrences of
black & white pixels
• Impulse noise: contains random occurrences of white pixels
• Gaussian noise: variations in intensity drawn from a
Gaussian normal distribution

Image processing for BME 2_Lec 5_ 2020 2


Noise Model

• We can consider a noisy image to be modelled as


follows:
g ( x, y )  f ( x, y )   ( x, y )

where f(x, y) is the original image pixel, η(x, y) is the


noise term and g(x, y) is the resulting noisy pixel

• If we can estimate the noise model we can figure


out how to restore the image

Image processing for BME 2_Lec 5_ 2020 3


What Is Image Enhancement?

Image enhancement is the process of making images more useful and


depends on which feature want to enhance (processing technique is
application dependent)
The reasons for doing this include:
1. Highlighting interesting detail in images (edge detection)
2. Removing noise from images
3. Making images more visually appealing
Note:
• No general “”theory” behind enhancement, the criteria behind
enhancement often subjective or too complex to be easily
converted to useful objective measures.
• Application specific evaluation criteria to observe its effectiveness.

Image processing for BME 2_Lec 5_ 2020 4


Image Enhancement

• Image Enhancement is the process of manipulating


an image so that the result is more suitable than the
original for a specific application.
• There are two broad categories of image
enhancement techniques
 Spatial domain operations uing (linear and non-
linear spatial filtering)
 Frequency domain operations

Image processing for BME 2_Lec 5_ 2020 5


Spatial Domain Filtering

Image processing for BME 2_Lec 5_ 2020 6


Image Enhancement
Spatial domain operations:
- Work on image plane itself
- directly operation on pixels of an image
using:
Point operations
Histogram based technique
Mask processing technique
Frequency domain operations
- Works on modified Fourier transform (FT) or wavelet
transform (WT) coefficients of an image
- Take the inverse FT or WT of the modified coefficients to
obtain the enhanced image
Image processing for BME 2_Lec 5_ 2020 7
Image Enhancement in Spatial Domain
(Filtering)

Point Processing: enhancement at any point in an image


depends only the gray-level at that point.

Mask Processing/Filtering: where the values of the mask


coefficients determine the nature of the process.

o Output depends on neighboring pixels of the input


function

o Neighborhood can be small or large

Image processing for BME 2_Lec 5_ 2020 8


Point Processing
g(x,y)=T[f(x,y)]
Where f(x,y): input image, g(x,y): processed image
T: an operator

s=T(r)
r: gray-level at (x,y) in original image f(x,y)
s: gray-level at (x,y) in processed image g(x,y)
T is called gray-level transformation or mapping

Image processing for BME 2_Lec 5_ 2020 9


Point Operation
• Operation deals with pixel intensity values individually.
• The intensity values are altered using particular transformation
techniques as per the requirement.
• The transformed output pixel value does not depend on any of the
neighbouring pixel value of the input image.
• Examples:
• Image Negative.
• Brightness Enhancement.
• Log Transformation.
• Power Law Transformation (gamma correction).
• Piecewise linear.
• Contrast Stretching.
• Thresholding.
• Enhancement Using Arithmetic/Logic Operations

Image processing for BME 2_Lec 5_ 2020 10


Mask processing technique
• Mask is a small matrix useful for blurring, sharpening,
edge-detection and more.
• New image is generated by multiplying the input
image with the mask matrix.
• The output pixel values thus depend on the
neighbouring input pixel values.
• The mask may be of any dimension 3X3, 5X5, 7X7 ….

Image processing for BME 2_Lec 5_ 2020 11


Mask processing technique
• Compute new image from old image
• Each pixel in new image depends on ‘nearby’ pixels
in old image
• For all x, y
O(x, y) = F(I(x, y), I(x+1, y), I(x-1, y), I(x, y+1), I(x, y-1))
I(x, y) O(x, y)

y y

x x
Image processing for BME 2_Lec 5_ 2020 12
Spatial Filtering
Mask
filter, kernel, templete, window
convelution mask/kernel

w(-1,-1) w(-1,0) w(-1,1)

w(0,-1) w(0,0) w(0,1)


Another representation of a general 3X3 filter mask

w(1,-1) w(1,0) w(1,1)

Mask coefficients showing coordinate arrangement

Image processing for BME 2_Lec 5_ 2020 13


Pixels of Image
(0,0) x

f(x-1,y-1) f(x,y-1) f(x+1,y-1)

y f(x-1,y) f(x,y) f(x+1,y)

f(x-1,y+1) f(x,y+1) f(x+1,y+1)

Image processing for BME 2_Lec 5_ 2020 14


The Mechanics of Mask Filtering in
, Spatial Domain

15
Image processing for BME 2_Lec 5_ 2020
The Mechanics of Mask Filtering in Spatial Domain

Image processing for BME 2_Lec 5_ 2020 16


Image Enhancement in Spatial Domain
(Filtering) using Mask processing technique
• Linear and non-linear smoothing filter
Note that: Smoothing Linear Filters (known as
averaging filter or lowpass filters).

• Non-linear Median filter

• Sharpening filter

Image processing for BME 2_Lec 5_ 2020 17


Image Enhancement in Spatial Domain
(Filtering)
• Smoothing Spatial Filter
Smoothing filters are used for
• blurring
• noise reduction

Image processing for BME 2_Lec 5_ 2020 18


Smoothing Linear Filters

Box filter Weighted average


filter

Image processing for BME 2_Lec 5_ 2020 19


Smoothing Spatial Filter
* Smoothing Linear Filters
Smoothing Linear Filters also called
• averaging filter
• Lowpass filter

Image processing for BME 2_Lec 5_ 2020 20


Lowpass filter

Image processing for BME 2_Lec 5_ 2020 21


Smoothing Filtering: Example 1
Original
Square averaging filter mask of
3x3 different sizes

5x5
9x9

15x15 35x35

Image processing for BME 2_Lec 5_ 2020 22


Smoothing Spatial Filter
* Smoothing Linear Filters
Smoothing Linear Filters also called
• Weighted averaging filter

Image processing for BME 2_Lec 5_ 2020 23


Smoothing Filtering: Example 2

Image processing for BME 2_Lec 5_ 2020 24


Non Linear Spatial Filtering: Median Filter
•Order-statistic filters are non-linear spatial filters whose
response is based on filters whose response is based on
ordering (ranking) the pixels contained in the image area.
•The best known filter in this category is the median filter,
which as its name implies, replace the value of a pixel by
median of the intensity values in the neighborhood of that
pixel.
• Median filters are quite popular because, for certain types of
random noise, they provide excellent noise-reduction
capabilities with considerably less blurring than linear
smoothing filters of similar size.

Image processing for BME 2_Lec 5_ 2020 25


Smoothing Spatial Filter
* Order-Statistics Filters
(Non-linear Filters)
• Median filtering is particularly effective in the presence of
impulse noise (salt and pepper noise).
• Unlike average filtering, median filtering does not blur too
much image details.

Image processing for BME 2_Lec 5_ 2020 26


Image processing for BME 2_Lec 5_ 2020 27
Image processing for BME 2_Lec 5_ 2020 28

You might also like