120 likes | 317 Views
Spatial operations and transformations. Last chapter uses statistical measures This chapter combines previous operations with operations on single images that deal with pixels and their neighbors (spatial operations) Spatial filters (removing noise by reference to neighboring pixel values)
E N D
Spatial operations and transformations • Last chapter uses statistical measures • This chapter combines previous operations with operations on single images that deal with pixels and their neighbors (spatial operations) • Spatial filters (removing noise by reference to neighboring pixel values) • Weighted averaging of pixel areas (convolution) • Comparing areas on an image with known pixel area shapes so as to find shapes in images (correlation) • Edge detection • Detection of ‘interest points’ 240-373 Image Processing
Spatially dependent transformations • A spatially dependent transformation is the transformation that depends on its position in the image. • The histogram of gray levels does not retain its original shape. • The spatially dependent function is F(g,X,Y), for example An image was captured using a weak ambient light together with some sort of point light source giving the effect of a dark picture at the bottom right and a light picture at the top left. The function, discovered by inspection, was used to even out thee lighting: F(g,X,Y) = X/20 + Y/20 - 5 • Use of threshold technique is unlikely to be as effective • There are other techniques for removal of this kind of gradation. 240-373 Image Processing
Technique 1 & 2 Technique 1: Gradation removing by averaging USE: to remove gradual shading across a single image (not suitable for text image) OPERATION: 1. subdivide the picture into rectangles 2. Evaluate the mean for each rectangle and also for the whole picture 3. To each rectangle of pixels, add or subtract a constant so as to give the rectangles across the picture the same mean. Technique 2: Masking USE: to remove or negate part of an image so that that part is not visible. OPERATION: ANDing an image with a binary mask amounts to thresholding to zero at the maximum gray level for part of the picture, without any thresholding on the rest of the picture. 240-373 Image Processing
Template and convolution • Template operations are very useful as elementary image filters. They can be used to: • enhance certain features, de-enhance others • identifying edge • smooth out noise • discover known shapes in an image Technique 3: Convolution USE: widely used in many operations OPERATION: • A template is an array of values. • It is placed step by step over the image. • At each step, creating a new window in the image the same size as the template • Associating with each element in the template a corresponding pixel in the image • Typically, the template element is multiplied by the corresponding image pixel gray level. The sum of these results, across the whole template, is recorded as a pixel gray level in a new image. • This ‘shift, add, multiply’ operation is called the ‘CONVOLUTION’ of the template with the image. 240-373 Image Processing
Convolution: Cont’d If T(x,y) is the template (nxm) and I(X,Y) is the image (NxM), then the convolving of T with I is written as Often the template is not allowed to shift off the edge of the image, so the resulting image will be smaller than the original image. For example Template Image Result 1 1 3 3 4 2 5 7 6 * 1 0 1 1 4 4 3 2 4 7 7 * 0 1 2 1 3 3 3 3 2 7 7 * 1 1 1 4 4 * * * * * * = no value Here the 2x2 template is operating on a 4x5 image, giving a 3x4 result. The value 5 in the result is obtained from (1x1) + (0x3) + (0x1) + (1x4) 240-373 Image Processing
Common templates • Low-pass filter (removing noise, blurring) • template 1 1 1 1 1 1 1 1 1 1 • template 2 (weighting with half of result is from the center pixel) 1 3 1 3 16 3 1 3 1 • High-pass filter (remove gradual change, enhance sudden changes) • Laplacian template (the sample sums to zero) 0 -1 0 -1 4 -1 0 -1 0 240-373 Image Processing
Example of low pass and high pass filtering Image After high pass after low pass 0 0 0 0 0 0 1 1 1 0 2 1 2 4 6 4 0 1 1 1 0 1 0 1 6 9 6 0 1 1 1 0 1 0 1 6 9 6 0 1 1 1 0 1 -5 1 11 14 11 0 1 6 1 0 -4 20 -4 11 14 11 0 1 1 1 0 2 -4 2 9 11 9 0 0 0 0 0 High-pass filter Low-pass filter 0 -1 0 1 1 1 -1 4 -1 1 1 1 0 -1 0 1 1 1 240-373 Image Processing