SlideShare una empresa de Scribd logo
1 de 31
Descargar para leer sin conexión
LOCAL NEIGHBORHOOD PROCESSING.
CONCEPT OF SPATIAL DOMAIN
FILTERING
CS-467 Digital Image Processing
1
Spatial Domain
• The Spatial Domain is a domain (the plane)
where a digital image is defined by spatial
coordinates of its pixels
• (Another domain considered in image
processing is the frequency domain where a
digital image is defined by braking down into
the spatial frequencies participating in its
formation – we will consider it later)
2
Local Neighborhood in
Image Processing
• Many image processing operations in the
spatial domain (particularly, spatial domain
filtering) are reduced to local neighborhood
processing
3
Local Neighborhood in
Image Processing
• Let be the set of coordinates of a
neighborhood centered on an arbitrary pixel
(x, y) in an image f.
• Neighborhood processing generates a
corresponding pixel at the same coordinates
in an output image g, such that the intensity
value in that that pixel is determined by a
specific operation involving the pixels in the
input image with coordinates in
4
xyS
xyS
Local Neighborhood in
Image Processing
5
Local Neighborhood in
Spatial Domain Image Processing
• The spatial domain processing can be
represented by the following expression
where f(x,y) is the input image, g(x,y) is the
output image and T is an operator defined
over a local neighborhood of pixel with the
coordinates (x,y)
6
( ) ( )( ), ,Tg x y f x y=
Local Contrast Enhancement
• Local contrast enhancement is utilized
through local histogram processing
• The local histogram in an n x m window of
a digital image with intensity levels {0,1,…,L-1}
is a discrete function
7
xyS
; 0,1,..., 1xy
xy
S k k
S
h r n k L
 
= = − 
 
