CEE 615: Digital Image Processing Spatial Enhancements 1 Spatial Enhancement Region operations: k'(x,y) = F( k(x-m, y-n), k(x,y), k(x+m,y+n) ] Template (Windowing) Operations Template (window, box, kernel) - defines the immediate area of interest - used in spatial domain operations - usually square/rectangular Examples of Template Operations correlation, convolution - spatial smoothing - spatial differentiation - edge enhancements median filter variance/ std. deviation local area enhancements difference operations template matching logical averaging Fourier Transform Image ==> spatial frequency map (FT) frequency domain filtering filtered FT map ==> image CorrelationThe correlation of two continuous functions f(x) and g(x), denoted by f(x) o g(x), is defined (in 1-dimension) by the relation: Where is a dummy variable of integration. f (x) g(x) f ( )g(x )d ConvolutionThe convolution of two continuous functions f(x) and g(x), denoted by f(x) g(x), is defined (in 1-dimension) by the relation: Where is a dummy variable of integration. f (x) g(x) f ( )g(x )d
CEE 615: Digital Image Processing Spatial Enhancements Correlation: graphic description STEP 1: STEP : Convolution: graphic description
CEE 615: Digital Image Processing Spatial Enhancements 3 Convolution & correlation filters 1. Sum of the filter elements: f(k) = 1 ==> tonal character of the original image is unchanged. f(k) > 1 ==> tonal (contrast) stretch 0 < f(k) < 1=> tonal (contrast) reduction f(k) = 0 ==> complete loss of tonal properties.. Laws: Let f 1 and f be filters, and let F be and image: Distributive Law: addition (f 1 * F) + (f * F) = (f 1 + f ) * F (f 1 o F) + (f o F) = (f 1 + f ) o F Commutative Law: addition (f 1 + f ) * F = (f + f 1 ) * F (f 1 + f ) o F = (f + f 1 ) o F Associative Law: convolution f 1 * (f * F) = (f 1 * f ) * F Commutative Law: convolution f 1 * f = (f * f 1 ) NOTE: If the filter, f, is invariant under a 180 rotation, convolution and correlation are identical operations. Convolution: discrete definitionthe discrete definition of the convolution of a filter f(x) with image g(x), is defined as: (m1) (n1) / f (i, j) g(i, j) f (k, ) g(i k, j ) image Where: (i,j) = location in the k (m1) (n1) / (m,n) = size of the filter template (k,) = location within the filter template (k,) = (0,0) refers to the filter center Filters are usually defined with odd dimensions, i.e., 3x3, 5x5,... That way the center pixel is always well defined. The center (or reference) pixel in a filter with even dimensions is often taken to be the upper left pixel of the center group. Spatial Smoothing: low-pass (averaging or mean) filter- convolution/correlation operation - replaces the image value with a weighted average of the local values x Linear Stretch: Convolution/correlation operation using a template with an effective size of 1x1. - Each image pixel gray value is multiplied by the value of the template.
CEE 615: Digital Image Processing Spatial Enhancements 4 Median Filter: Replaces the image value with the local median More generally, a rank-order filter. The filter is applied by sorting the values of in the neighborhood defined by the template, selecting the median value and assigning this value to the pixel. For example, in a 3x3 neighborhood, the median is the 5th largest value, in a 5x5 neighborhood the 13th largest value, and so on. Logical averaging Local area enhancement (statistical differencing) gray-value mapping varies over the image. produces same contrast over the entire image. let k m (i.j) and (i,j) and be the mean and standard deviation of gray values in some neighborhood of (i,j). o k (i, j) k (i, j) [k(i, j) k ] where: k o m m o = output gray value (i, j) o = desired standard deviation k m = local meanlocal area enhancement (forcing a local mean) allows more user control over the enhancement o k (i, j) m (1 )[k(i, j) k ] o o m (i, j) where: k m (i,j) = local mean (i,j) = local standard deviation k o = output gray value m o = desired mean Edge enhancements: 1-D Gradient In 1-dimension: df df Continuous function: xf ; yf dx dy Discrete function: xf f (i) f (i 1), yf f (j) f (j 1) o o = desired standard deviation = degree to which the mean is forced Edge enhancements: -D Gradient In -dimension: f f Continuous function: f ˆ i ˆj x y Discrete function: f (i, j) f (i, j) f (i 1, j) ˆi f (i, j) f (i, j 1) ˆj The Gradient is a vector quantity
CEE 615: Digital Image Processing Spatial Enhancements 5 Edge enhancements: Gradient alternates The gradient is a vector quantity, i.e., it has a magnitude and a direction. Magnitude: f f f x y Absolute Value: f f x y Robert's gradient: [f(i,j) - f(i+1,j+1)] + [f(i+1,j) - f(i,j+1)] Sum of the directional f f derivatives: x y Edge Enhancement: Laplacian Continuous function: Discrete function: f y x f f f x y f f (i 1, j) *f (i, j) f (i 1, j) f (i, j1) *f (i, j) f (i, j 1) Discrete D Laplacian: f f f f (i 1, j) f (i 1, j) f (i, j 1) f (i, j 1) 4*f (i, j) x y
CEE 615: Digital Image Processing Spatial Enhancements 6 Convolution filter characteristics: Sum of the filter elements: f(k) = 1 ==> tonal character of the original image is unchanged. f(k) > 1 ==> tonal (contrast) stretch 0 < f(k) < 1=> tonal (contrast) reduction f(k) = 0 ==> Directionality/symmetry complete loss of tonal properties.