SlideShare a Scribd company logo
1 of 51
COMPUTER GRAPHICS & IMAGE PROCESSING
COM2304
Intensity Transformation and Spatial Filtering – II
Spatial Filtering and Smoothing
K.A.S.H.Kulathilake
B.Sc. (Hons) IT (SLIIT), MCS (UCSC), M.Phil (UOM), SEDA(UK)
Rajarata University of Sri Lanka
Faculty of Applied Sciences
Department of Physical Sciences
Learning Outcomes
COM2304 - Computer Graphics & Image
Processing
• At the end of this lecture, you should be
able to;
– describe the fundamentals of spatial filtering.
– generating spatial filter masks.
– identify smoothing via linear filters and non
linear filters.
– apply smoothing techniques for problem
solving.
Filters in Image Processing
• Filter can accept or reject certain frequency
components.
• In image processing filters are mainly used to
suppress either the high frequencies in the
image, i.e. smoothing the image, or the low
frequencies, i.e. enhancing/ sharpening or
detecting edges in the image.
• An image can be filtered either in the
frequency or in the spatial domain.
COM2304 - Computer Graphics & Image
Processing
Fundamentals of Frequency
Domain Filtering
• Frequency domain filtering involves ;
– transforming the image into the
frequency domain,
– multiplying it with the frequency
filter function and
– re-transforming the result into the
spatial domain.
• The filter function is shaped so as to
attenuate some frequencies and
enhance others.
• For example, a simple lowpass function
is 1 for frequencies smaller than the
cut-off frequency and 0 for all others.
COM2304 - Computer Graphics & Image
Processing
Fundamentals of Spatial Filtering
• Spatial filter contains two components;
– MASK/ CONVOLUTION MATRIX/ KERNEL: A neighborhood
(typically small rectangle:)
– FILTER FUNCTION: A predefined operation that is performed
on the image pixels encompassed by the neighborhood.
• Spatial filtering is the method of choice in situations when only
additive random noise is present.
• Filtering creates a new pixel value with coordinates equal to the
coordinates of the center of the neighborhood, and whose value
is the result of the filtering operation.
COM2304 - Computer Graphics & Image
Processing
Fundamentals of Spatial Filtering
(Cont….)
COM2304 - Computer Graphics & Image
Processing
Fundamentals of Spatial Filtering
(Cont….)
COM2304 - Computer Graphics & Image
Processing
If the operation
performed on the image
pixels is linear, then the
filter is called a linear
spatial filter, otherwise,
the filter is non-linear.
Fundamentals of Spatial Filtering
(Cont….)
• Spatial filtering of an image of size M×N with a filter of size
m×n is given by the expression;
• Where w is the mask and f is the image function, x and y
are varied so that each pixel in w visits every pixel in f.
• m = 2a+1 and n = 2b+1, where a and b are positive
integers.
• This concept is known as correlation.
COM2304 - Computer Graphics & Image
Processing
Fundamentals of Spatial Filtering
(Cont….)
• There are two closely related concepts that
must be understood clearly when performing
linear spatial filtering
– Correlation
• Correlation is the process of moving a filter mask over
the image and computing the sum of products at each
location exactly as explained previously.
– Convolution
• The mechanics of convolution are the same as
correlation except that the filter is first rotated by 180
degrees.
COM2304 - Computer Graphics & Image
Processing
Fundamentals of Spatial Filtering
(Cont….)
COM2304 - Computer Graphics & Image
Processing
If the filter mask is symmetric, correlation and convolution
yield the same result
Mask/Kernel/ Convolution Matrix
• In image processing, a kernel, convolution
matrix, or mask is a small matrix.
• It is useful for blurring, sharpening,
embossing, edge detection, and more.
• This is accomplished by means of convolution
between a kernel and an image.
COM2304 - Computer Graphics & Image
Processing
Mask/Kernel/ Convolution Matrix
(Cont…)
• Important Features of
Kernel
– Size: 3×3, 5×5, 9×9,
21×21
– Shape: rectangle, cross,
strip, circular, diamond
or user defined.
– Coefficients / Values:
set based on the
operation.
– Anchor point: mostly in
middle
COM2304 - Computer Graphics & Image
Processing
0 -1 0
-1 5 -1
0 -1 0
3×3 Kernel
Anchor
Values for
sharpening
operation
Mask/Kernel/ Convolution Matrix
(Cont…)
COM2304 - Computer Graphics & Image
Processing
0 -1 0
-1 5 -1
0 -1 0
Kernel
Mask/Kernel/ Convolution Matrix
(Cont…)
COM2304 - Computer Graphics & Image
Processing
http://setosa.io/ev/image-kernels/
https://en.wikipedia.org/wiki/Kernel_(image_processing)
Convolution
• Convolution is a simple mathematical
operation which is fundamental to many
common image processing operators.
• This can be used in image processing to
implement operators whose output pixel
values are simple linear combinations of
certain input pixel values.
COM2304 - Computer Graphics & Image
Processing
Convolution (Cont…)
COM2304 - Computer Graphics & Image
Processing
Each kernel position
corresponds to a single
output pixel, the value of
which is calculated by
multiplying together the
kernel value and the
underlying image pixel
value for each of the cells
in the kernel, and then
adding all these numbers
together.
The convolution is
performed by sliding the
kernel over the image,
generally starting at the
top left corner.
Convolution (Cont…)
COM2304 - Computer Graphics & Image
Processing
Generating Spatial Filter Masks
• Generating an m×n linear spatial filter requires that we
specify mn mask coefficients.
• These coefficients are selected based on what the filter
is supposed to do.
• There are different types of filters available, some of
them are;
– Linear filters - In signal processing, a linear filter is a filter
whose output is a linear function of its input.
– Continuous function based filters – e.g. Gaussian
smoothing (it’s a kind of linear filter).
– Non linear filters - In signal processing, a non-linear filter is
a filter whose output is not a linear function of its input.
COM2304 - Computer Graphics & Image
Processing
Generating Spatial Filter Masks (cont…)
• Linear filters
– Implement sum of products
– ex: filters used for smoothing
• Continuous function based filters
– ex: Gaussian function of two variables as shown in the following
equation;
– Where σ is the standard deviation and coordinates x and y are
the positive integers.
– Recall that 2D Gaussian function has bell shape and the σ
control the tightness of the bell.
COM2304 - Computer Graphics & Image
Processing
Generating Spatial Filter Masks (cont…)
• Non linear/ Order static filters
– Non linear filters require to specify the size of the
filter and the operation(s) to be performed on the
image pixel contained in the filter.
• ex: filter 5×5 filter centered at an arbitrary point and
perform max operation.
– Non linear filters are quiet powerful in some
applications, than the linear filters.
COM2304 - Computer Graphics & Image
Processing
Smoothing Spatial Filters
• Smoothing filters are used for blurring and
noise reduction.
• Blurring is used in preprocessing tasks, such as
removal of small details from an image prior
to object extraction, and bridging of small
gaps in lines or curves.
• Noise reduction can be accomplished by
blurring with a linear filter and also by
nonlinear filtering.
COM2304 - Computer Graphics & Image
Processing
Smoothing Linear Filters
• Average /Mean Filter
– The output is simply the average of the pixels
contained in the neighborhood of the filter mask.
– In smoothing filter, it replaces the value of every pixel
in an image by the average of the intensity levels in
the neighborhood defined by the filter mask.
– This process result in an image with reduced “sharp”
transitions in intensities.
– Most obvious application of smoothing is noise
reduction because random noise typically consists of
sharp transitions in intensity levels.
COM2304 - Computer Graphics & Image
Processing
Smoothing Linear Filters (Cont…)
COM2304 - Computer Graphics & Image
Processing
Smoothing Linear Filters (Cont…)
– Averaging filters blur edges, because edges
represent the sharp intensity transition.
– Average blurring smoothes the false contours that
result from using an insufficient number of
intensity levels.
– A major use of averaging filters is in the reduction
of “irrelevant” detail (pixel regions that are small
with respect to the size of the filter mask) in an
image.
COM2304 - Computer Graphics & Image
Processing
Smoothing Linear Filters (Cont…)
COM2304 - Computer Graphics & Image
Processing
Observe
blurring
occur during
smoothing
operation
Smoothing Linear Filters (Cont…)
– Let Sx,y represent the set of coordinates in neighbourhood
of size m×n, centered at point (x, y).
– The arithmetic mean filter computes the average value of
the corrupted image g( x, y) in the area defined by Sx,y.
– The value of the restored image f’ at point ( x, y) is simply
the arithmetic mean computed using the pixels in the
region defined by Sx,y.
COM2304 - Computer Graphics & Image
Processing


