180 likes | 458 Views
Filter. Image Filtering. Filtering can be use to enhance some features and de-enhance others. Usually used as a pre-processing step. 4 basic types of filters Low-pass filter High-pass filter Band-pass filter Band-stop filter . Multi-image averaging.
E N D
Filter Image Filtering • Filtering can be use to enhance some features and de-enhance others. • Usually used as a pre-processing step. • 4 basic types of filters • Low-pass filter • High-pass filter • Band-pass filter • Band-stop filter 240-373 Image Processing
Multi-image averaging • A series of poor images of the same scene can be used to find a better image. • Averaging or filtering can be used to enhance the picture. • Multi-image modal filtering • Chose the most popular gray level for each corresponding pixel in a sequence of images • Multi-image median filtering • Similar to modal filtering, except the middle value is chosen • sorting is needed • Multi-image averaging filtering • Using a weighted averaging technique 240-373 Image Processing
Recursive filtering USE: To improve a sequence of still images--reducing noise by producing new images that correspond to weighted averages of previous images. OPERATION: It is assumed that newly collected images are available from a frame store with a fixed delay between each image. 1. Setting up: • copy an image into a separate frame store, dividing all the gray levels by an integer, n. Add to that image n-1 subsequent images, the gray levels of which are also divided by n. You should now have the average of the first n images in the frame store. 2. Recursion: • For every new image, multiply the contents of the frame store by (n-1)/n and the new image by 1/n, add them together and put the result back into the frame store. THEORY: At setup the frame store contains 240-373 Image Processing
Recursive filtering cont’d Then after many images the following steady state is created: n=10 n=5 n=2 new one 0.100 0.200 0.500 last one 0.090 0.128 0.250 last but 1 0.081 0.102 0.125 last but 2 0.073 0.080 0.063 last but 3 0.066 0.066 0.031 last but 4 0.059 0.052 0.016 last but 5 0.053 0.042 0.008 last but 6 0.048 0.034 0.004 last but 7 0.043 0.027 0.002 last but 8 0.039 0.021 0.001 last but 9 0.035 0.017 0.000 and so on 240-373 Image Processing
Median Filtering USE: Noise removal while preserving edges in an image. OPERATION: Median filter is a low-pass filter that attempts to remove noisy pixels while keeping the edges intact. The value of the pixels in the window are sorted and the median--the middle value in the sorted list--is chosen. Example: Noise removal with a 3x3 median filter Image Output 240-373 Image Processing
Median Filtering Example Modal filter: similar to median filter except that the most popular value from the set of nine is chosen. 240-373 Image Processing
k-closest averaging USE: To preserve the actual values of the pixels without letting the noise get through to the final image OPERATION: • All pixels in the window are sorted • k pixels values closest to the target pixel (center pixel in the window) are averaged. If the target pixel is included, the effect is similar to a low-pass filter • k is constant that is smaller than the area of the window • To avoid pairs or triples of noisy pixels, an extension of this technique can be as follow: • k values nearest to the target, but not including q values closest to and including the target. 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 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
Storing the convolution results • Convolution results normally need examination and transformation before storage. • In most applications, images are held as one array of bytes (or three arrays of bytes for color images). Each byte hold 0-255 unsigned integer. • The results of an operation must be transformed to within the range. • Scaling can be done to adjust the result range. • Other method is to use a floating point variable to hold each pixel value. This needs more memory, scaling and rounding. 240-373 Image Processing