Local Contrast Enhancement
• Local contrast enhancement leads to better
visibility of local details and, as a result, to the
extraction of those details (not necessarily
small details) that are hidden in the areas with
a poor local contrast
• Local contrast enhancement can be utilized,
for example, through the same methods that
are used for the global contrast enhancement
8
Local Contrast Enhancement
9
© 1992-2008 R.C. Gonzalez & R.E. Woods
Filtering
• Filtering in signal processing is the process of
accepting (passing) or rejecting certain
frequency components
• Lowpass filters preserve low frequencies,
rejecting the high ones
• Highpass filters preserve high frequencies,
rejecting the low ones
10
Filtering
• Lowpass filters are used in image processing
for removal or reduction of noise
• Highpass filters are used in image processing
for edge detection and distinguishing of small
details
11
Models of Noise
• Models of noise
• Additive noise
• Multiplicative (speckle) noise
• Impulse noise
where is the probability of distortion ( in
percents is called the corruption rate)
12
( ) ( ), , ( , )g x y f x y x yη= +
( ) ( ), , ( , )g x y f x y x yη= ×
( )
( )
, ( , )
,
1 , ,
n
n
p x y
g x y
p f x y
η
= 
−
np np
100%np ⋅
The Goal of Noise Filtering
• The goal of noise filtering is to obtain the best
approximation of the “ideal” image
in terms of the mean square error (root mean
square error) or, which is the same, in terms
of PSNR
• Filtering is utilized through a filtering operator
applied to a noisy image:
13
( ),f x y( )ˆ ,f x y
( ) ( )( )ˆ , ,f x y F g x y=
“Ideal” Filtering
• If there are k realizations of the same image
scene corrupted by the same kind of additive
noise, and , then the original image
can be restored by taking component-wise
mean of its realizations:
• The larger is k, the closer is to
14
k → ∞
( ) ( )
( ) ( )
1
, , ( , ); 1,2,..., ,...
1ˆ , ,
i i
k
i
i
g x y f x y x y i k
f x y g x y
k
η
=
= + =
= ∑
( )ˆ ,f x y ( ),f x y
Linear Filters
• Linear filtering is utilized through a linear
operator
• The operator F is called linear, if for arbitrary
constants a and b the following property
holds:
15
( )( ) ( )( ) ( )
( )( ) ( )
, ( , ) , ( , )
, ( , )
F af x y b x y F af x y F b x y
aF f x y bF x y
η η
η
+ = + =
+
Linear Filters
• A filter, which is represented by a linear
operator is called a linear filter
• Ideally, a linear filter may separate an image
from additive noise. If F is a linear filter, then
and an image can be restored as follows
16
( )( ) ( )( ) ( )( ) ( ), , ( , ) , ( , )F g x y F f x y x y F f x y F x yη η= + = +
( ) ( )( )( ) ( )( ) ( )( )1 1
, , , ( , )f x y F F f x y F F g x y F x yη− −
= −
Linear and Nonlinear Filters
• Since can be estimated only in the
frequency domain and this estimation is
possible only for some particular kinds of
noise, the “ideal” method has a limited
applicability
• Speckle and impulse noise cannot be
separated from an image using a linear filter.
Thus, for their filtering nonlinear filters shall
be used
17
( )( , )F x yη
Linear and Nonlinear Filters
• A filter, which is represented by an operator,
which is not linear, is called a nonlinear filter
• Linear filters can be implemented in the
frequency domain (where they originally were
applied by Norbert Wiener in 1940s ) and in the
spatial domain
• Most of nonlinear filters can be implemented
only in the spatial domain (except some specific
nonlinear transformations of spectra that are
applicable only in the frequency domain)
18
Filter Design
• When any new filter is designed, then to test its
efficiency, the following model should be used:
A clean image shall be artificially corrupted using
a certain kind of noise
Then an artificially corrupted image shall be
filtered and the result shall be compared to the
“ideal” clean image in terms of PSNR
A filter showing stable good results, being applied
to different images (when compared to other
filters), should be considered good
19
Modeling of Additive Noise
• To add noise to a clean image, it is necessary to
generate a matrix of noise with a desired
distribution (Gaussian is most frequently used)
using a random numbers generator, with exactly
the same sizes as the ones of the clean image,
the same mean as the one of the clean image and
σn (standard deviation) equal to of the
clean image.
• Then this noise shall be added to the clean image
component-wise and their common mean shall
be component-wise subtracted from the sum
20
0.2 0.5σ σ−
( ) ( ), , ( , )g x y f x y x y meanη= + −
Spatial Domain Filtering
• Any spatial domain filter is reduced to processing
of a local neighborhood of every pixel
• Filtering creates a new pixel with coordinates
equal to the coordinates of the center of the
neighborhood and whose value is the result of
the filtering operator applied to the
neighborhood of the processed pixel
• Filtering of different pixels is typically
independent and in such a case can be done in
parallel
21
Spatial Domain Filtering
• Any lowpass spatial domain filter averages
intensities (linearly or non-linearly) over an
n x m local neighborhood of each pixel and
smooths the image due to this averaging. This
means that some image details whose size is
about 0.5n x 0.5m may become
undistinguishable.
• Lowpass spatial domain filters are used for noise
reduction. Averaging over each n x m local
neighborhood , they “dissolve” a noise in an
image
22
Spatial Domain Filtering
23
Linear Spatial Domain Filtering
• Linear spatial filtering of an image of size
M x N with a filter of size m x n is defined by
the expression
where g(x,y) is an image to be processed,
a=(m-1)/2, b=(n-1)/2, and the weights w(s,t)
create a filter kernel
24
( ) ( ) ( )ˆ , , ,
a b
s a t b
f x y w s t g x s y t
=− =−
= + +∑ ∑
Linear Spatial Domain Filtering
25
© 1992-2008 R.C. Gonzalez & R.E. Woods
Border Effects in
Spatial Domain Filtering
• To process image borders, it is necessary to
extend an image in all directions, otherwise it
will not be possible to build local
neighborhoods for the border pixels
• The simplest way of such an extension is zero-
padding . However, this method always
creates a “black” frame along the image
borders.
26
Border Effects in
Spatial Domain Filtering
• To take care of border effects, mirroring shall
be used. An N x M image, before it is
processed by a spatial domain filter with an
n x m kernel, shall be extended to an
image as follows
27
2 2
n m
N M
   
