5/24/2015© 2009 Raymond P. Jefferis III Lect Geographic Image Processing Data Transformation and Filtering Noise in data Arrays Digital filtering Filter coefficients Convolution Topographic map Gaussian Convolution Filter Coefficients
5/24/2015© 2009 Raymond P. Jefferis III Lect Types of Image Noise Distributed random (altitude uncertainty) –Gaussian (many physical measurements) –Uniform (useful for models and tests) Impulse noise (natural data disturbances) Salt-and-Pepper (random 0s and 1s)
5/24/2015© 2009 Raymond P. Jefferis III Lect Noisy Data In the slide to follow, –the first image shows DTED raw data, as distributed –the second image shows the same data corrupted by uniform random noise of ± 5 meters Note: Raw DTED data has noise of less than ±1 meter
5/24/2015© 2009 Raymond P. Jefferis III Lect Uniform Random Data Noise Normal DTED DataNoisy DTED Data
5/24/2015© 2009 Raymond P. Jefferis III Lect Effects of Noise Greater uncertainty in data Cascading uncertainty in computations performed on data: –Topographical maps –Attribute contours (contour maps) –Watershed gradients
5/24/2015© 2009 Raymond P. Jefferis III Lect Effect of Noise on Contour Plot Normal data contoursNoisy data contours
5/24/2015© 2009 Raymond P. Jefferis III Lect Gaussian Noise (Mean=0, StdDev=5) Noisy DTED DataNoisy data contours
5/24/2015© 2009 Raymond P. Jefferis III Lect Gaussian Noise - Filtereed Gaussian Noise - (Mean=0, StdDev=5) Image has been filtered 7x7 Gaussian convolution filter used to remove noise
5/24/2015© 2009 Raymond P. Jefferis III Lect Notes on Noise Contour maps frequently give contours meters apart. If data points are not smoothed to this distance, contours will appear jagged Data points are on 10-meter centers, depending on type of noise, a recommended convolution array might be at least 11x11.
5/24/2015© 2009 Raymond P. Jefferis III Lect Raw and Averaged Contours Raw Data - Malvern3x3 Convolution
5/24/2015© 2009 Raymond P. Jefferis III Lect Effect of 7x7 vs 15x15 Convolutes 15x15 Gaussian filter 7x7 Gaussian filter
5/24/2015© 2009 Raymond P. Jefferis III Lect Reasons for Digital Filtering Reduction of random noise Smoothing of topological contours Smoothing topological cross-sections Smoothing of attribute contours (rainfall, etc.) Smoothing of data for gradient calculations To extract image features or attributes To enhance image features or attributes
5/24/2015© 2009 Raymond P. Jefferis III Lect What is digital filtering? Processing of raw data Uses filter algorithms Filters typically require coefficients to control the data processing Convolution methods frequently used for image processing (can be parallelized) Data combined from multiple points/sources
5/24/2015© 2009 Raymond P. Jefferis III Lect The Meaning of Digital Filtering Points in an image field contain noise Each single point is physically related to its surrounding points, so that sudden spatial changes are improbable Digital filtering exploits this relationship by adding information from surrounding points to the central points by means of a weighted summation process - convolution.
5/24/2015© 2009 Raymond P. Jefferis III Lect Convolution Filter Uses an array of filter weights Operated incrementally over entire data field, except near edges of data Each resulting point is sum of weighted data surrounding it, divided by sum of weights (normalized weights, shifted for convolution) ( ∑ Data*Weights / ∑ Weights )
Normalized Weights Each weight is normalized – dividing it by the sum of all the weights Normalized weights are assumed in the following two slides 5/24/2015© 2009 Raymond P. Jefferis III Lect
5/24/2015© 2009 Raymond P. Jefferis III Lect Discrete Convolution
5/24/2015© 2009 Raymond P. Jefferis III Lect Example (normalized weights) d11d12d13d14d15 d21d22d23d24d25 d31d32d33d34d35 d41d42d43d44d45 d51d52d53d54d55 h33=(d22*w33+ d23*w32+ d24*w31+ d32*w23+ d33*w22+ d34*w21+ d42*w13+ d43*w12+ d44*w11) Data Weights Result w33w32w31 w23w22w21 w13w12w11
5/24/2015© 2009 Raymond P. Jefferis III Lect Example: Gaussian Image Filter Determine filter coefficients from spatial Gaussian function. Form convolution matrix Normalize coefficients Convolve matrix with spatial data Obtain filtered result for each image pixel
5/24/2015© 2009 Raymond P. Jefferis III Lect Result Convolution operation performed Gaussian filter kernel (square matrix with odd number of rows and columns) Gauss filter smooths or blurs an image
5/24/2015© 2009 Raymond P. Jefferis III Lect Gaussian Filter Coefficients Here σ is the standard deviation of the Mean. x and y are the spatial dimensions.
5/24/2015© 2009 Raymond P. Jefferis III Lect Calculation of Gaussian Weights s = 1.52; im = 3; nrm = 0; For[j = -im, j < im + 1, j++, For[i = -im, i < im + 1, i++, g = Exp[-((i^2 + j^2)/(2.0* s^2))]; gr = Round[g*67]; Print[gr]; nrm = nrm + gr; ] ] Print[nrm] Notes: See Models file for program. Degree of smoothing determines by value of “s”
5/24/2015© 2009 Raymond P. Jefferis III Lect Choice of Parameters Pick (odd) number of samples Pick σ to broaden filter to desired number of samples Pick multiplier (67 in example) to give unity coefficients at edges. Repeat until filter exhibits desired smoothing
5/24/2015© 2009 Raymond P. Jefferis III Lect Gaussian Convolution Matrix
5/24/2015© 2009 Raymond P. Jefferis III Lect Notes Central points have higher weight Diagonal points have weights reduced (distance to central point is longer) Whole number weights used, though NOT necessary. Normalized weights are Real numbers.
5/24/2015© 2009 Raymond P. Jefferis III Lect Comments Coefficients are typically whole numbers Sum of coefficients normalizes them, resulting in array of Real numbers Example filter gives most weight to central data (little blurring)
5/24/2015© 2009 Raymond P. Jefferis III Lect Mathematica ® Programming y = ListConvolve[c, sampledelev]; “c” is the convolution kernel array “sampledelev” is data table “y” is filtered data array (can be plotted as filtered topographic map)
Note If data matrix is m x m, and Convolution kernel is (2n+1) x (2n+1), then The filtered result will be (m-n) x (m-n) Example: m = 480 2n +1 = 17 Result is ( ) x ( ) 5/24/2015© 2009 Raymond P. Jefferis III Lect
5/24/2015© 2009 Raymond P. Jefferis III Lect Filtering Malvern Data Normal DTED DataFiltered DTED Data
5/24/2015© 2009 Raymond P. Jefferis III Lect Comments on Filtering Gaussian filtering will remove some degree of random noise Resulting image will have some blurring, when compared with (noise-free) unfiltered data Convolution filtering with n x n kernel will reduce image size by 2*(n-1) pixels in both horizontal and vertical directions.
5/24/2015© 2009 Raymond P. Jefferis III Lect Filtering A Noisy Image ±5m Noisy DTED DataFiltered Noisy Data
5/24/2015© 2009 Raymond P. Jefferis III Lect High Noise Levels Gaussian filtering can remove a lot of noise! Resulting image may look quite sharp or may be blurred
5/24/2015© 2009 Raymond P. Jefferis III Lect Filtering Very Noisy Image ±10m Noisy DTED DataFiltered Very Noisy Data
5/24/2015© 2009 Raymond P. Jefferis III Lect Topographic Map Shows contours of equal altitude Fixed contour spacing Similar to horizontal “slices” through the topography Requires smooth (filtered) data
5/24/2015© 2009 Raymond P. Jefferis III Lect Filtered Topographic Map Malvern quadrangle Filtered data used Gaussian 7 x 7 convolution filter (s = 1.52) Contour lines at 20- meter intervals
5/24/2015© 2009 Raymond P. Jefferis III Lect Comment on Contour Map Edges are a little jaggy More filtering (smoothing) would be preferable, to get smooth contours 11x11 or 15x15 convolution kernels would be preferred
Questions? 5/24/2015© 2009 Raymond P. Jefferis III Lect