Syllabus
Fundamentals
Introduction Image Acquisition Enhancement-1 Enhancement-2
Image Analysis
Module Introduction, Origins of Image Processing (Imaging), Imaging Modalities Image Formation, Pixels, Spatial & Intensity Resolutions, Interpolation
Grey Level Transformations: Contrast Stretching, Histogram Processing
Spatial Filtering: Smoothing (Averaging, Median), Sharpening (Sobel & Laplacian)
Morphological Image Processing-1 & Assessment Contextualisation Session Morphological Image Processing-2
Image Segmentation-1
Image Segmentation-2
Applications
Colour Image Processing
Image Compression Representation and Description Real-world Applications
Last Lecture
Today
Spatial Domain
Limitations of Point Operations
• They don’t know anything about their neighbours
• Most image features (edges, textures, etc) involve a spatial neighbourhood of pixels
• If we want to enhance or manipulate these features, we need to go beyond point operations
What Point Operations Can’t Do
Blurring/Smoothing
What Point Operations Can’t Do
Sharpening
• Neighbourhood operations simply operate on a larger neighbourhood of pixels than point operations
• Neighbourhoods are mostly a rectangle around a central pixel
• Any size rectangle is possible
Origin
x
Neighbourhood Operations
Neighbourhood
(x, y)
y
Image f (x, y)
Spatial Filters
A spatial filter is an image operation where each pixel value I(x,y) is changed
by a function of the intensities of pixels in a neighbourhood of (x,y) xx
G yy
Definition
I(x,y)
G(x,y)
Smoothing Spatial Filter – Averaging
Example:
Mean of a neighbourhood
Consider taking mean in a 3×3 neighbourhood
Used for
• blurring: removal of small
(irrelevant) details
• bridging small gaps • noisereduction
y-1 y
y+1
𝐺(𝑥,𝑦)=9
𝐼(𝑥+𝑖,𝑦+𝑗)
1 1 1
x-1 x x+1
𝑖=−1 𝑗=−1
Origin
x
How a Linear Spatial Filter Works
Simple 3*3 104 100 108 Neighbourhood 99 106 98
104 100 108
99 106 98
95 90 85
Original Image Pixels
y
Image f (x, y)
95 90 85
Origin
x
How a Linear Spatial Filter Works
104 100 108 1/9 1/9 1/9 99 106 98 * 1/9 1/9 1/9
111 1/04 1/00 1/08
95 90 85
Original Image Pixels
1/9 1/9 1/9
Filter
Simple 3*3 Neighbourhood
9 9 9
3*3 Smoothing
111 9/9 1/06 9/8 9 9 9
111 9/5 9/0 8/5 999
Filter
e = 1/9*106 +
1/9*104 + 1/9*100 + 1/9*108 + 1/9*99 + 1/9*98 +
1/9*95 + 1/9*90 + 1/9*85
= 98.3333
y
Image f (x, y)
Origin
x
How a Linear Spatial Filter Works
104 100 108 1/9 1/9 1/9 99 106 98 * 1/9 1/9 1/9
111 1/04 1/00 1/08
95 90 85
Original Image Pixels
1/9 1/9 1/9
Filter
Simple 3*3 Neighbourhood
9 9 9
3*3 Smoothing
111 9/9 1/06 9/8 9 9 9
111 9/5 9/0 8/5 999
Filter
e = 1/9*106 +
1/9*104 + 1/9*100 + 1/9*108 + 1/9*99 + 1/9*98 +
1/9*95 + 1/9*90 + 1/9*85
= 98.3333
y
Image f (x, y)
The above is repeated for every pixel in the original image to generate the smoothed image
How a Linear Spatial Filter Works
x
y
I
x
y G
Effect of Filter Kernel Size
Mean filters;
Kernel size determines the degree of smoothing and loss of detail
What Does This Filter Do?
Identity function (leaves image alone)
What Does This Filter Do?
Mean (averages neighbourhood)
What Does This Filter Do?
Shift left by one pixel
What Does This Filter Do?
Sharpen (combination of identity and mean filters)
Smoothing Spatial Filter – Gaussian
• 2D Gaussian Kernel
• higher weight in the centre to decrease blurring
• σ determines width of filter and hence amount of smoothing
Averaging vs Gaussian Smoothing
Median Filter
• Image infected with salt-and-pepper noise
• Average filters would spread some of the noise in the image
Median Filter
• Sort all neighbourhood pixels in increasing order
• Replace neighbourhood centre with the median
• Forces noisy (distinct) pixels to conform to their neighbours
• Useful in noise reduction: eliminating intensity spikes such as salt-and-pepper noise
• Special shapes can preserve line structures
Median Filter
X-ray image of a mean 3×3 median 3×3 circuit board
corrupted by salt- and-pepper noise
What To Do At The Boundary?
What To Do At The Boundary?
Crop Zero-Pad Extend Wrap
Sharpening
Term sharpening is referred to techniques suited for enhancing intensity transitions
In images, borders between objects are perceived because of intensity change: the crisper the intensity transitions, the sharper the image is perceived
Intensity transition between adjacent pixels is related to derivatives of image in that position
1st and 2nd Derivatives
Formula for the 1st derivative of a function:
f f(x1) f(x) x
difference between subsequent values and measures rate of change of function
Gary-level values
Formula for the 2nd derivative of a function:
2 f f(x1) f(x1)2f(x) 2nd
2 x derivative
takes into account the values both before and after the current value
1st derivative
Derivatives
More to follow next week…
Recommended Reading
“Digital Image Processing”, R.C. Gonzalez and R.E. Woods, 3rd edition, Pearson Prentice Hall, 2008
Chapter 3