xySts
tsg
mn
yxf
),(
),(
1
),(ˆ
Smoothing Linear Filters (Cont…)
• There are different kinds of mean filters all of
which exhibit slightly different behaviour:
• Geometric Mean:
– Achieves similar smoothing to the arithmetic
mean, but tends to lose less image detail
COM2304 - Computer Graphics & Image
Processing
mn
Sts xy
tsgyxf
1
),(
),(),(ˆ








 
Smoothing Linear Filters (Cont…)
• Harmonic Mean:
– Works well for salt noise, but fails for pepper
noise.
– Also does well for other kinds of noise such as
Gaussian noise
COM2304 - Computer Graphics & Image
Processing


xySts tsg
mn
yxf
),( ),(
1
),(ˆ
Smoothing Linear Filters (Cont…)
• Contraharmonic Mean:
– Q is the order of the filter and adjusting its value
changes the filter’s behaviour.
– Positive values of Q eliminate pepper noise.
– Negative values of Q eliminate salt noise.
– If Q =0 it represents the arithmetic filter.
COM2304 - Computer Graphics & Image
Processing






xy
xy
Sts
Q
Sts
Q
tsg
tsg
yxf
),(
),(
1
),(
),(
),(ˆ
Smoothing Linear Filters (Cont…)
Original
Image
Image
Corrupted
By Gaussian
Noise
After A 3*3
Geometric
Mean Filter
After A 3*3
Arithmetic
Mean Filter
COM2304 - Computer Graphics & Image
Processing
Smoothing Linear Filters (Cont…)
Image
Corrupted
By Pepper
Noise
Result of
Filtering Above
With 3*3
Contraharmonic
Q=1.5
COM2304 - Computer Graphics & Image
Processing
Smoothing Linear Filters (Cont…)
Image
Corrupted
By Salt
Noise
Result of
Filtering Above
With 3*3
Contraharmonic
Q=-1.5
COM2304 - Computer Graphics & Image
Processing
Smoothing Linear Filters (Cont…)
Choosing the wrong value for Q when using the
contraharmonic filter can have drastic results
COM2304 - Computer Graphics & Image
Processing
Smoothing Linear Filters (Cont…)
• A spatial averaging filter in which all
coefficients are equal is called a Box
Filter.
• The basic strategy behind weighting
the center point the highest and then
reducing the value of the coefficients
as a function of increasing distance
from the origin in spatial averaging
filter is simply an attempt to reduce
blurring in the smoothing process.
COM2304 - Computer Graphics & Image
Processing
Smoothing Linear Filters (Cont…)
• Gaussian Smoothing:
– The Gaussian filter is a non-uniform low pass filter.
– The kernel coefficients diminish with increasing distance from
the kernel’s centre.
– Central pixels have a higher weighting than those on the
periphery.
– Larger values of σ produce a wider peak (greater blurring).
– Kernel size must increase with increasing σ to maintain the
Gaussian nature of the filter (`bell-shaped') .
– Gaussian kernel coefficients depend on the value of σ.
– At the edge of the mask, coefficients must be close to 0.
– The kernel is rotationally symmetric with no directional bias.
– Gaussian filters might not preserve image brightness.
COM2304 - Computer Graphics & Image
Processing
Smoothing Linear Filters (Cont…)
• The Gaussian distribution
in 1-D has the form:
• Where σ is the standard
deviation of the
distribution.
• We have also assumed
that the distribution has a
mean of zero (i.e. it is
centered on the line x=0).
COM2304 - Computer Graphics & Image
Processing
1-D Gaussian distribution with
mean 0 and σ=1
Smoothing Linear Filters (Cont…)
• In 2-D, an isotropic
(i.e. circularly symmetric)
Gaussian has the form:
COM2304 - Computer Graphics & Image
Processing
2-D Gaussian distribution with
mean (0,0) and σ=1
Discrete approximation to Gaussian
function with σ=1
The std. dev σ of the Gaussian
determines the amount of
smoothing.
Smoothing Linear Filters (Cont…)
COM2304 - Computer Graphics & Image
Processing
Smoothing Order Static (Nonlinear)
Filters
• The response of the order static or nonlinear
filters is based on ordering (ranking) the pixels
contained in the image area encompassed by the
filter, and then replacing the value of the center
pixel with the value determine by the ranking
result.
• Useful nonlinear filters include;
– Median filter
– Max and min filter
– Midpoint filter
COM2304 - Computer Graphics & Image
Processing
Smoothing Order Static (Nonlinear)
Filters (Cont…)
• Median Filter:
– It can reduce certain typed of random noise with
less blurring than the linear smoothing filters of
similar size.
– Provides excellent results when applying to reduce
salt and pepper noise.
COM2304 - Computer Graphics & Image
Processing
)},({),(ˆ
),(
tsgmedianyxf
xySts 

Smoothing Order Static (Nonlinear)
Filters (Cont…)
COM2304 - Computer Graphics & Image
Processing
Smoothing Order Static (Nonlinear)
Filters (Cont…)
COM2304 - Computer Graphics & Image
Processing
Smoothing Order Static (Nonlinear)
Filters (Cont…)
• Median filter smoothes ("washes") all edges
and boundaries and may "erase" all details
whose size is about n/2× m/2, where n × m is
a window size.
• As a result, an image becomes "fuzzy".
• Median filter is not so efficient for additive
Gaussian noise removal, it yields to linear
filters.
COM2304 - Computer Graphics & Image
Processing
Smoothing Order Static (Nonlinear)
Filters (Cont…)
• Max Filter:
• Min Filter:
–Max filter is useful for finding the brightest points in an
image and min filter for finding the darkest points in an
image.
–Max filter is good for pepper noise and min filter is good for
salt noise
COM2304 - Computer Graphics & Image
Processing
)},({max),(ˆ
),(
tsgyxf
xySts 

)},({min),(ˆ
),(
tsgyxf
xySts 

Smoothing Order Static (Nonlinear)
Filters (Cont…)
• Midpoint Filter:
– Good for random Gaussian and uniform noise
COM2304 - Computer Graphics & Image
Processing



 

)},({min)},({max
2
1
),(ˆ
),(),(
tsgtsgyxf
xyxy StsSts
Smoothing Order Static (Nonlinear)
Filters (Cont…)
• Alpha-trimmed Mean Filter:
– We can delete the d/2 lowest and d/2 highest grey
levels.
– So g(s, t) represents the remaining mn – d pixels.
– When d= 0 : arithmetic mean filter.
– Good for combination of salt and pepper and
Gaussian noise.
COM2304 - Computer Graphics & Image
Processing


xySts
tsg
dmn
yxf
),(
),(
1
),(ˆ
Smoothing Order Static (Nonlinear)
Filters (Cont…)
COM2304 - Computer Graphics & Image
Processing
Removing Periodic Noise
• Removing periodic noise form an image
involves removing a particular range of
frequencies from that image.
• Band reject filters can be used for this
purpose.
Out of the scope of this course -   
COM2304 - Computer Graphics & Image
Processing
Reference
• Chapter 03, Chapter 05 of Gonzalez, R.C.,
Woods, R.E., Digital Image Processing, 3rd ed.
Addison-Wesley Pub.
• http://setosa.io/ev/image-kernels/
• https://en.wikipedia.org/wiki/Kernel_(image_
processing)
COM2304 - Computer Graphics & Image
Processing
Learning Outcomes Revisit
• Now, you should be able to;
– describe the fundamentals of spatial filtering.
– generating spatial filter masks.
– identify smoothing via linear filters and non
linear filters.
– apply smoothing techniques for problem
solving.
COM2304 - Computer Graphics & Image
Processing
QUESTIONS ?
Next Lecture – Intensity Transformation and Spatial Filtering – III
COM2304 - Computer Graphics & Image
Processing

More Related Content

What's hot

Image trnsformations
Image trnsformationsImage trnsformations
Image trnsformations
John Williams
 
Enhancement in spatial domain
Enhancement in spatial domainEnhancement in spatial domain
Enhancement in spatial domain
Ashish Kumar
 

What's hot (20)

Image trnsformations
Image trnsformationsImage trnsformations
Image trnsformations
 
Enhancement in spatial domain
Enhancement in spatial domainEnhancement in spatial domain
Enhancement in spatial domain
 
Image Filtering in the Frequency Domain
Image Filtering in the Frequency DomainImage Filtering in the Frequency Domain
Image Filtering in the Frequency Domain
 
Digital Image Processing: Image Segmentation
Digital Image Processing: Image SegmentationDigital Image Processing: Image Segmentation
Digital Image Processing: Image Segmentation
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial Domain
 
Histogram processing
Histogram processingHistogram processing
Histogram processing
 
Image Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain FiltersImage Enhancement using Frequency Domain Filters
Image Enhancement using Frequency Domain Filters
 
Image Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain FiltersImage Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain Filters
 
Sharpening using frequency Domain Filter
Sharpening using frequency Domain FilterSharpening using frequency Domain Filter
Sharpening using frequency Domain Filter
 
filters for noise in image processing
filters for noise in image processingfilters for noise in image processing
filters for noise in image processing
 
Chapter 5 Image Processing: Fourier Transformation
Chapter 5 Image Processing: Fourier TransformationChapter 5 Image Processing: Fourier Transformation
Chapter 5 Image Processing: Fourier Transformation
 
08 frequency domain filtering DIP
08 frequency domain filtering DIP08 frequency domain filtering DIP
08 frequency domain filtering DIP
 
Erosion and dilation
Erosion and dilationErosion and dilation
Erosion and dilation
 
Chapter 9 morphological image processing
Chapter 9   morphological image processingChapter 9   morphological image processing
Chapter 9 morphological image processing
 
Image processing second unit Notes
Image processing second unit NotesImage processing second unit Notes
Image processing second unit Notes
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filtering
 
IMAGE SEGMENTATION.
IMAGE SEGMENTATION.IMAGE SEGMENTATION.
IMAGE SEGMENTATION.
 
Digital Image restoration
Digital Image restorationDigital Image restoration
Digital Image restoration
 
Homomorphic filtering
Homomorphic filteringHomomorphic filtering
Homomorphic filtering
 
Image Enhancement in Spatial Domain
Image Enhancement in Spatial DomainImage Enhancement in Spatial Domain
Image Enhancement in Spatial Domain
 

Viewers also liked

Spatial enhancement
Spatial enhancement Spatial enhancement
Spatial enhancement
abinarkt
 
Edge detection of video using matlab code
Edge detection of video using matlab codeEdge detection of video using matlab code
Edge detection of video using matlab code
Bhushan Deore
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
Ayaelshiwi
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniques
Saideep
 
discrete wavelet transform
discrete wavelet transformdiscrete wavelet transform
discrete wavelet transform
piyush_11
 

Viewers also liked (20)

Digital image processing
Digital image processingDigital image processing
Digital image processing
 
Spatial enhancement
Spatial enhancement Spatial enhancement
Spatial enhancement
 
Spatial domain and filtering
Spatial domain and filteringSpatial domain and filtering
Spatial domain and filtering
 
Texture in image processing
Texture in image processing Texture in image processing
Texture in image processing
 
Image Texture Analysis
Image Texture AnalysisImage Texture Analysis
Image Texture Analysis
 
Edge detection of video using matlab code
Edge detection of video using matlab codeEdge detection of video using matlab code
Edge detection of video using matlab code
 
Digital Image Processing: Image Restoration
Digital Image Processing: Image RestorationDigital Image Processing: Image Restoration
Digital Image Processing: Image Restoration
 
Edge Detection algorithm and code
Edge Detection algorithm and codeEdge Detection algorithm and code
Edge Detection algorithm and code
 
Digital Image Processing: Image Enhancement in the Spatial Domain
Digital Image Processing: Image Enhancement in the Spatial DomainDigital Image Processing: Image Enhancement in the Spatial Domain
Digital Image Processing: Image Enhancement in the Spatial Domain
 
Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)Chapter 3 image enhancement (spatial domain)
Chapter 3 image enhancement (spatial domain)
 
Digital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainDigital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency Domain
 
Introduction to wavelet transform
Introduction to wavelet transformIntroduction to wavelet transform
Introduction to wavelet transform
 
Edge detection
Edge detectionEdge detection
Edge detection
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniques
 
Image enhancement techniques
Image enhancement techniquesImage enhancement techniques
Image enhancement techniques
 
Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)Image Restoration (Digital Image Processing)
Image Restoration (Digital Image Processing)
 
image_enhancement_spatial
 image_enhancement_spatial image_enhancement_spatial
image_enhancement_spatial
 
Image processing ppt
Image processing pptImage processing ppt
Image processing ppt
 
discrete wavelet transform
discrete wavelet transformdiscrete wavelet transform
discrete wavelet transform
 

Similar to COM2304: Intensity Transformation and Spatial Filtering – II Spatial Filtering and Smoothing

When Discrete Optimization Meets Multimedia Security (and Beyond)
When Discrete Optimization Meets Multimedia Security (and Beyond)When Discrete Optimization Meets Multimedia Security (and Beyond)
When Discrete Optimization Meets Multimedia Security (and Beyond)
Shujun Li
 

Similar to COM2304: Intensity Transformation and Spatial Filtering – II Spatial Filtering and Smoothing (20)

COM2304: Intensity Transformation and Spatial Filtering – III Spatial Filters...
COM2304: Intensity Transformation and Spatial Filtering – III Spatial Filters...COM2304: Intensity Transformation and Spatial Filtering – III Spatial Filters...
COM2304: Intensity Transformation and Spatial Filtering – III Spatial Filters...
 
Segmentation Techniques -I
Segmentation Techniques -ISegmentation Techniques -I
Segmentation Techniques -I
 
COM2304: Morphological Image Processing
COM2304: Morphological Image ProcessingCOM2304: Morphological Image Processing
COM2304: Morphological Image Processing
 
Digital Image Fundamentals - II
Digital Image Fundamentals - IIDigital Image Fundamentals - II
Digital Image Fundamentals - II
 
Segmentation Techniques -II
Segmentation Techniques -IISegmentation Techniques -II
Segmentation Techniques -II
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
ACMP340.pptx
ACMP340.pptxACMP340.pptx
ACMP340.pptx
 
Fidelity criteria in image compression
Fidelity criteria in image compressionFidelity criteria in image compression
Fidelity criteria in image compression
 
Translation Invariance (TI) based Novel Approach for better De-noising of Dig...
Translation Invariance (TI) based Novel Approach for better De-noising of Dig...Translation Invariance (TI) based Novel Approach for better De-noising of Dig...
Translation Invariance (TI) based Novel Approach for better De-noising of Dig...
 
COM2304: Introduction to Computer Vision & Image Processing
COM2304: Introduction to Computer Vision & Image Processing COM2304: Introduction to Computer Vision & Image Processing
COM2304: Introduction to Computer Vision & Image Processing
 
Spatial Filtering in intro image processingr
Spatial Filtering in intro image processingrSpatial Filtering in intro image processingr
Spatial Filtering in intro image processingr
 
When Discrete Optimization Meets Multimedia Security (and Beyond)
When Discrete Optimization Meets Multimedia Security (and Beyond)When Discrete Optimization Meets Multimedia Security (and Beyond)
When Discrete Optimization Meets Multimedia Security (and Beyond)
 
COM2304: Digital Image Fundamentals - I
COM2304: Digital Image Fundamentals - I COM2304: Digital Image Fundamentals - I
COM2304: Digital Image Fundamentals - I
 
Image processing
Image processingImage processing
Image processing
 
IRJET - Computer-Assisted ALL, AML, CLL, CML Detection and Counting for D...
IRJET -  	  Computer-Assisted ALL, AML, CLL, CML Detection and Counting for D...IRJET -  	  Computer-Assisted ALL, AML, CLL, CML Detection and Counting for D...
IRJET - Computer-Assisted ALL, AML, CLL, CML Detection and Counting for D...
 
COMPUTER GRAPHICS
COMPUTER GRAPHICSCOMPUTER GRAPHICS
COMPUTER GRAPHICS
 
DIP Notes Unit-1 PPT , engineering, computer Science
DIP Notes Unit-1 PPT , engineering, computer ScienceDIP Notes Unit-1 PPT , engineering, computer Science
DIP Notes Unit-1 PPT , engineering, computer Science
 
Presentation
PresentationPresentation
Presentation
 
IRJET - Change Detection in Satellite Images using Convolutional Neural N...
IRJET -  	  Change Detection in Satellite Images using Convolutional Neural N...IRJET -  	  Change Detection in Satellite Images using Convolutional Neural N...
IRJET - Change Detection in Satellite Images using Convolutional Neural N...
 
2. filtering basics
2. filtering basics2. filtering basics
2. filtering basics
 

More from Hemantha Kulathilake

More from Hemantha Kulathilake (20)

NLP_KASHK:Parsing with Context-Free Grammar
NLP_KASHK:Parsing with Context-Free Grammar NLP_KASHK:Parsing with Context-Free Grammar
NLP_KASHK:Parsing with Context-Free Grammar
 
NLP_KASHK:Context-Free Grammar for English
NLP_KASHK:Context-Free Grammar for EnglishNLP_KASHK:Context-Free Grammar for English
NLP_KASHK:Context-Free Grammar for English
 
NLP_KASHK:POS Tagging
NLP_KASHK:POS TaggingNLP_KASHK:POS Tagging
NLP_KASHK:POS Tagging
 
NLP_KASHK:Markov Models
NLP_KASHK:Markov ModelsNLP_KASHK:Markov Models
NLP_KASHK:Markov Models
 
NLP_KASHK:Smoothing N-gram Models
NLP_KASHK:Smoothing N-gram ModelsNLP_KASHK:Smoothing N-gram Models
NLP_KASHK:Smoothing N-gram Models
 
NLP_KASHK:Evaluating Language Model
NLP_KASHK:Evaluating Language ModelNLP_KASHK:Evaluating Language Model
NLP_KASHK:Evaluating Language Model
 
NLP_KASHK:N-Grams
NLP_KASHK:N-GramsNLP_KASHK:N-Grams
NLP_KASHK:N-Grams
 
NLP_KASHK:Minimum Edit Distance
NLP_KASHK:Minimum Edit DistanceNLP_KASHK:Minimum Edit Distance
NLP_KASHK:Minimum Edit Distance
 
NLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological ParsingNLP_KASHK:Finite-State Morphological Parsing
NLP_KASHK:Finite-State Morphological Parsing
 
NLP_KASHK:Morphology
NLP_KASHK:MorphologyNLP_KASHK:Morphology
NLP_KASHK:Morphology
 
NLP_KASHK:Text Normalization
NLP_KASHK:Text NormalizationNLP_KASHK:Text Normalization
NLP_KASHK:Text Normalization
 
NLP_KASHK:Finite-State Automata
NLP_KASHK:Finite-State AutomataNLP_KASHK:Finite-State Automata
NLP_KASHK:Finite-State Automata
 
NLP_KASHK:Regular Expressions
NLP_KASHK:Regular Expressions NLP_KASHK:Regular Expressions
NLP_KASHK:Regular Expressions
 
NLP_KASHK: Introduction
NLP_KASHK: Introduction NLP_KASHK: Introduction
NLP_KASHK: Introduction
 
COM1407: File Processing
COM1407: File Processing COM1407: File Processing
COM1407: File Processing
 
COm1407: Character & Strings
COm1407: Character & StringsCOm1407: Character & Strings
COm1407: Character & Strings
 
COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation
 
COM1407: Input/ Output Functions
COM1407: Input/ Output FunctionsCOM1407: Input/ Output Functions
COM1407: Input/ Output Functions
 
COM1407: Working with Pointers
COM1407: Working with PointersCOM1407: Working with Pointers
COM1407: Working with Pointers
 
COM1407: Arrays
COM1407: ArraysCOM1407: Arrays
COM1407: Arrays
 

Recently uploaded

Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
PirithiRaju
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
Sérgio Sacani
 
Module for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learningModule for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learning
levieagacer
 
dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...
dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...
dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...
dkNET
 
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
ssuser79fe74
 
Seismic Method Estimate velocity from seismic data.pptx
Seismic Method Estimate velocity from seismic  data.pptxSeismic Method Estimate velocity from seismic  data.pptx
Seismic Method Estimate velocity from seismic data.pptx
AlMamun560346
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Sérgio Sacani
 
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptxSCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
RizalinePalanog2
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
PirithiRaju
 
biology HL practice questions IB BIOLOGY
biology HL practice questions IB BIOLOGYbiology HL practice questions IB BIOLOGY
biology HL practice questions IB BIOLOGY
1301aanya
 

Recently uploaded (20)

Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdfPests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
Pests of cotton_Borer_Pests_Binomics_Dr.UPR.pdf
 
pumpkin fruit fly, water melon fruit fly, cucumber fruit fly
pumpkin fruit fly, water melon fruit fly, cucumber fruit flypumpkin fruit fly, water melon fruit fly, cucumber fruit fly
pumpkin fruit fly, water melon fruit fly, cucumber fruit fly
 
Formation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disksFormation of low mass protostars and their circumstellar disks
Formation of low mass protostars and their circumstellar disks
 
Module for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learningModule for Grade 9 for Asynchronous/Distance learning
Module for Grade 9 for Asynchronous/Distance learning
 
Unit5-Cloud.pptx for lpu course cse121 o
Unit5-Cloud.pptx for lpu course cse121 oUnit5-Cloud.pptx for lpu course cse121 o
Unit5-Cloud.pptx for lpu course cse121 o
 
dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...
dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...
dkNET Webinar "Texera: A Scalable Cloud Computing Platform for Sharing Data a...
 
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
High Class Escorts in Hyderabad ₹7.5k Pick Up & Drop With Cash Payment 969456...
 
PSYCHOSOCIAL NEEDS. in nursing II sem pptx
PSYCHOSOCIAL NEEDS. in nursing II sem pptxPSYCHOSOCIAL NEEDS. in nursing II sem pptx
PSYCHOSOCIAL NEEDS. in nursing II sem pptx
 
GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)GBSN - Microbiology (Unit 1)
GBSN - Microbiology (Unit 1)
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
 
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
Chemical Tests; flame test, positive and negative ions test Edexcel Internati...
 
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
High Profile 🔝 8250077686 📞 Call Girls Service in GTB Nagar🍑
 
Seismic Method Estimate velocity from seismic data.pptx
Seismic Method Estimate velocity from seismic  data.pptxSeismic Method Estimate velocity from seismic  data.pptx
Seismic Method Estimate velocity from seismic data.pptx
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
 
COMPUTING ANTI-DERIVATIVES (Integration by SUBSTITUTION)
COMPUTING ANTI-DERIVATIVES(Integration by SUBSTITUTION)COMPUTING ANTI-DERIVATIVES(Integration by SUBSTITUTION)
COMPUTING ANTI-DERIVATIVES (Integration by SUBSTITUTION)
 
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptxSCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
SCIENCE-4-QUARTER4-WEEK-4-PPT-1 (1).pptx
 
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdfPests of cotton_Sucking_Pests_Dr.UPR.pdf
Pests of cotton_Sucking_Pests_Dr.UPR.pdf
 
GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)GBSN - Microbiology (Unit 2)
GBSN - Microbiology (Unit 2)
 
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verifiedConnaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
Connaught Place, Delhi Call girls :8448380779 Model Escorts | 100% verified
 
biology HL practice questions IB BIOLOGY
biology HL practice questions IB BIOLOGYbiology HL practice questions IB BIOLOGY
biology HL practice questions IB BIOLOGY
 

COM2304: Intensity Transformation and Spatial Filtering – II Spatial Filtering and Smoothing

  • 1. COMPUTER GRAPHICS & IMAGE PROCESSING COM2304 Intensity Transformation and Spatial Filtering – II Spatial Filtering and Smoothing K.A.S.H.Kulathilake B.Sc. (Hons) IT (SLIIT), MCS (UCSC), M.Phil (UOM), SEDA(UK) Rajarata University of Sri Lanka Faculty of Applied Sciences Department of Physical Sciences
  • 2. Learning Outcomes COM2304 - Computer Graphics & Image Processing • At the end of this lecture, you should be able to; – describe the fundamentals of spatial filtering. – generating spatial filter masks. – identify smoothing via linear filters and non linear filters. – apply smoothing techniques for problem solving.
  • 3. Filters in Image Processing • Filter can accept or reject certain frequency components. • In image processing filters are mainly used to suppress either the high frequencies in the image, i.e. smoothing the image, or the low frequencies, i.e. enhancing/ sharpening or detecting edges in the image. • An image can be filtered either in the frequency or in the spatial domain. COM2304 - Computer Graphics & Image Processing
  • 4. Fundamentals of Frequency Domain Filtering • Frequency domain filtering involves ; – transforming the image into the frequency domain, – multiplying it with the frequency filter function and – re-transforming the result into the spatial domain. • The filter function is shaped so as to attenuate some frequencies and enhance others. • For example, a simple lowpass function is 1 for frequencies smaller than the cut-off frequency and 0 for all others. COM2304 - Computer Graphics & Image Processing
  • 5. Fundamentals of Spatial Filtering • Spatial filter contains two components; – MASK/ CONVOLUTION MATRIX/ KERNEL: A neighborhood (typically small rectangle:) – FILTER FUNCTION: A predefined operation that is performed on the image pixels encompassed by the neighborhood. • Spatial filtering is the method of choice in situations when only additive random noise is present. • Filtering creates a new pixel value with coordinates equal to the coordinates of the center of the neighborhood, and whose value is the result of the filtering operation. COM2304 - Computer Graphics & Image Processing
  • 6. Fundamentals of Spatial Filtering (Cont….) COM2304 - Computer Graphics & Image Processing
  • 7. Fundamentals of Spatial Filtering (Cont….) COM2304 - Computer Graphics & Image Processing If the operation performed on the image pixels is linear, then the filter is called a linear spatial filter, otherwise, the filter is non-linear.
  • 8. Fundamentals of Spatial Filtering (Cont….) • Spatial filtering of an image of size M×N with a filter of size m×n is given by the expression; • Where w is the mask and f is the image function, x and y are varied so that each pixel in w visits every pixel in f. • m = 2a+1 and n = 2b+1, where a and b are positive integers. • This concept is known as correlation. COM2304 - Computer Graphics & Image Processing
  • 9. Fundamentals of Spatial Filtering (Cont….) • There are two closely related concepts that must be understood clearly when performing linear spatial filtering – Correlation • Correlation is the process of moving a filter mask over the image and computing the sum of products at each location exactly as explained previously. – Convolution • The mechanics of convolution are the same as correlation except that the filter is first rotated by 180 degrees. COM2304 - Computer Graphics & Image Processing
  • 10. Fundamentals of Spatial Filtering (Cont….) COM2304 - Computer Graphics & Image Processing If the filter mask is symmetric, correlation and convolution yield the same result
  • 11. Mask/Kernel/ Convolution Matrix • In image processing, a kernel, convolution matrix, or mask is a small matrix. • It is useful for blurring, sharpening, embossing, edge detection, and more. • This is accomplished by means of convolution between a kernel and an image. COM2304 - Computer Graphics & Image Processing
  • 12. Mask/Kernel/ Convolution Matrix (Cont…) • Important Features of Kernel – Size: 3×3, 5×5, 9×9, 21×21 – Shape: rectangle, cross, strip, circular, diamond or user defined. – Coefficients / Values: set based on the operation. – Anchor point: mostly in middle COM2304 - Computer Graphics & Image Processing 0 -1 0 -1 5 -1 0 -1 0 3×3 Kernel Anchor Values for sharpening operation
  • 13. Mask/Kernel/ Convolution Matrix (Cont…) COM2304 - Computer Graphics & Image Processing 0 -1 0 -1 5 -1 0 -1 0 Kernel
  • 14. Mask/Kernel/ Convolution Matrix (Cont…) COM2304 - Computer Graphics & Image Processing http://setosa.io/ev/image-kernels/ https://en.wikipedia.org/wiki/Kernel_(image_processing)
  • 15. Convolution • Convolution is a simple mathematical operation which is fundamental to many common image processing operators. • This can be used in image processing to implement operators whose output pixel values are simple linear combinations of certain input pixel values. COM2304 - Computer Graphics & Image Processing
  • 16. Convolution (Cont…) COM2304 - Computer Graphics & Image Processing Each kernel position corresponds to a single output pixel, the value of which is calculated by multiplying together the kernel value and the underlying image pixel value for each of the cells in the kernel, and then adding all these numbers together. The convolution is performed by sliding the kernel over the image, generally starting at the top left corner.
  • 17. Convolution (Cont…) COM2304 - Computer Graphics & Image Processing
  • 18. Generating Spatial Filter Masks • Generating an m×n linear spatial filter requires that we specify mn mask coefficients. • These coefficients are selected based on what the filter is supposed to do. • There are different types of filters available, some of them are; – Linear filters - In signal processing, a linear filter is a filter whose output is a linear function of its input. – Continuous function based filters – e.g. Gaussian smoothing (it’s a kind of linear filter). – Non linear filters - In signal processing, a non-linear filter is a filter whose output is not a linear function of its input. COM2304 - Computer Graphics & Image Processing
  • 19. Generating Spatial Filter Masks (cont…) • Linear filters – Implement sum of products – ex: filters used for smoothing • Continuous function based filters – ex: Gaussian function of two variables as shown in the following equation; – Where σ is the standard deviation and coordinates x and y are the positive integers. – Recall that 2D Gaussian function has bell shape and the σ control the tightness of the bell. COM2304 - Computer Graphics & Image Processing
  • 20. Generating Spatial Filter Masks (cont…) • Non linear/ Order static filters – Non linear filters require to specify the size of the filter and the operation(s) to be performed on the image pixel contained in the filter. • ex: filter 5×5 filter centered at an arbitrary point and perform max operation. – Non linear filters are quiet powerful in some applications, than the linear filters. COM2304 - Computer Graphics & Image Processing
  • 21. Smoothing Spatial Filters • Smoothing filters are used for blurring and noise reduction. • Blurring is used in preprocessing tasks, such as removal of small details from an image prior to object extraction, and bridging of small gaps in lines or curves. • Noise reduction can be accomplished by blurring with a linear filter and also by nonlinear filtering. COM2304 - Computer Graphics & Image Processing
  • 22. Smoothing Linear Filters • Average /Mean Filter – The output is simply the average of the pixels contained in the neighborhood of the filter mask. – In smoothing filter, it replaces the value of every pixel in an image by the average of the intensity levels in the neighborhood defined by the filter mask. – This process result in an image with reduced “sharp” transitions in intensities. – Most obvious application of smoothing is noise reduction because random noise typically consists of sharp transitions in intensity levels. COM2304 - Computer Graphics & Image Processing
  • 23. Smoothing Linear Filters (Cont…) COM2304 - Computer Graphics & Image Processing
  • 24. Smoothing Linear Filters (Cont…) – Averaging filters blur edges, because edges represent the sharp intensity transition. – Average blurring smoothes the false contours that result from using an insufficient number of intensity levels. – A major use of averaging filters is in the reduction of “irrelevant” detail (pixel regions that are small with respect to the size of the filter mask) in an image. COM2304 - Computer Graphics & Image Processing
  • 25. Smoothing Linear Filters (Cont…) COM2304 - Computer Graphics & Image Processing Observe blurring occur during smoothing operation
  • 26. Smoothing Linear Filters (Cont…) – Let Sx,y represent the set of coordinates in neighbourhood of size m×n, centered at point (x, y). – The arithmetic mean filter computes the average value of the corrupted image g( x, y) in the area defined by Sx,y. – The value of the restored image f’ at point ( x, y) is simply the arithmetic mean computed using the pixels in the region defined by Sx,y. COM2304 - Computer Graphics & Image Processing   xySts tsg mn yxf ),( ),( 1 ),(ˆ
  • 27. Smoothing Linear Filters (Cont…) • There are different kinds of mean filters all of which exhibit slightly different behaviour: • Geometric Mean: – Achieves similar smoothing to the arithmetic mean, but tends to lose less image detail COM2304 - Computer Graphics & Image Processing mn Sts xy tsgyxf 1 ),( ),(),(ˆ          
  • 28. Smoothing Linear Filters (Cont…) • Harmonic Mean: – Works well for salt noise, but fails for pepper noise. – Also does well for other kinds of noise such as Gaussian noise COM2304 - Computer Graphics & Image Processing   xySts tsg mn yxf ),( ),( 1 ),(ˆ
  • 29. Smoothing Linear Filters (Cont…) • Contraharmonic Mean: – Q is the order of the filter and adjusting its value changes the filter’s behaviour. – Positive values of Q eliminate pepper noise. – Negative values of Q eliminate salt noise. – If Q =0 it represents the arithmetic filter. COM2304 - Computer Graphics & Image Processing       xy xy Sts Q Sts Q tsg tsg yxf ),( ),( 1 ),( ),( ),(ˆ
  • 30. Smoothing Linear Filters (Cont…) Original Image Image Corrupted By Gaussian Noise After A 3*3 Geometric Mean Filter After A 3*3 Arithmetic Mean Filter COM2304 - Computer Graphics & Image Processing
  • 31. Smoothing Linear Filters (Cont…) Image Corrupted By Pepper Noise Result of Filtering Above With 3*3 Contraharmonic Q=1.5 COM2304 - Computer Graphics & Image Processing
  • 32. Smoothing Linear Filters (Cont…) Image Corrupted By Salt Noise Result of Filtering Above With 3*3 Contraharmonic Q=-1.5 COM2304 - Computer Graphics & Image Processing
  • 33. Smoothing Linear Filters (Cont…) Choosing the wrong value for Q when using the contraharmonic filter can have drastic results COM2304 - Computer Graphics & Image Processing
  • 34. Smoothing Linear Filters (Cont…) • A spatial averaging filter in which all coefficients are equal is called a Box Filter. • The basic strategy behind weighting the center point the highest and then reducing the value of the coefficients as a function of increasing distance from the origin in spatial averaging filter is simply an attempt to reduce blurring in the smoothing process. COM2304 - Computer Graphics & Image Processing
  • 35. Smoothing Linear Filters (Cont…) • Gaussian Smoothing: – The Gaussian filter is a non-uniform low pass filter. – The kernel coefficients diminish with increasing distance from the kernel’s centre. – Central pixels have a higher weighting than those on the periphery. – Larger values of σ produce a wider peak (greater blurring). – Kernel size must increase with increasing σ to maintain the Gaussian nature of the filter (`bell-shaped') . – Gaussian kernel coefficients depend on the value of σ. – At the edge of the mask, coefficients must be close to 0. – The kernel is rotationally symmetric with no directional bias. – Gaussian filters might not preserve image brightness. COM2304 - Computer Graphics & Image Processing
  • 36. Smoothing Linear Filters (Cont…) • The Gaussian distribution in 1-D has the form: • Where σ is the standard deviation of the distribution. • We have also assumed that the distribution has a mean of zero (i.e. it is centered on the line x=0). COM2304 - Computer Graphics & Image Processing 1-D Gaussian distribution with mean 0 and σ=1
  • 37. Smoothing Linear Filters (Cont…) • In 2-D, an isotropic (i.e. circularly symmetric) Gaussian has the form: COM2304 - Computer Graphics & Image Processing 2-D Gaussian distribution with mean (0,0) and σ=1 Discrete approximation to Gaussian function with σ=1 The std. dev σ of the Gaussian determines the amount of smoothing.
  • 38. Smoothing Linear Filters (Cont…) COM2304 - Computer Graphics & Image Processing
  • 39. Smoothing Order Static (Nonlinear) Filters • The response of the order static or nonlinear filters is based on ordering (ranking) the pixels contained in the image area encompassed by the filter, and then replacing the value of the center pixel with the value determine by the ranking result. • Useful nonlinear filters include; – Median filter – Max and min filter – Midpoint filter COM2304 - Computer Graphics & Image Processing
  • 40. Smoothing Order Static (Nonlinear) Filters (Cont…) • Median Filter: – It can reduce certain typed of random noise with less blurring than the linear smoothing filters of similar size. – Provides excellent results when applying to reduce salt and pepper noise. COM2304 - Computer Graphics & Image Processing )},({),(ˆ ),( tsgmedianyxf xySts  
  • 41. Smoothing Order Static (Nonlinear) Filters (Cont…) COM2304 - Computer Graphics & Image Processing
  • 42. Smoothing Order Static (Nonlinear) Filters (Cont…) COM2304 - Computer Graphics & Image Processing
  • 43. Smoothing Order Static (Nonlinear) Filters (Cont…) • Median filter smoothes ("washes") all edges and boundaries and may "erase" all details whose size is about n/2× m/2, where n × m is a window size. • As a result, an image becomes "fuzzy". • Median filter is not so efficient for additive Gaussian noise removal, it yields to linear filters. COM2304 - Computer Graphics & Image Processing
  • 44. Smoothing Order Static (Nonlinear) Filters (Cont…) • Max Filter: • Min Filter: –Max filter is useful for finding the brightest points in an image and min filter for finding the darkest points in an image. –Max filter is good for pepper noise and min filter is good for salt noise COM2304 - Computer Graphics & Image Processing )},({max),(ˆ ),( tsgyxf xySts   )},({min),(ˆ ),( tsgyxf xySts  
  • 45. Smoothing Order Static (Nonlinear) Filters (Cont…) • Midpoint Filter: – Good for random Gaussian and uniform noise COM2304 - Computer Graphics & Image Processing       )},({min)},({max 2 1 ),(ˆ ),(),( tsgtsgyxf xyxy StsSts
  • 46. Smoothing Order Static (Nonlinear) Filters (Cont…) • Alpha-trimmed Mean Filter: – We can delete the d/2 lowest and d/2 highest grey levels. – So g(s, t) represents the remaining mn – d pixels. – When d= 0 : arithmetic mean filter. – Good for combination of salt and pepper and Gaussian noise. COM2304 - Computer Graphics & Image Processing   xySts tsg dmn yxf ),( ),( 1 ),(ˆ
  • 47. Smoothing Order Static (Nonlinear) Filters (Cont…) COM2304 - Computer Graphics & Image Processing
  • 48. Removing Periodic Noise • Removing periodic noise form an image involves removing a particular range of frequencies from that image. • Band reject filters can be used for this purpose. Out of the scope of this course -    COM2304 - Computer Graphics & Image Processing
  • 49. Reference • Chapter 03, Chapter 05 of Gonzalez, R.C., Woods, R.E., Digital Image Processing, 3rd ed. Addison-Wesley Pub. • http://setosa.io/ev/image-kernels/ • https://en.wikipedia.org/wiki/Kernel_(image_ processing) COM2304 - Computer Graphics & Image Processing
  • 50. Learning Outcomes Revisit • Now, you should be able to; – describe the fundamentals of spatial filtering. – generating spatial filter masks. – identify smoothing via linear filters and non linear filters. – apply smoothing techniques for problem solving. COM2304 - Computer Graphics & Image Processing
  • 51. QUESTIONS ? Next Lecture – Intensity Transformation and Spatial Filtering – III COM2304 - Computer Graphics & Image Processing