IMAGE PROCESSING INTENSITY TRANSFORMATION AND SPATIAL FILTERING Editor by DR. FERDA ERNAWAN Faculty of Computer Systems & Software Engineering ferda@ump.edu.my
Today’s Lesson Image Enhancement in the Spatial Domain Introduction to Spatial domain Intensity transformations Photographic Negative, Gamma transformation, Logarithmic Transformation, Contrast-stretching transformation Histogram transformation Spatial filtering Smoothing, Sharpening Learning Outcomes: To understand the basic operation of image enhancement in Spatial Domain.
Introduction to Spatial Spatial domain is a signal having space as the independent variable (Jayaraman, Veerakumar, Esakkirajan, 2017 ), image is an example of a signal that can be processed in the spatial domain. There are two principal categories for processing in spatial domain: Spatial filtering : sharpening and blurring. Intensity transformation : contras manipulation and thresholding.
General Framework in Spatial Domain The most basic transformation is h(x, y) = T(f(x, y)) where f(x, y) denotes input image, h(x, y) represents the output and T(f) is a function of a single (real) variable.
Conventions: Digital Images Left: Digital image where the point of (x,y) is reffered. Below: Examples of gray-value transformations to enhance the image by controlling the contrast stretching function (i) and thresholding function (ii).
Intensity Transformations
Basic Gray Level (Intensity) Transformations Function The simplest image processing technique. s = T( r ) transformation pixel r into s. Gray level is used to enhance an image : Negative Gamma Transformation Logarithmic Transformation Contrast-stretching / Piecewise linear Bit slicing
Negative Transformation Gray-level transformation function used for image enhancement
Negative Transformation Example This technique is suitable when the image has dominant black areas. S = L – 1 – r reversing the intensity (grey) level. Images taken from Gonzalez and Woods, 2016
Negative Transformation Example Images taken from Gonzalez and Woods, 2016
Logarithmic Transformation Example Enhance details in the darker regions of an image by expensing detail in brighter regions. Images taken from Gonzalez and Woods, 2016
Gamma Transformation Gamma transformation is an important technique for image display on a computer monitor. Images taken from Gonzalez and Woods, 2016
Piecewise-Linear Transformation Example Contrast Stretching: Stretch gray-level ranges where we desire more information Images taken from Gonzalez and Woods, 2016
Piecewise-Linear Example 2 Images taken from Gonzalez and Woods, 2016
Intensity Level Slicing Highlight specific ranges of gray-levels only. Images taken from Gonzalez and Woods, 2016
Histogram Transformation
Histogram Processing A fully automated gray-level stretching technique one of the image enhancement technique. What is Histogram? Images taken from Gonzalez and Woods, 2016
Image Histograms “Level of gray is represented by a unique number” An image histogram is a plot of the gray-level frequencies. “Level of gray is represented by a unique number”
Image Histograms (cont..) Divide frequencies by total number of pixels to represent as probabilities. 6 18 2 10
Properties of Image Histograms Histograms with small spread correspond to low contrast images (i.e., mostly dark, mostly bright, or mostly gray). Histograms with wide spread correspond to high contrast images better image. Images taken from Gonzalez and Woods, 2016
Properties of Image Histograms (cont..) Histograms clustered at the low end correspond to dark images. Histograms clustered at the high end correspond to bright images. Images taken from Gonzalez and Woods, 2016
Histogram Equalization The main idea is to redistribute the gray-level values uniformly. Images taken from Gonzalez and Woods, 2016
Histogram Equalization In practice, the equalized histogram might not be completely flat.
Histogram Equalization Images taken from Gonzalez and Woods, 2016
Histogram Equalization – in Graph Images taken from Gonzalez and Woods, 2016
Advantages of Histogram Equalization Optimal contrast. Fully automated (adaptive, no human intervention). Image normalization: easy to compare two images taken under different lighting conditions.
Spatial filtering (Smoothing and Sharpening)
Spatial Filtering Filter (Mask) refers to “accepting” or “rejecting” a certain frequency components (smooth or sharp). Mask operation: output pixel value = some algorithm performed on all the pixels in the neighborhood of the corresponding input pixel Size of neighborhood = size of mask. Mask slides from left-side to right-side, then from top to bottom Same operation is performed on every pixel Neighborhood exceeds image boundary: zero padding or replication of border pixels
Spatial Example “Consider neighborhood pixel in order to do operation in smoothing or sharpening”.
Neighbourhood Operations Origin x y Image f (x, y) (x, y) Neighbourhood 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 and any shape filter are possible
Neighbourhood Operations Origin Target x y Image f (x, y) (x, y) Neighbourhood
The Spatial Filtering Process Origin x * Original Image Pixels Filter (w) Simple 3*3 Neighbourhood e 3*3 Filter eprocessed = o*e + k*a + l*b + m*c + n*d + p*f + q*g + r*h + s*i y Image f (x, y) For each pixel is computed based on neighbourhood operation to generate the smoothed image
Smoothing Spatial Filtering Origin x 104 100 108 99 106 98 95 90 85 1/9 * Original Image Pixels Filter 1/9 104 99 95 100 108 98 90 85 Simple 3*3 Neighbourhood 3*3 Smoothing Filter 106 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) For each pixel is computed based on neighbourhood operation to generate the smoothed image
Weighted Smoothing Filters An effective smoothing filter uses different weights in the averaging function.
Linear Filter Example g(x,y) = w(-1,-1)f(x-1,y-1) +w(-1,0)f(-1,0) +…… + w(1,1)f(x+1, y+1)
Spatial Filtering - Smoothing Spatial filter is suitable for blurring and noise reduction The aims are to remove the detail information and bridging of small gaps in lines or curves
Smoothing Masks Smoothing masks are normally adjusted to preserve average value (∑wi = 1)
Spatial Filtering - Sharpening Highlight/enhance fine detail that has been blurred Application ranging from electronic printing and medical imaging to industrial inspection
Laplacian Filter The Laplacian filter is given as: Where: The filter mask of Laplacian filter is shown as follows:
Laplacian Filter The result obtained from Laplacian filer produces highlights edges. Images taken from Gonzalez and Woods, 2016
Result of Laplacian Filter In order to produce the final sharpened image, the original image is subtracted by the Laplacian result Laplacian Filtered Images taken from Gonzalez and Woods, 2016
Laplacian Filter Images taken from Gonzalez and Woods, 2016
Laplacian Filter Images taken from Gonzalez and Woods, 2016
Variants Laplacian Filter Some variants Laplacian filters are given as follows: Simple Laplacian Variant of Laplacian Images taken from Gonzalez and Woods, 2016
Cont..
References R.C. Gonzalez and R.E. Woods, 2016. Digital Image Processing, Pearson Education India; Third edition. A.K. Jain, 2015. Fundamentals of Digital Image Processing, Pearson Education India; First edition. R.C. Gonzalez, R.E. Woods and S.L. Eddins, 2017. Digital Image Processing Using MATLAB. McGraw Hill Education; 2 edition. S. Jayaraman, T. Veerakumar, S. Esakkirajan, 2017.Digital Image Processing, McGraw Hill Education; 1 edition.