0% found this document useful (0 votes)
6 views39 pages

Lecture-5 (Filtering Mechanisms)

Uploaded by

eisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views39 pages

Lecture-5 (Filtering Mechanisms)

Uploaded by

eisha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

Spatial and Frequency-domain Filters

 Enhancement using arithmetic  Sharpening Spatial filters,


/logic operations, - Foundation,
- Image subtraction, - Step and ramp discontinuities.
- image averaging.
 Frequency Domain,
 Basics of spatial filtering, - Fourier transform.
- Linear spatial filtering,
 Smoothing Frequency-Domain
 Piecewise-linear transform Filters,
functions, - Ideal lowpass filter,
- Smoothing linear filter, - Butterworth lowpass filter,
- box filters. - Gaussian lowpass filter.
 Order-Statistics (Nonlinear)
filters,
- Median filters,
@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)
1. Enhancement Using Arithmetic/Logic Operations
(1/6)
 Arithmetic/logic operations involves:
– images are performed on a pixel-by-pixel basis between two or more images.
For Example;
- subtraction of two images results in a new image.
- whose pixel at coordinates (x, y) is the difference between the pixels in that
same location on the two images being subtracted.

 Actual mechanisms of implementation arithmetic/logic operations


can be done, sequentially one pixel at a time, or in parallel.

- To implement the AND, OR and NOT logic operators because these three
operators are functionally complete.
- Example, performing the NOT operation on a black, 8-bit pixel produces a
white pixel.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


1. Enhancement Using Arithmetic/Logic Operations
(2/6)
 Arithmetic/logic operations involves:
– In the AND or OR image masks, light represents a binary 1 and dark
represents a binary 0.
– Masking sometimes is referring to as region of interest (ROI) processing.

Figure: Arithmetic/Logic Operations such as NOT, AND and OR for images A and B

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


1. Enhancement Using Arithmetic/Logic Operations
(3/6)
(Assignment)

1. Apply AND, OR and NOT operators at different


scene datasets.

2. Make manual ROI processing at face datasets.

3. Develop ROI technique automatically over pedestrian


datasets.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


1. Enhancement Using Arithmetic/Logic Operations
(4/6)
 Arithmetic/logic operations involves:
– In the arithmetic operation, subtraction and addition are the most useful for
image enhancement.
– We consider divide of two images simply
– as multiplication of an image by the reciprocal of the other.

 Types of Arithmetic/logic operations:


1) Image Subtraction:
 The difference between two image f (x,y) and h (x,y), expressed as

g (x,y) = f (x,y) - h (x,y)