+ × +      
( )
( )
( )
( )
( )
( )
, ; 0,1,..., 1, 0,1,..., 1
, ; 1,..., / 2 , 0,1,..., 1
( 1) ( 1), ; ,..., / 2 1, 0,1,..., 1
, ; 0,1,..., 1, 1,..., / 2,
,( 1) ( 1) ; 0,1,..., 1, ,...
f x y x N y M
f x y x n y M
f N x N y x N N n y M
f x y x N y mf x y
f x N y N x N y N
= −= −
− =− − = −  
− − − + = + −= −  
− = − =− −  =  
− − − + = −=

( )
( )
, / 2 1
, ; , 1, 2,...
( 1) ( 1),( 1) ( 1) ; , , 1,...
N m
f x y x y
f N x N N y N x y N N






 + −  
− − =− −

− − − + − − − + = +
Border Effects in
Spatial Domain Filtering
28
0th row
M-1th row
0th
col.
1st
col.
-1th row
Mth row
-1st
col.
Mirroring for a 3x3 local neighborhood window
Arithmetic Mean Filter – the Simplest
Spatial Domain Linear Filter
• Arithmetic mean filter replaces the intensity
value in each pixel by the local arithmetic
mean taken over a local n x m processing
window:
• This corresponds to the filter kernel (mask)
29
( ) ( )
1ˆ , ,
a b
s a t b
f x y g x s y t
nm =− =−
= + +∑ ∑
1 1 1
...
1 1 1
...
... ... ... ...
1 1 1
...
nm nm nm
nm nm nm
nm nm nm
 
 
 
 
 
 
 
 
 
 
Useful Filtering Mask
• Vertical and horizontal adjacent pixels in a 3x3
window are located “closer” to the center of the
window than the diagonal pixels. Evidently, the
distance from a center of a square to any of its sides
is shorter than the one to its vertices:
30
Useful Filtering Mask
• So it can be reasonable to emphasize
contribution of the central pixel and its closest
neighbors to the resulting intensity value. This
can be done by the following filter mask
(kernel)
31
1 2 1
1
2 4 2
16
1 2 1
 
 
 
 
 

Más contenido relacionado

La actualidad más candente

Image processing spatialfiltering
Image processing spatialfilteringImage processing spatialfiltering
Image processing spatialfiltering
John Williams
 
Noise filtering
Noise filteringNoise filtering
Noise filtering
Alaa Ahmed
 
Digital image processing img smoothning
Digital image processing img smoothningDigital image processing img smoothning
Digital image processing img smoothning
Vinay Gupta
 

La actualidad más candente (20)

SPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSINGSPATIAL FILTERING IN IMAGE PROCESSING
SPATIAL FILTERING IN IMAGE PROCESSING
 
Filtering an image is to apply a convolution
Filtering an image is to apply a convolutionFiltering an image is to apply a convolution
Filtering an image is to apply a convolution
 
Image processing spatialfiltering
Image processing spatialfilteringImage processing spatialfiltering
Image processing spatialfiltering
 
Module 2
Module 2Module 2
Module 2
 
Image filtering in Digital image processing
Image filtering in Digital image processingImage filtering in Digital image processing
Image filtering in Digital image processing
 
2.spatial filtering
2.spatial filtering2.spatial filtering
2.spatial filtering
 
04 image enhancement edge detection
04 image enhancement edge detection04 image enhancement edge detection
04 image enhancement edge detection
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Sharpening spatial filters
Sharpening spatial filtersSharpening spatial filters
Sharpening spatial filters
 
Spatial filtering
Spatial filteringSpatial filtering
Spatial filtering
 
Noise filtering
Noise filteringNoise filtering
Noise filtering
 
Module 31
Module 31Module 31
Module 31
 
Smoothing Filters in Spatial Domain
Smoothing Filters in Spatial DomainSmoothing Filters in Spatial Domain
Smoothing Filters in Spatial Domain
 
Smoothing in Digital Image Processing
Smoothing in Digital Image ProcessingSmoothing in Digital Image Processing
Smoothing in Digital Image Processing
 
Unit3 dip
Unit3 dipUnit3 dip
Unit3 dip
 
Digital image processing
Digital image processingDigital image processing
Digital image processing
 
Image Processing: Spatial filters
Image Processing: Spatial filtersImage Processing: Spatial filters
Image Processing: Spatial filters
 
03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial
 
