0% found this document useful (0 votes)
20 views

DIP Lecture

The document discusses image enhancement in the spatial domain through spatial filtering techniques. It describes various linear and nonlinear spatial filters including averaging filters, median filters and other order statistic filters. It provides details on how spatial filtering works and examples of common filter masks.

Uploaded by

majdiyjalalm2
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

DIP Lecture

The document discusses image enhancement in the spatial domain through spatial filtering techniques. It describes various linear and nonlinear spatial filters including averaging filters, median filters and other order statistic filters. It provides details on how spatial filtering works and examples of common filter masks.

Uploaded by

majdiyjalalm2
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 35

Biomedical Engineering Department

Digital Image Processing (DIP)


4th Year
Image Enhancement in the Spatial Domain

Lecture (4)

Dr. Nedal Abdalaal Abdallh


Digital Image Processing
Image Enhancement in the Spatial
Domain

Pp 116- 124
Image Filtering
Input image Output image

(x,y) (x,y)

pointwise
transformation

Input image Output image

(x,y) (x,y)

neighbourhood
transformation
Image Filtering
The output g(x,y) can be a linear or non-linear
function of the set of input pixel grey levels { f(x-M,y-
M)…f(x+M,y+M}.

Input image f(x,y) Output image g(x,y)

(x-1,y-1)

(x,y) (x,y)

(x+1,y+1)
Spatial Filtering

use filter (can also be called as


mask/kernel/template or window)
the values in a filter sub image are referred to
as coefficients, rather than pixel.
our focus will be on masks of odd sizes, e.g.
3x3, 5x5,…
Spatial Filtering Process
Spatial Filtering Process

Response, R, of an m  n mask at any point (x, y)

Special consideration is given when the center of


the filter approach the boarder of the image.
Spatial Filtering Process

 Simply move 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.

R  w1 z1  w2 z 2  ...  wmn z mn
mn
  wi zi
i i
Basics of Spatial Filtering - Linear
Spatial filtering are filtering
operations performed on the
pixel intensities of an
image and not on the
frequency components of
the image.

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

a = (m - 1) / 2 b = (n - 1) / 2

To generate a complete filtered image this equation must


be applied for x = 0, 1, 2, … , M-1 and y = 0, 1, 2, … , N-1
Nonlinear of Spatial Filtering
Nonlinear spatial filters operate on neighborhoods, and the
mechanics of sliding a mask past an image are the same as was
just outlined. In general however, the filtering operation is based
conditionally on the values of the pixel in the neighborhood under
consideration, and they do not explicitly use coefficients in the
sum-of products manner described previously.

Example
Computation for the median is a nonlinear operation.
Smoothing Spatial Filtering - Linear
Averaging (low-pass) Filters
 Smoothing filters are used
- Noise reduction
- Smoothing of false contours
- Reduction of irrelevant detail

 Undesirable side effect of smoothing filters


- Blur edges

Weighted average filter


reduces blurring in the
smoothing process.

Box Weighted
filter average
Smoothing Spatial Filtering - Linear
Averaging (low-pass) Filters
 Used for blurring and for noise reduction
 Blurring is used in preprocessing steps, such as
 removal of small details from an image prior to
object extraction
 Noise reduction can be accomplished by blurring
with a linear filter and also by a nonlinear filter

 output is simply the average of the pixels contained


in the neighborhood of the filter mask.
 called averaging filters or low-pass filters.
Smoothing Spatial Filtering - Linear
Averaging (low-pass) Filters
 replacing the value of every pixel in an image
by the average of the gray levels in the
neighborhood will reduce the “sharp” transitions
in gray levels.
 sharp transitions
 random noise in the image
 edges of objects in the image
 thus, smoothing can reduce noises
(desirable) and blur edges (undesirable)
3x3 Smoothing Linear Filters

box filter weighted average

the center is the most important and other


pixels are inversely weighted as a function of
their distance from the center of the mask
Weighted average 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 is simply an attempt to reduce blurring in the
smoothing process.
General form : smoothing mask
Smoothing Spatial Filtering _ Linear
Averaging (low-pass) Filters
n = filter size

n=3

n=5 n=9

n = 35

n = 15
H.R. Pourreza
Smoothing Spatial Filtering
Averaging & Threshold
filter size Thrsh = 25% of
n = 15 highest intensity
Smoothing Spatial Filtering-nonlinear
Order Statistic Filters

The response is based on ordering (ranking)


the pixels contained in the image area
encompassed by the filter
Example
median filter : R = median{zk |k = 1,2,…,n x n}
max filter : R = max{zk |k = 1,2,…,n x n}
min filter : R = min{zk |k = 1,2,…,n x n}
note: n x n is the size of the mask
Smoothing Spatial Filtering
Order Statistic Filters
Order-statistics filters are nonlinear spatial filters whose
response 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 determined by the ranking result.
3  3 Median filter [10 125 125 135 141 141 144 230 240] = 141
3  3 Max filter [10 125 125 135 141 141 144 230 240] = 240
3  3 Min filter [10 125 125 135 141 141 144 230 240] = 10

Median filter eliminates isolated clusters of pixels that are


light or dark with respect to their neighbors, and whose
area is less than n2/2.
Smoothing Spatial Filtering
Order Statistic Filters
Median Filters

 Replaces the value of a pixel by the median of the


gray levels in the neighborhood of that pixel (the
original value of the pixel is included in the
computation of the median).
 Quite popular because for certain types of random
noise (impulse noise  salt and pepper noise) , they
provide excellent noise-reduction capabilities, with
considering less blurring than linear smoothing filters
of similar size.
Order Statistic Filters
Example : Median Filters
n=3 n=3
Average Median
filter filter
Example
Example
Example

You might also like