- is obtained by` computing the difference between all pixels from f and h.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


1. Enhancement Using Arithmetic/Logic Operations
(5/6)
 Types of Arithmetic/logic operations:
1) Image Subtraction:
– One of the most commercially successful and beneficial uses of image
subtraction is in the area of medical imaging called mask mode radiography.

– In this case h(x,y), the mask, is an X-ray image of a region of a patient’s body
captured by an intensified TV camera located opposite an X-ray source.
– The procedure consists of injecting a contrast medium into the patient’s
bloodstream, taking a series of images having same anatomical region,
– After subtracting this mask from the series of incoming images after injection
of the contrast medium.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


1. Enhancement Using Arithmetic/Logic Operations
(6/6)
 Types of Arithmetic/logic operations:
2) Image Averaging:
 Consider a noisy image g (x, y) formed by the addition of noise n (x, y) to an
original image f (x, y); that is

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


2. Basics of Spatial Filtering (1/3)
 Neighborhood operations work with the :
- values of the image pixels in the neighborhood and the corresponding values of a
subimage that has the same dimensions as the neighborhood.

 This subimage is called as;


- filter,
- mask, kernel,
- template or windowing,

 While, windowing is the most prevalent terminology;


- the values in a filter subimage are refereed to as coefficients, rather than pixels.

 Filtering is a technique for modifying or enhancing an image.


- For example, you can filter an image to emphasize certain features or remove
other features.
- filtering include smoothing, sharpening, and edge enhancement.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


2. Basics of Spatial Filtering (2/3)
 This process consists simply of moving the filter mask from point
to point in an image. At each point (x, y), the response of the filter:
- at that point is calculated using a predefined relationship.

1) Linear Spatial Filtering:


 response is given by a sum of products of the filter coefficients and
the corresponding image pixels in the area spanned by the filter
mask.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


2. Basics of Spatial Filtering (3/3)
1) Linear Spatial Filtering:
- w (-1,-1) f(x-1,y-1) + w (-1,0) f (x-1,y) + ………………
………………………...............+ w(1,0)f(x+1,y) +
w(1,1)f(x+1,y+1)

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


3. Smoothing Spatial Filters (1/10)
 Smoothing filters are used for;
- blurring and for noise reduction.

 Blurring is used in preprocessing step, such as;


- removal of small details from an image to object extraction and
- bridge of small gaps in lines or curves.

 Noise reduction can be accomplished by blurring with a;


- linear filter and
- non-linear filtering.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


3. Smoothing Spatial Filters (2/10)

Types of Smoothing Spatial Filters:


1) Linear (Average) Filters:-
Output of a smoothing, linear spatial filter is simply the average of the
pixels contained in the neighborhood of the filter mask.
- This filters sometimes are classed average filters, they also are refereed to a
lowpass filters.

However, edges also are characterized by sharp transitions on gray levels,


so averaging filters have the undesirable side effect that they blur edges.
- A major use of Averaging Filters is in the reduction of “irrelevant” details in
an image.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


3. Smoothing Spatial Filters (3/10)
Types of Smoothing Spatial Filters:
1) Linear (Average) Filters (For Example)

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


3. Smoothing Spatial Filters (4/10)
(Class Participation)
Types of Smoothing Spatial Filters:
 Define 3x3 averaging smoothing filter. What is the structure of
matrix if we have an;
=> average value = 32,
=> average value = 128,
=> average value = 256,
=> average value = 64,
=> average value = 512,
=> average value = 1024,

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


3. Smoothing Spatial Filters (5/10)

Types of Smoothing Spatial Filters:


2) Box (Weighted average) Filters:-
A spatial averaging filter in which all
coefficients are equal is sometime called a box
filter.

The 2nd mask so-called weighted average,


terminology used to indicate that pixels are
multiplied by different coefficients.

In the mask, (b-f) the pixel at the center of


the mask is multiplied by a higher value than
any other, thus giving this pixel more
importance in the calculation of the average.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


3. Smoothing Spatial Filters (6/10)
Types of Smoothing Spatial Filters:
2) Box (Weighted average) Filters:-
Basic strategy:
- weighting the center point the highest.
- Then, reducing the value of the coefficients as a function of
increasing distance from the origin is simply an attempt to reduce
blurring in the smoothing process.
The general implementation for filtering an M  N image
with a weighted averaging filter of size m  n is given
a b

  w( s, t ) f ( x  s, y  t )
g ( x, y )  s  a t  b
a b

  w( s, t )
s  a t  b

where m  2 a  1, n  2b  1.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


3. Smoothing Spatial Filters (8/10)
Types of Smoothing Spatial Filters:
3) Order-Statistics Filters (Non-Linear):-
Order-statistics filters are non-linear spatial filters whose response
is based on ordering (ranking).
- the pixel contained in the image area encompassed by the filters.
- then, replace the value of the center pixel with the value determined by the
ranking result.

For Example :
- this category used medium filter, which, replaces the value of the
pixel by the medium of the gray levels in the neighborhood of that
pixel.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


3. Smoothing Spatial Filters (9/10)
Types of Smoothing Spatial Filters:
3) Order-Statistics Filters (Non-Linear):-
Medium filters are:
- Particularly effective in the presence of impulse noise, also called salt-and-
pepper noise because of its appearance as white and black dots superimposed on an
image.
- When several values in a neighborhood are the same, all equal values are
grouped.

For Example; Suppose that a 3x3 neighborhood has values


(10,20,20,20,15,20,20,25,100).
These values are sorted as ( 10,15, 20,20,20,20,20,25,100), which results in the
median of 20.
Thus, the principal function of medium filter is to force points with distinct gray
levels to be more like their neighbors.
In this case “eliminated” means forced to the medium intensity of the neighbors.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


3. Smoothing Spatial Filters (10/10)
Types of Smoothing Spatial Filters:
3) Order-Statistics Filters (Non-Linear):-
Example: Use of Median Filtering for Noise Reduction

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


4. Image Enhancement in the Frequency Domain
 Fourier’s contribution in this
particular field states that:
– Any function that periodically
repeats itself can be expressed as
the sum of sines and/or cosines of
difference frequencies, each
multiplied by a different coefficient.

– First time practical processing and


meaningful interpretation as :

 Medical monitors and scanners


to modern electronics
communication.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


4.1 One-Dimensional Fourier Transform and its
Inverse

The Fourier Transform of a continous function f (t )



F (  )  { f (t )}   f (t )e j 2t dt


The Inverse Fourier Transform of F (  )



f (t )   {F (  )}   F (  )e j 2t d 
1


@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


4.1 One-Dimensional Fourier Transform and its
Inverse

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


4.2 Filtering in the Frequency Domain (1/5)

 F (u , v) contains all values of f (x,y), modified by the values of


the exponential terms.

 The slowest varying frequency component (u = v = 0)


corresponds to the average gray level of an image.

 As we move away from the origin of the transform,


- the low frequencies correspond to the slowly varying
components of an image.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


4.2 Filtering in the Frequency Domain (2/5)

 Steps of filtering in the frequency domain:-


- Filtering in the frequency domain is straight forward. It consists of the
following steps.

1) Multiple the input image by (-1)x+y to center the transform.


2) Compute F (u, v), the DFT of the image.
3) Multiple F (u, v) by the filter function H (u, v).
4) Compute the inverse DFT.

H (u, v) is called filter because it suppressed certain frequencies I


the transform while leaving other unchanged.

G (u , v) = H (u, v) * F(u, v)

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


4.2 Filtering in the Frequency Domain (3/5)

 The multiplication of H and F involves two–dimensional functions.


 The first element of H multiplies the first element of F, the second
element of H multiplies the second element of F.

 Each component of H multiplies both the real and imaginary parts


of the corresponding component in F. Such a filter is called zero-
phase-shift filters.
Fourier Filter Inverse
transform function Fourier
H (u,v) transform
Pre-
F (u, v) H (u,v) F (u, v) Post-
Processing
Processed

F (x, y) g (x, y)
Input image Enhanced image
@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)
4.2 Filtering in the Frequency Domain (4/5)
 Low frequencies in the Fourier transform are responsible for the
general gray-level appearance of the image over smooth areas,

 A filter that attenuates high frequencies while “passing” low


frequencies is called a lowpass filter.
- is a filter that passes signals with a frequency lower than a selected cutoff
frequency.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


4.2 Filtering in the Frequency Domain (5/5)
 While, high frequencies are responsible for detail, such as edges
and noise.

 A filter that has the opposite characteristics is appropriately called a


highpass filter.
- is an electronic filter that passes signals with a frequency higher than a certain
cutoff frequency.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


5. Smoothing Frequency-Domain Filters
 These 3 filters cover the range from very sharp (ideal) to very
smooth (Gaussian) filter function.
(1) Ideal, (2) Butterworth and (3) Gaussian filters.

1) Ideal Lowpass filter:-


 A filter that “cut off” all high-frequency components of the Fourier
transform.
- Distance greater than a specified distance Do from the origin of the centered
transform.
 Such a filter is called a two-dimensional ideal filter (ILPF).
Ideal Lowpass Filters (ILPF)
1 if D(u, v)  D0
H (u, v)  
0 if D(u, v)  D0
@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)
5. Smoothing Frequency-Domain Filters

1) Ideal Lowpass filter:-


 In this case, the distance from any
point ( u, v) to the center (origin) of
the Fourier transform is given by:
D (u , v) = [ (u – M/2)2 + (v – N/2)2]1/2

 As the filter radius increase, less and


less power is removed, resulting in
less severe blurring.
- The circles superimposed on the spectrum
having radius of 5, 15, 30, 80, 230 pixels (the circle
of radius 5 is not easily visible).

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


5. Smoothing Frequency-Domain Filters
2) Butterworth Lowpass filter:-
 Butterworth filters are one of the most commonly used digital
filters in motion analysis.
 Cutoff frequency = Maximally flat magnitude filter
- Butterworth filter of order 1 has no ringing.
- Ringing generally is imperceptible in filters of order 2,
- but can become a significant factor in filters of higher order.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


5. Smoothing Frequency-Domain Filters

Butterworth Lowpass Filters (BLPF) of order n and


with cutoff frequency D0
1
H (u , v ) 
1   D(u, v) / D0 
2n

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


Comparison: ILPF vs BLPF

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


5. Smoothing Frequency-Domain Filters
 Gaussian filtering is used to blur images and remove noise and
detail. [ more effective at smoothing images]
 In one dimension, the Gaussian function is;

- where is the standard deviation of the distribution. The


distribution is assumed to have a mean of 0.
 Shown graphically, we see the familiar bell shaped Gaussian
distribution.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


5. Smoothing Frequency-Domain Filters

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


5. Smoothing Frequency-Domain Filters
3) Gaussian Lowpass filter:-
By letting   D0
 D 2 ( u ,v )/2 D02
H (u, v)  e

- where Do is the cutoff frequency. When D (u,v) = Do, the filter is


down to 0.607 of its maximum value.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


5. Smoothing Frequency-Domain Filters
3) Gaussian Lowpass filter:-

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


Examples: GLPF
3) Gaussian Lowpass filter:-
 Example is from the field of machine
perception, with application to
character recognition.
 (a) shows that the characters in this particular
document have distorted shapes due to lack
of resolution, and many of the characters are
broken.
- a machine recognition system has real
difficulties reading broken characters.
(a) (b)
 (b) shows how well characters can be
“repaired” by this simple process using
Gaussian lowpass filter with Do=80. The
image is size 444x508 pixels.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


Examples: GLPF
3) Gaussian Lowpass filter:-
- the second is from the printing and publishing industry; and

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)


Examples: GLPF
3) Gaussian Lowpass filter:-
- the third is related to processing satellite images.

@Copyrights: Digital Image Processing Organized by Dr. Ahmad Jalal (http://portals.au.edu.pk/imc/)

You might also like