Digital image processing img smoothning
Digital image processing img smoothningDigital image processing img smoothning
Digital image processing img smoothning
 
New approach for generalised unsharp masking alogorithm
New approach for generalised unsharp masking alogorithmNew approach for generalised unsharp masking alogorithm
New approach for generalised unsharp masking alogorithm
 

Destacado

Housing chapter 2
Housing chapter 2Housing chapter 2
Housing chapter 2
lbonner1987
 
Chapter 1 housing and human needs
Chapter 1 housing and human needsChapter 1 housing and human needs
Chapter 1 housing and human needs
lbonner1987
 
low cost housing delhi
low cost housing delhilow cost housing delhi
low cost housing delhi
richa_15b
 
Planning concepts
Planning conceptsPlanning concepts
Planning concepts
ctlachu
 

Destacado (15)

Edna and sheila slideshare composite
Edna and sheila slideshare compositeEdna and sheila slideshare composite
Edna and sheila slideshare composite
 
Housing & its Basic Requirements | SurgicoMed.com
Housing & its Basic Requirements | SurgicoMed.comHousing & its Basic Requirements | SurgicoMed.com
Housing & its Basic Requirements | SurgicoMed.com
 
PAS 106 Workshops Leeds
PAS 106 Workshops LeedsPAS 106 Workshops Leeds
PAS 106 Workshops Leeds
 
Christopher Cant S106 presentation
Christopher Cant S106 presentationChristopher Cant S106 presentation
Christopher Cant S106 presentation
 
Housing chapter 2
Housing chapter 2Housing chapter 2
Housing chapter 2
 
Housing Standards Review: Building Regulations Perspective
Housing Standards Review: Building Regulations PerspectiveHousing Standards Review: Building Regulations Perspective
Housing Standards Review: Building Regulations Perspective
 
image compression using matlab project report
image compression  using matlab project reportimage compression  using matlab project report
image compression using matlab project report
 
Chapter 1 housing and human needs
Chapter 1 housing and human needsChapter 1 housing and human needs
Chapter 1 housing and human needs
 
Low Cost Housing Concept
Low Cost Housing ConceptLow Cost Housing Concept
Low Cost Housing Concept
 
Fulltext
FulltextFulltext
Fulltext
 
Neighborhood
NeighborhoodNeighborhood
Neighborhood
 
Housing powerpoint
Housing powerpointHousing powerpoint
Housing powerpoint
 
low cost housing delhi
low cost housing delhilow cost housing delhi
low cost housing delhi
 
Affordable housing in india
Affordable housing in indiaAffordable housing in india
Affordable housing in india
 
Planning concepts
Planning conceptsPlanning concepts
Planning concepts
 

Similar a Lecture 4

12-Image enhancement and filtering.ppt
12-Image enhancement and filtering.ppt12-Image enhancement and filtering.ppt
12-Image enhancement and filtering.ppt
AJAYMALIK97
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
Ayaelshiwi
 
05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt
pawankamal3
 
DIP -Unit 3 ppt.pptx
DIP -Unit 3 ppt.pptxDIP -Unit 3 ppt.pptx
DIP -Unit 3 ppt.pptx
1DA20CS085Nithyashre
 

Similar a Lecture 4 (20)

Image enhancement
Image enhancementImage enhancement
Image enhancement
 
3 intensity transformations and spatial filtering slides
3 intensity transformations and spatial filtering slides3 intensity transformations and spatial filtering slides
3 intensity transformations and spatial filtering slides
 
unit-3.ppt
unit-3.pptunit-3.ppt
unit-3.ppt
 
06 spatial filtering DIP
06 spatial filtering DIP06 spatial filtering DIP
06 spatial filtering DIP
 
Spatial Filtering in intro image processingr
Spatial Filtering in intro image processingrSpatial Filtering in intro image processingr
Spatial Filtering in intro image processingr
 
PPT s04-machine vision-s2
PPT s04-machine vision-s2PPT s04-machine vision-s2
PPT s04-machine vision-s2
 
Adaptive unsharp masking
Adaptive unsharp maskingAdaptive unsharp masking
Adaptive unsharp masking
 
