lecture8
lecture8
Lecture 8:
Arithmetic and Logical Operations
Spatial Filtering
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 1
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 2
1
Mathematical/logical operations on images
▪ Addition
– Averaging images for noise removal
▪ Subtraction
– Removal of background from images
– Image enhancement
– Image matching
– Moving/displaced object tracking
▪ Multiplication
– Superimposing of texture on an image
– Convolution and correlation of images
▪ And and or operations
– To remove unnecessary area of image through mask operations
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 3
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 4
2
Image averaging for noise reduction
Original image Noisy image
Noisy image
Noise
reduction by
averaging
256 samples
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 6
3
Examples of image subtraction
Original image Image after moving one coin
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 7
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 8
4
Examples of image Multiplication
Multiplication of images can be used for superimposing
texture on an image
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 9
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 10
10
5
Local enhancement through spatial filtering
▪ The output intensity value at (x,y) depends not only on
the input intensity value at (x,y) but also on the specified
number of neighboring intensity values around (x,y)
▪ Spatial masks (also called window, filter, kernel,
template) are used and convolved over the entire image
for local enhancement (spatial filtering)
▪ The size of the masks determines the number of
neighboring pixels which influence the output value at
(x,y)
▪ The values (coefficients) of the mask determine the
nature and properties of enhancing technique
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 11
11
where a = (m − 1) / 2, b = (n − 1) / 2
x = 0, 1, 2,......, M − 1, y = 0, 1, 2,......, N − 1,
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 12
12
6
Basics of spatial filtering
▪ Given the 3×3 mask with coefficients: w1, w2,…, w9
▪ The mask cover the pixels with gray levels: z1, z2,…, z9
13
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 14
14
7
Mask operation near the image border
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 15
15
16
8
Smoothing filters
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 17
17
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 18
18
9
Spatial filtering for Smoothing (example)
Smoothed by Smoothed by
5 x 5 box filter 9 x 9 box filter
Smoothed by Smoothed by
15 x 15 box filter 35 x 35 box filter
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 19
19
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 20
20
10
Order-statistics filtering
▪ Nonlinear spatial filters
▪ Output is based on order of gray levels in mask (subimage)
▪ Examples: Median filtering, Max & Min filtering
Median filtering
▪ Assigns the mid value of all the gray levels in the mask to the
center of mask;
▪ Particularly effective when
– noise pattern consists of strong, spiky components (impulse
noise, salt-and-pepper
– edges are to be preserved
– Force points with distinct gray levels to be more like their
neighbors
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 21
21
Median Filtering
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 22
22
11
Median Filtering (example)
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 23
23
3/27/2025 Capital University of Science and Technology Digital Image Processing CPE3643 24
24
12
Spatial filtering for image sharpening
Operation of Image Differentiation
▪ Enhance edges and discontinuities (magnitude of output
gray level >>0)
▪ De-emphasize areas with slowly varying gray-level
values (output gray level: 0)
25
13