Geometric and Point Transforms
Copyright GA Tagliarini, PhD Standard Angles Rotation or reflection through standard angles such as 90°, 180°, or 270° can be done most conveniently via direct index. Intermediate angle rotations employ matrix manipulations of the indices 11/30/2018 Copyright GA Tagliarini, PhD
Rotation By Matrix Multiplication 11/30/2018 Copyright GA Tagliarini, PhD
Rotating The Standard Basis 11/30/2018 Copyright GA Tagliarini, PhD
Graphically Portraying The Standard Basis Rotation <0, 1> <-sin(θ), cos(θ)> -sin(θ) <cos(θ), sin(θ)> cos(θ) θ sin(θ) θ <1, 0> cos(θ) 11/30/2018 Copyright GA Tagliarini, PhD
Rotating An Arbitrary Point <x, y> 11/30/2018 Copyright GA Tagliarini, PhD
Geometrically Interpreting Rotation <xcos(θ)-ysin(θ), xsin(θ)+ycos(θ)> = <rcos(α+θ), rsin(α+θ)> Why?? <0, 1> r y or y<0, 1> <x, y> = <r cos(α), r sin(α)> r θ α x or x<1, 0> <1, 0> 11/30/2018 Copyright GA Tagliarini, PhD
Observations About Rotation Depending upon the rotation angle and image dimension, special processing may be required for some pixels Matrix multiplication applied to pixel indices provides access to pixel values for the destination image Working from the source to the destination may omit pixels 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Spatial Filtering Common types of filtering Smoothing: averaging may be done Over multiple images to de-noise the source To reduce noise or soften the appearance in a single image Speckle reducing Edge enhancing Often implemented by point operations using neighborhood data and a filter Filters are commonly represented with rectangular arrays of numbers The numeric values are the coefficients of the filter The arrays may be referred to as masks, kernels, templates, windows 11/30/2018 Copyright GA Tagliarini, PhD
Smoothing Filter: Averaging In An Image 11/30/2018 Copyright GA Tagliarini, PhD
Geometrical Interpretation 11/30/2018 Geometrical Interpretation s a b c d e f g h i 1/9 r c 11/30/2018 Copyright GA Tagliarini, PhD Copyright GA Tagliarini, PhD
Averaging Observations Average filtering will reduce the clarity of sharp edges. (Why?) The form of the filter is typically adapted at the boundaries of the image to accommodate computation. This 3x3 filter becomes: 2x2 at the image corners (with coefficients = ¼) 2x3 along the top and bottom, and 3x2 along the left and right sides (with coefficients = 1/6) 11/30/2018 Copyright GA Tagliarini, PhD
Averaging Observations (continued) Averaging (and other) filters are commonly square with odd side length (so that they possess a center weight). The center weight may be zero. The weights are not required all to have the same value. The sum of the weights will be 1. Not all filters will be symmetric. 11/30/2018 Copyright GA Tagliarini, PhD
Example Averaging Filters Some other averaging filters: 1/8 1 = 1 2 3 7 11 17 1/16 2/16 4/16 1 2 4 = 11/30/2018 Copyright GA Tagliarini, PhD
Speckle Reduction By Median Filtering Median filters are another type of spatial filter. Suppose a neighborhood of odd side length, sl = 2m+1 for pixel (r, c) in an image s, denoted N(s, r, c, sl). To apply a median filter: Find the median intensity, mi, of the pixels in N(s, r, c, m); i.e., mi = median( N(s, r, c, sl)) Set d(r, c) = mi 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Median Filtering The median can be found by sorting the pixel intensities in N(s, r, c, sl) It is NOT necessary to sort the list of pixel intensities completely. (Why?) Exercises Implement monochrome and multi-spectral median filters. What happens when a median filter is applied recursively? How does this differ from the result of recursively applying a smoothing filter? 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Contrast Enhancement Polynomial or root transformations Log transformations Histogram equalization 11/30/2018 Copyright GA Tagliarini, PhD
Polynomial And Root Transforms 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Log Transforms 11/30/2018 Copyright GA Tagliarini, PhD
Key Insight: Changing Contrast f(x) When f’>1, a unit change in x results more than a unit change in y When f’<1, a unit change in x results less than a unit change in y When f’≈1, a unit change in x results approximately a unit change in y y f’<1 f’≈1 x f’>1 11/30/2018 Copyright GA Tagliarini, PhD
An Typical Image Histogram 11/30/2018 Copyright GA Tagliarini, PhD
Overlaying The Histograms 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Cumulative Histogram Similar to a probability density function Increases contrast where the most frequently occurring pixel intensities lie Used for monochrome images but separate application to RGB color planes leads to surreal images 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Sharpening Unlike smoothing filters, the goal is to enhance detail that has been blurred Averaging filters typically use a scaled weighted sum (an integration) Sharpening filters commonly employ differences (derivatives) 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Derivatives Recall that the derivative of a function f at a point a may be defined as when the limit exists. 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Graphically a x f(x)-f(a) x-a 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD With Digital Samples The closest approximation is when x=a+1 So x-a=1 Hence f(a+1)-f(a) is an estimate of f’(a) a x f(x)-f(a) x-a 11/30/2018 Copyright GA Tagliarini, PhD
One Dimensional Derivative … f(x) f(x+1) 11/30/2018 Copyright GA Tagliarini, PhD
One Dimensional Second Derivative … f(x-1) f(x) f(x+1) 11/30/2018 Copyright GA Tagliarini, PhD
Laplacian 1 -4 Which gives rise to the mask 11/30/2018 1 -4 Which gives rise to the mask 11/30/2018 Copyright GA Tagliarini, PhD
Enhancement Using The Laplacian 11/30/2018 Copyright GA Tagliarini, PhD
A One-Dimensional Example 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Example Detail f 50 45 40 35 30 25 20 60 100 140 180 220 120 200 f' -5 -100 -180 f'' 5 -140 -360 f# 15 260 -80 380 -160 scaled f# [20, 220] 98 94 92 90 89 87 85 116 131 146 161 176 clipped f# clipped 0-255 f# 255 11/30/2018 Copyright GA Tagliarini, PhD
Alternative Laplacian Masks Implementing the computational simplification use: To employ diagonal derivatives in addition to x-y use -1 5 -1 9 11/30/2018 Copyright GA Tagliarini, PhD
Example With f, f’, f’’, and Sharpened f 11/30/2018 Copyright GA Tagliarini, PhD
Example With Sharpening 11/30/2018 Copyright GA Tagliarini, PhD
Gradient Operators For Enhancement Robert’s cross-gradient (2x2) Prewitt’s gradient (3x3) Sobel operator (3x3) These use the magnitude of a gradient estimate to create image enhancements 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Gradient 11/30/2018 Copyright GA Tagliarini, PhD
Creating And Using Gradient Estimates Often, the sum of the absolute values of Gx and Gy are used Computationally, |Gx| and |Gy| take much less time to compute than squaring and finding a square root of a sum. Hence, the gradient magnitude may be estimated by 11/30/2018 Copyright GA Tagliarini, PhD
Using Gradient Operators Estimate the gradient magnitudes and create a gradient magnitude map. Often the gradient map is half-toned using an anecdotally determined threshold. The gradient map may be used directly to find edges. The half-toned map (or its negative) can be “OR-ed” with the original for interpretation. 11/30/2018 Copyright GA Tagliarini, PhD
Robert’s Cross-Gradient Operators Robert’s cross-gradient is estimated using |grad(f)| = |z9-z5|+|z8-z6| Using the masks below to estimate derivatives: z1 z2 z3 z4 z5 z6 z7 z8 z9 -1 1 -1 1 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Robert’s Gradient Map 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Prewitt’s Gradient Estimate Prewitt’s gradient using: |grad(f)| = |(z3+z6+z9)-(z1+z4+z7)|+ |(z7+z8+z9)-(z1+z2+z3)| Use the masks below: z1 z2 z3 z4 z5 z6 z7 z8 z9 -1 1 -1 1 11/30/2018 Copyright GA Tagliarini, PhD
Prewitt’s Gradient Map 11/30/2018 Copyright GA Tagliarini, PhD
Copyright GA Tagliarini, PhD Sobel Masks Sobel’s gradient is estimated using |grad(f)| = |z3-z1|+|z6-z4|+|z9-z7| Using the masks below to estimate derivatives: z1 z2 z3 z4 z5 z6 z7 z8 z9 -1 1 -2 2 -1 -2 1 2 11/30/2018 Copyright GA Tagliarini, PhD
Using Sobel’s Gradient 11/30/2018 Copyright GA Tagliarini, PhD
Using Sobel’s Gradient With Wavelet 11/30/2018 Copyright GA Tagliarini, PhD