CSE367 Lecture- image sinal processing lecture
CSE367 Lecture- image sinal processing lectureCSE367 Lecture- image sinal processing lecture
CSE367 Lecture- image sinal processing lecture
 
12-Image enhancement and filtering.ppt
12-Image enhancement and filtering.ppt12-Image enhancement and filtering.ppt
12-Image enhancement and filtering.ppt
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
COM2304: Intensity Transformation and Spatial Filtering – II Spatial Filterin...
COM2304: Intensity Transformation and Spatial Filtering – II Spatial Filterin...COM2304: Intensity Transformation and Spatial Filtering – II Spatial Filterin...
COM2304: Intensity Transformation and Spatial Filtering – II Spatial Filterin...
 
Image processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filtersImage processing, Noise, Noise Removal filters
Image processing, Noise, Noise Removal filters
 
05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt05_Spatial_Filtering.ppt
05_Spatial_Filtering.ppt
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Digital image processing - Image Enhancement (MATERIAL)
Digital image processing  - Image Enhancement (MATERIAL)Digital image processing  - Image Enhancement (MATERIAL)
Digital image processing - Image Enhancement (MATERIAL)
 
Digital Image Processing - Image Enhancement
Digital Image Processing  - Image EnhancementDigital Image Processing  - Image Enhancement
Digital Image Processing - Image Enhancement
 
Spatial Domain Filtering.pdf
Spatial Domain Filtering.pdfSpatial Domain Filtering.pdf
Spatial Domain Filtering.pdf
 
DIP -Unit 3 ppt.pptx
DIP -Unit 3 ppt.pptxDIP -Unit 3 ppt.pptx
DIP -Unit 3 ppt.pptx
 
Edge detection
Edge detectionEdge detection
Edge detection
 
2. filtering basics
2. filtering basics2. filtering basics
2. filtering basics
 

Más de Wael Sharba (20)

Project 8
Project 8Project 8
Project 8
 
Project 7
Project 7Project 7
Project 7
 
Project 6
Project 6Project 6
Project 6
 
Project 5
Project 5Project 5
Project 5
 
Project 4
Project 4Project 4
Project 4
 
Project 2
Project 2Project 2
Project 2
 
Project 1
Project 1Project 1
Project 1
 
Project 3
Project 3Project 3
Project 3
 
Project 9
Project 9Project 9
Project 9
 
Lecture 14
Lecture 14Lecture 14
Lecture 14
 
Lecture 13
Lecture 13Lecture 13
Lecture 13
 
Lecture 11
Lecture 11Lecture 11
Lecture 11
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Microsoft system center 1
Microsoft system center 1Microsoft system center 1
Microsoft system center 1
 
Sig2014 vision correcting display
Sig2014 vision correcting displaySig2014 vision correcting display
Sig2014 vision correcting display
 

Último

Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 

