240 373 Image Processing Montri Karnjanadecha montricoe psu

  • Slides: 31
Download presentation
240 -373 Image Processing Montri Karnjanadecha montri@coe. psu. ac. th http: //fivedots. coe. psu.

240 -373 Image Processing Montri Karnjanadecha montri@coe. psu. ac. th http: //fivedots. coe. psu. ac. th/~montri 240 -373: Chapter 5: Image Filtering 1

Chapter 5 Image Filtering 240 -373: Chapter 5: Image Filtering 2

Chapter 5 Image Filtering 240 -373: Chapter 5: Image Filtering 2

Image Filtering Filter • Filtering can be use to enhance some features and de-enhance

Image Filtering Filter • Filtering can be use to enhance some features and de-enhance others. • Usually used as a pre-processing step. • 4 basic types of filters (1)Low-pass filter (3)Band-pass filter 240 -373: Chapter 5: Image Filtering (2) High-pass filter (4) Band-stop filter 3

Multi-image averaging • A series of poor images of the same scene can be

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. 240 -373: Chapter 5: Image Filtering 4

Multi-image Averaging Techniques • Multi-image modal filtering – Chose the most popular gray level

Multi-image Averaging Techniques • 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: Chapter 5: Image Filtering 5

Recursive Filtering Technique 9: Recursive filtering USE: To improve a sequence of still images--reducing

Recursive Filtering Technique 9: 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. 240 -373: Chapter 5: Image Filtering 6

