Title: Dr' Claude C' Chibelushi
1Fac. of Comp., Eng. Tech. Staffordshire
University
Image Processing, Computer Vision, and Pattern
Recognition
Spatial Domain Filters
Dr. Claude C. Chibelushi
2Outline
- Introduction
- Filter pass band
- Spatial domain filters
- Convolution-based filters
- Mode and median filters
- Combination of convolution-based filters
- Summary
3Introduction
Rate of intensity change (i.e. intensity
gradient) gives information such as object
boundary, presence of noise, ...
4Introduction
- Filter transforms image such that
- certain type of information is retained /
emphasized while others are rejected / attenuated - based on rate of change of pixel values
5Introduction
6Introduction
- Filtering can be done in
- spatial domain
- i.e. applied to image pixels directly
- frequency domain
- i.e. applied to representation of image as sum of
cyclic patterns
7Filter Pass Band
- Filters let through or attenuate specific ranges
of image details - e.g. slow/gradual or fast changes in pixel value
- Hence the classification of filters into
- low-pass filters
- high-pass filters
- and other types of filters
- band-pass filters, band-reject filters,
8Filter Pass Band
- Low-pass filter
- Attenuates fast changes in pixel value but lets
through slow / gradual changes - Typical application noise removal
- Tends to blur image
9Filter Pass Band
- High-pass filter
- Attenuates slow / gradual changes in pixel value
but lets through fast changes - Typical application edge enhancement
- Tends to be sensitive to noise
- Output values may be outside numerical range of
pixel value - shifting and scaling may be required (see notes
on contrast enhancement)
10Spatial-Domain Filters
- Spatial-domain filters are based on moving
window techniques e.g. - convolution operation (e.g. Laplacian filter)
- sorting operation (e.g. median filter)
- pixel-counting operation (e.g. mode filter)
11Spatial-Domain Filters
- window repeatedly shifted over image
- calculations performed for each shift
- only pixels within window are considered
12Spatial-Domain Filters
- Convolution
- Many spatial-domain filters are based on
convolution - Convolution uses a moving window
- shift-multiply-add operation
13Spatial-Domain Filters
32
Output value
(-1x9)
(-1x30)
(0x29)
(0x33)
(0x39)
(1x9)
(1x2)
32
window
14Spatial-Domain Filters
- Convolution
- Shift-multiply-add operation
- weighted sum of pixel values in neighbourhood
- weights specified in mask (kernel, template, ...)
- sum entered in output image at pixel location
corresponding to mask anchor - mask shifted by one pixel
- Note shift by more than 1 pixel is sometimes
used (gives smaller output image)
15Spatial-Domain Filters
- Convolution
- Mathematical notation
Output at image row i, column j
for each mask row
for each mask column
16Spatial-Domain Filters
- Convolution pseudo code
- / at each image pixel /
- for each image row // downward window shifts
- for each image column // rightward window
shifts - / in image window covered by mask /
- for each mask row
- for each mask column
- update local cumulative weighted sum
- Note use output buffer
17Spatial-Domain Filters
- Convolution
- Warning
- Example given earlier shows common implementation
of convolution - but it actually uses formula for cross-correlation
18Spatial-Domain Filters
- Convolution-based filters
- Low-pass filter masks
19Spatial-Domain Filters
- Convolution-based filters
- High-pass filter
- change that corresponds to edge is measured using
derivative - 1st order derivative has high magnitude at edge
- gradient of image
- 2nd order derivative has zero-crossing at edge
(but higher sensitivity to noise) - Laplacian of image
20Spatial-Domain Filters
- Convolution-based filters
- High-pass filter
21Spatial-Domain Filters
- Convolution-based filters
- High-pass filter noise sensitivity of Laplacian
Zero-crossings of Laplacian
Original image
22Spatial-Domain Filters
- Convolution-based filters
- High-pass filter noise sensitivity of Laplacian
- possible solution pre-filtering with Gaussian LPF
23Spatial-Domain Filters
- Convolution-based filters
- Laplacian of Gaussian
24Spatial-Domain Filters
- Convolution-based filters
- High-pass filter masks
- gradient of discrete function can be estimated
using finite difference - e.g. gradient along x-axis
- other approximations Roberts masks, Sobel masks,
Prewitt masks
25Spatial-Domain Filters
- Convolution-based filters
- High-pass filter masks
For general use combine outputs of vertical and
horizontal edge filters
26Spatial-Domain Filters
High-pass filtering (Sobel masks) note
directional sensitivity
27Spatial-Domain Filters
- Convolution-based filters
- High-pass filter masks
28Spatial-Domain Filters
- Convolution-based filters
- High-pass filter masks
29Spatial-Domain Filters
- Convolution-based filters
- High-pass filter masks
- Laplacian of discrete function can be estimated
using finite difference
30Spatial-Domain Filters
- Convolution-based filters
- High-pass filter masks
Single mask detects vertical and horizontal edges
31Spatial-Domain Filters
- Mode and median filters
- Some low-pass filters not based on convolution,
e.g. - mode filter
- output pixel value (at anchor) most common
value in neighbourhood requires local histogram
- median filter
- output pixel value (at anchor) median value
in neighbourhood requires sorting
32Spatial-Domain Filters
- Mode filter pseudo code
- / at each image pixel /
- for each image row // downward window shifts
- for each image column // rightward window
shifts -
- / in current image window /
- for each window row
- for each window column
- update local histogram
- put local mode in output buffer
-
33Spatial-Domain Filters
- Median filter pseudo code
- / at each image pixel /
- for each image row // downward window shifts
- for each image column // rightward window
shifts -
- / in current image window /
- for each window row
- for each window column
- update local sort
- put local median in output buffer
-
34Spatial-Domain Filters
- Mode and median filters
- Less blurring of edges (compared to averaging
filters) - Computational requirements may be high sorting
in the median filter
35Spatial-Domain Filters
36Spatial-Domain Filters
- Combination of convolution-based filters
- Several filtering passes may be applied to image
- passes may be parallel or sequential
- combined effect can be obtained by (one of
following) - combining results of individual passes
- combining masks into one single-pass mask
37Spatial-Domain Filters
- Combination of convolution-based filters
- Parallel passes
- e.g. combination of output of directional edge
detectors (e.g. Sobel edge detector) - each edge pixel considered as vector (with
magnitude and direction)
38Spatial-Domain Filters
- Combination of convolution-based filters
- Parallel passes
- e.g. addition of output images
Single-pass equivalent add mask coefficients
39Spatial-Domain Filters
- Combination of convolution-based filters
- Parallel passes
- addition of output images (ctd.)
- relevant property of convolution
- distributivity with addition
40Spatial-Domain Filters
- Combination of convolution-based filters
- Parallel passes e.g. edge detection by
substraction
Original image
-
Smoothed image (5x5 Gaussian mask)
Output values scaled by 4 and offset by 128
41Spatial-Domain Filters
- Combination of convolution-based filters
- Sequential passes
Single-pass equivalent convolve masks
42Spatial-Domain Filters
- Combination of convolution-based filters
- Sequential passes (ctd.)
- relevant property of convolution
- associativity
43Spatial-Domain Filters
- Combination of convolution-based filters
- Sometimes beneficial to blur image prior to edge
detection - e.g. in Canny edge detector
Increasing degree of blurring
44Summary
- Filters retain / reject image details based on
rate of change of pixel values - classes low-pass filter, high-pass filter, ...
- based on neighbourhood (window) operations
- e.g. convolution, sorting, counting operations,
- convolution-based filters use mask
45Summary
- Combination of convolution-based filters
- parallel e.g. for addition of filtered images
- add mask coefficients
- sequential convolve masks