Lecture 4

  • 1. LOCAL NEIGHBORHOOD PROCESSING. CONCEPT OF SPATIAL DOMAIN FILTERING CS-467 Digital Image Processing 1
  • 2. Spatial Domain • The Spatial Domain is a domain (the plane) where a digital image is defined by spatial coordinates of its pixels • (Another domain considered in image processing is the frequency domain where a digital image is defined by braking down into the spatial frequencies participating in its formation – we will consider it later) 2
  • 3. Local Neighborhood in Image Processing • Many image processing operations in the spatial domain (particularly, spatial domain filtering) are reduced to local neighborhood processing 3
  • 4. Local Neighborhood in Image Processing • Let be the set of coordinates of a neighborhood centered on an arbitrary pixel (x, y) in an image f. • Neighborhood processing generates a corresponding pixel at the same coordinates in an output image g, such that the intensity value in that that pixel is determined by a specific operation involving the pixels in the input image with coordinates in 4 xyS xyS
  • 6. Local Neighborhood in Spatial Domain Image Processing • The spatial domain processing can be represented by the following expression where f(x,y) is the input image, g(x,y) is the output image and T is an operator defined over a local neighborhood of pixel with the coordinates (x,y) 6 ( ) ( )( ), ,Tg x y f x y=
  • 7. Local Contrast Enhancement • Local contrast enhancement is utilized through local histogram processing • The local histogram in an n x m window of a digital image with intensity levels {0,1,…,L-1} is a discrete function 7 xyS ; 0,1,..., 1xy xy S k k S h r n k L   = = −   
  • 8. Local Contrast Enhancement • Local contrast enhancement leads to better visibility of local details and, as a result, to the extraction of those details (not necessarily small details) that are hidden in the areas with a poor local contrast • Local contrast enhancement can be utilized, for example, through the same methods that are used for the global contrast enhancement 8
  • 9. Local Contrast Enhancement 9 © 1992-2008 R.C. Gonzalez & R.E. Woods
  • 10. Filtering • Filtering in signal processing is the process of accepting (passing) or rejecting certain frequency components • Lowpass filters preserve low frequencies, rejecting the high ones • Highpass filters preserve high frequencies, rejecting the low ones 10
  • 11. Filtering • Lowpass filters are used in image processing for removal or reduction of noise • Highpass filters are used in image processing for edge detection and distinguishing of small details 11
  • 12. Models of Noise • Models of noise • Additive noise • Multiplicative (speckle) noise • Impulse noise where is the probability of distortion ( in percents is called the corruption rate) 12 ( ) ( ), , ( , )g x y f x y x yη= + ( ) ( ), , ( , )g x y f x y x yη= × ( ) ( ) , ( , ) , 1 , , n n p x y g x y p f x y η =  − np np 100%np ⋅
  • 13. The Goal of Noise Filtering • The goal of noise filtering is to obtain the best approximation of the “ideal” image in terms of the mean square error (root mean square error) or, which is the same, in terms of PSNR • Filtering is utilized through a filtering operator applied to a noisy image: 13 ( ),f x y( )ˆ ,f x y ( ) ( )( )ˆ , ,f x y F g x y=
  • 14. “Ideal” Filtering • If there are k realizations of the same image scene corrupted by the same kind of additive noise, and , then the original image can be restored by taking component-wise mean of its realizations: • The larger is k, the closer is to 14 k → ∞ ( ) ( ) ( ) ( ) 1 , , ( , ); 1,2,..., ,... 1ˆ , , i i k i i g x y f x y x y i k f x y g x y k η = = + = = ∑ ( )ˆ ,f x y ( ),f x y
  • 15. Linear Filters • Linear filtering is utilized through a linear operator • The operator F is called linear, if for arbitrary constants a and b the following property holds: 15 ( )( ) ( )( ) ( ) ( )( ) ( ) , ( , ) , ( , ) , ( , ) F af x y b x y F af x y F b x y aF f x y bF x y η η η + = + = +
  • 16. Linear Filters • A filter, which is represented by a linear operator is called a linear filter • Ideally, a linear filter may separate an image from additive noise. If F is a linear filter, then and an image can be restored as follows 16 ( )( ) ( )( ) ( )( ) ( ), , ( , ) , ( , )F g x y F f x y x y F f x y F x yη η= + = + ( ) ( )( )( ) ( )( ) ( )( )1 1 , , , ( , )f x y F F f x y F F g x y F x yη− − = −
  • 17. Linear and Nonlinear Filters • Since can be estimated only in the frequency domain and this estimation is possible only for some particular kinds of noise, the “ideal” method has a limited applicability • Speckle and impulse noise cannot be separated from an image using a linear filter. Thus, for their filtering nonlinear filters shall be used 17 ( )( , )F x yη
  • 18. Linear and Nonlinear Filters • A filter, which is represented by an operator, which is not linear, is called a nonlinear filter • Linear filters can be implemented in the frequency domain (where they originally were applied by Norbert Wiener in 1940s ) and in the spatial domain • Most of nonlinear filters can be implemented only in the spatial domain (except some specific nonlinear transformations of spectra that are applicable only in the frequency domain) 18
  • 19. Filter Design • When any new filter is designed, then to test its efficiency, the following model should be used: A clean image shall be artificially corrupted using a certain kind of noise Then an artificially corrupted image shall be filtered and the result shall be compared to the “ideal” clean image in terms of PSNR A filter showing stable good results, being applied to different images (when compared to other filters), should be considered good 19
  • 20. Modeling of Additive Noise • To add noise to a clean image, it is necessary to generate a matrix of noise with a desired distribution (Gaussian is most frequently used) using a random numbers generator, with exactly the same sizes as the ones of the clean image, the same mean as the one of the clean image and σn (standard deviation) equal to of the clean image. • Then this noise shall be added to the clean image component-wise and their common mean shall be component-wise subtracted from the sum 20 0.2 0.5σ σ− ( ) ( ), , ( , )g x y f x y x y meanη= + −
  • 21. Spatial Domain Filtering • Any spatial domain filter is reduced to processing of a local neighborhood of every pixel • Filtering creates a new pixel with coordinates equal to the coordinates of the center of the neighborhood and whose value is the result of the filtering operator applied to the neighborhood of the processed pixel • Filtering of different pixels is typically independent and in such a case can be done in parallel 21
  • 22. Spatial Domain Filtering • Any lowpass spatial domain filter averages intensities (linearly or non-linearly) over an n x m local neighborhood of each pixel and smooths the image due to this averaging. This means that some image details whose size is about 0.5n x 0.5m may become undistinguishable. • Lowpass spatial domain filters are used for noise reduction. Averaging over each n x m local neighborhood , they “dissolve” a noise in an image 22
  • 24. Linear Spatial Domain Filtering • Linear spatial filtering of an image of size M x N with a filter of size m x n is defined by the expression where g(x,y) is an image to be processed, a=(m-1)/2, b=(n-1)/2, and the weights w(s,t) create a filter kernel 24 ( ) ( ) ( )ˆ , , , a b s a t b f x y w s t g x s y t =− =− = + +∑ ∑
  • 25. Linear Spatial Domain Filtering 25 © 1992-2008 R.C. Gonzalez & R.E. Woods
  • 26. Border Effects in Spatial Domain Filtering • To process image borders, it is necessary to extend an image in all directions, otherwise it will not be possible to build local neighborhoods for the border pixels • The simplest way of such an extension is zero- padding . However, this method always creates a “black” frame along the image borders. 26
  • 27. Border Effects in Spatial Domain Filtering • To take care of border effects, mirroring shall be used. An N x M image, before it is processed by a spatial domain filter with an n x m kernel, shall be extended to an image as follows 27 2 2 n m N M     + × +       ( ) ( ) ( ) ( ) ( ) ( ) , ; 0,1,..., 1, 0,1,..., 1 , ; 1,..., / 2 , 0,1,..., 1 ( 1) ( 1), ; ,..., / 2 1, 0,1,..., 1 , ; 0,1,..., 1, 1,..., / 2, ,( 1) ( 1) ; 0,1,..., 1, ,... f x y x N y M f x y x n y M f N x N y x N N n y M f x y x N y mf x y f x N y N x N y N = −= − − =− − = −   − − − + = + −= −   − = − =− −  =   − − − + = −=  ( ) ( ) , / 2 1 , ; , 1, 2,... ( 1) ( 1),( 1) ( 1) ; , , 1,... N m f x y x y f N x N N y N x y N N        + −   − − =− −  − − − + − − − + = +
  • 28. Border Effects in Spatial Domain Filtering 28 0th row M-1th row 0th col. 1st col. -1th row Mth row -1st col. Mirroring for a 3x3 local neighborhood window
  • 29. Arithmetic Mean Filter – the Simplest Spatial Domain Linear Filter • Arithmetic mean filter replaces the intensity value in each pixel by the local arithmetic mean taken over a local n x m processing window: • This corresponds to the filter kernel (mask) 29 ( ) ( ) 1ˆ , , a b s a t b f x y g x s y t nm =− =− = + +∑ ∑ 1 1 1 ... 1 1 1 ... ... ... ... ... 1 1 1 ... nm nm nm nm nm nm nm nm nm                    
  • 30. Useful Filtering Mask • Vertical and horizontal adjacent pixels in a 3x3 window are located “closer” to the center of the window than the diagonal pixels. Evidently, the distance from a center of a square to any of its sides is shorter than the one to its vertices: 30
  • 31. Useful Filtering Mask • So it can be reasonable to emphasize contribution of the central pixel and its closest neighbors to the resulting intensity value. This can be done by the following filter mask (kernel) 31 1 2 1 1 2 4 2 16 1 2 1          