Recursive Filtering (cont’d(. 1 Setting up: – copy an image into a separate frame

Recursive Filtering (cont’d(. 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. 240 -373: Chapter 5: Image Filtering 7

Recursive Filtering (cont’d( THEORY: At setup the frame store contains Then after many images

Recursive Filtering (cont’d( THEORY: At setup the frame store contains Then after many images the following steady state is created: 240 -373: Chapter 5: Image Filtering 8

Recursive Filtering cont’d new one last but 1 last but 2 last but 3

Recursive Filtering cont’d new one last but 1 last but 2 last but 3 last but 4 last but 5 last but 6 last but 7 last but 8 last but 9 and so on 240 -373: Chapter 5: Image Filtering n=10 0. 100 0. 090 0. 081 0. 073 0. 066 0. 059 0. 053 0. 048 0. 043 0. 039 0. 035 n=5 0. 200 0. 128 0. 102 0. 080 0. 066 0. 052 0. 042 0. 034 0. 027 0. 021 0. 017 n=2 0. 500 0. 250 0. 125 0. 063 0. 031 0. 016 0. 008 0. 004 0. 002 0. 001 0. 000 9

Median Filtering USE: Noise removal while preserving edges in an image. OPERATION: Median filter

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. 240 -373: Chapter 5: Image Filtering 10

Median Filtering Example: Noise removal with a 3 x 3 median filter Image Output

Median Filtering Example: Noise removal with a 3 x 3 median filter Image Output 240 -373: Chapter 5: Image Filtering 11

Median Filtering Example Modal filter: similar to median filter except that the most popular

Median Filtering Example Modal filter: similar to median filter except that the most popular value from the set of nine is chosen. 240 -373: Chapter 5: Image Filtering 12

k-closest averaging USE: To preserve the actual values of the pixels without letting the

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: Chapter 5: Image Filtering 13

Template and convolution • Template operations are very useful as elementary image filters. They

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 240 -373: Chapter 5: Image Filtering 14

Convolution USE: widely used in many operations OPERATION: • A template is an array

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 240 -373: Chapter 5: Image Filtering 15

Convolution (cont’d( OPERATION: • Associating with each element in the template a corresponding pixel

Convolution (cont’d( OPERATION: • 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: Chapter 5: Image Filtering 16

Convolution (cont’d( If T(x, y) is the template (n x m) and I(X, Y)

Convolution (cont’d( If T(x, y) is the template (n x m) and I(X, Y) is the image (Nx. M), then the convolving of T with I is written as 240 -373: Chapter 5: Image Filtering 17

Convolution (cont’d( Often the template is not allowed to shift off the edge of

Convolution (cont’d( 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 *7742 *7723 ***** Image Result * 6 7 5 24 3 3 1 1 34411 01 33312 10 44111 =* no value 240 -373: Chapter 5: Image Filtering 18

Convolution (cont’d( From the example, the 2 x 2 template is operating on a

Convolution (cont’d( From the example, the 2 x 2 template is operating on a 4 x 5 image, giving a 3 x 4 result. The value 5 in the result is obtained from (1 x 1) + (0 x 3) + (0 x 1) + (1 x 4) 240 -373: Chapter 5: Image Filtering 19

Common templates • Low-pass filter (removing noise, blurring( – template 1 111 111 –

Common templates • Low-pass filter (removing noise, blurring( – template 1 111 111 – template 2 (weighting with half of result is from the center pixel( 1 3 16 3 1 240 -373: Chapter 5: Image Filtering 20

Common templates • High-pass filter (remove gradual change, enhance sudden changes( – Laplacian template

Common templates • High-pass filter (remove gradual change, enhance sudden changes( – Laplacian template (the sample sums to zero( 0 1 - 4 10 1 - 0 240 -373: Chapter 5: Image Filtering 21

Example of low pass and high pass filtering Image 0 0 0 4 6

Example of low pass and high pass filtering Image 0 0 0 4 6 42 6 9 61 6 9 6 1 11 14 11 9 0 0 0 After high pass 1 0 0 after low pass 2 0 1 1 1 0 1 5 - 1 0 1 1 1 0 4 - 20 40 1 6 1 0 2 4 - 2 0 1 1 1 0 240 -373: Chapter 5: Image Filtering 22

Storing the convolution results • Convolution results normally need examination and transformation before storage.

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: Chapter 5: Image Filtering 23

Interest Points • Interest points are identified by algorithms that can be applied first

Interest Points • Interest points are identified by algorithms that can be applied first to images containing a known object, and then to images where recognition of the object is required 240 -373: Chapter 5: Image Filtering 24

Moravec operator Technique 6: Moravec operator USE: To identify a set of points on

Moravec operator Technique 6: Moravec operator USE: To identify a set of points on an image by which the image may be classified or compared OPERATION: – Computing variance where 240 -373: Chapter 5: Image Filtering 25

Moravec operator – Passing a 3 x 3 window and saving minimum – Passing

Moravec operator – Passing a 3 x 3 window and saving minimum – Passing a 3 x 3 window and setting to zero the center pixel when its value is not maximum in the window – Simplified formula 240 -373: Chapter 5: Image Filtering 26

Example Image Variances 240 -373: Chapter 5: Image Filtering After step 1 After step

Example Image Variances 240 -373: Chapter 5: Image Filtering After step 1 After step 2 27

Correlation Technique 7: Correlation USE: To find where a template matches a window in

Correlation Technique 7: Correlation USE: To find where a template matches a window in an image, To determine the existence of a known shape in an image. THEORY: If N x M image is addressed by I(X, Y) and n x m template is addressed by t(i, j) then 240 -373: Chapter 5: Image Filtering 28

Correlation 3 240 -373: Chapter 5: Image Filtering 2 1 29

Correlation 3 240 -373: Chapter 5: Image Filtering 2 1 29

Correlation : 1 is constant across the image, so can be ignored : 2

Correlation : 1 is constant across the image, so can be ignored : 2 is t convolved with I : 3 is constant only if average light from image is constant across image (often approximately true( 240 -373: Chapter 5: Image Filtering 30

Some comments on correlation technique • If overall light intensity across the whole image

Some comments on correlation technique • If overall light intensity across the whole image is fairly constant, it is safe to use convolution instead of correlation. • The object may have any orientation. • The object may have any size. 240 -373: Chapter 5: Image Filtering 31