ee 6358 computer vision image filtering

38
06/15/22 06/15/22 EE 6358 EE 6358 Computer vision Computer vision Image Image Filtering Filtering By By Srividya Varanasi Srividya Varanasi Graduate Student Graduate Student Dept of Electrical Engineering Dept of Electrical Engineering Fall 2005 Fall 2005

Upload: marcy

Post on 09-Feb-2016

56 views

Category:

Documents


0 download

DESCRIPTION

EE 6358 Computer vision Image Filtering. By Srividya Varanasi Graduate Student Dept of Electrical Engineering Fall 2005. Need for image filtering. Remove noise Sharpen contrast Highlight contours in images. Basic terminology. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23

EE 6358EE 6358

Computer visionComputer vision

Image FilteringImage Filtering

ByBy

Srividya VaranasiSrividya Varanasi

Graduate StudentGraduate Student

Dept of Electrical EngineeringDept of Electrical Engineering

Fall 2005Fall 2005

Page 2: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 22

Need for image filteringNeed for image filtering

Remove noiseRemove noise

Sharpen contrastSharpen contrast

Highlight contours in images Highlight contours in images

Page 3: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 33

Basic terminologyBasic terminology

The Spatial, Frequency and Time domains:The Spatial, Frequency and Time domains:

Time domain applies to signals which are represented only Time domain applies to signals which are represented only in 1Din 1D

Ex: Audio signalsEx: Audio signals

The spatial domain describes a 2D signal The spatial domain describes a 2D signal Ex: ImageEx: Image

Both these domains can be converted to frequency domainBoth these domains can be converted to frequency domain

Page 4: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 44

Linearity:Linearity:1D Convolution:1D Convolution:

2D convolution:2D convolution:

Page 5: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 55

Page 6: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 66

Histogram ModificationHistogram Modification

Purpose for histogram modification:Purpose for histogram modification: To sharpen the contrast of an imageTo sharpen the contrast of an image

Reasons for poor contrast: Many images contain unevenly distributed gray values. It is common to find the intensities to lie within a small range, resulting in poor contrast.

Page 7: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 77

Image with poor contrastImage with poor contrast

Page 8: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 88

Definition:. If an image has a histogram of pixel intensities that has been highly skewed toward darker levels, detail is often imperceptible in the darker regions when such an image is viewed on a conventional display with only 8-bit pixels. Histogram modification can alleviate this problem by rescaling the original image so that the histogram of pixel intensities follows some preferred form.

Page 9: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 99

Method of histogram modification:Method of histogram modification:

Histogram modification is a method of stretching the Histogram modification is a method of stretching the contrast of the image by Uniformly redistributing the contrast of the image by Uniformly redistributing the gray values. gray values.

An example of histogram modification is image An example of histogram modification is image scaling, in which pixels in range scaling, in which pixels in range [a,b] [a,b] are expanded to are expanded to fill the range fill the range [z1,zk][z1,zk]

Page 10: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 1010

The formula for mapping a pixel value ‘z’ in the original The formula for mapping a pixel value ‘z’ in the original range into a pixel value z’ in the new range is given by:range into a pixel value z’ in the new range is given by:

Eqn 1.1

Page 11: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 1111

Drawbacks of image scaling:Drawbacks of image scaling:

The histogram stretched according to The histogram stretched according to equation 1.1 has gaps between bins.equation 1.1 has gaps between bins.

Often artifacts appearOften artifacts appear by using this methodby using this method

Page 12: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 1212

Alternate methods of histogram modification:Alternate methods of histogram modification:

• If the desired gray value distribution is known ahead of time If the desired gray value distribution is known ahead of time thenthen

If PIf Pi i be the number of pixels at level zbe the number of pixels at level z i i in the original histogram in the original histogram

qqi i the number of pixels at level zthe number of pixels at level z i i in the desired histogramin the desired histogram

We begin at the left end of the original histogram and find KWe begin at the left end of the original histogram and find K11

such thatsuch that

11

11

1 kp

kqp

ii

iii

Page 13: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 1313

The pixels at levels zThe pixels at levels z1 1 , z, z2 2 …..,z…..,zk1-1k1-1 map to level z map to level z1 1 in the new in the new

image.image.

Next , find gray value kNext , find gray value k2 2 such thatsuch that

22

21

11

1 kp

kqqp

ii

ii

The next range of pixel values zzk1k1 , z , zk2k2 …..,z …..,zk2-1k2-1 map to level z map to level z22

in the new image. This procedure is repeated until all gray in the new image. This procedure is repeated until all gray values in original histogram have been added.values in original histogram have been added.

Page 14: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 1414

Original picture Original picture

After histogram modificationAfter histogram modification

Page 15: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 1515

Original pictureOriginal picture After histogram modificationAfter histogram modification

Page 16: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 1616

Page 17: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 1717

Common types of noiseCommon types of noise

Salt and pepper noiseSalt and pepper noise

Impulse noise Impulse noise

Gaussian noiseGaussian noise

Page 18: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 1818

Salt n pepper noise:Salt n pepper noise:

Salt and pepper noise contains random occurrences of Salt and pepper noise contains random occurrences of both black and white intensity values.both black and white intensity values.

Page 19: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 1919

Original image Image with noise Original image Image with noise

Salt and pepper noise

Page 20: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 2020

Impulse noise:Impulse noise: Impulse noise is noise of short duration and high Impulse noise is noise of short duration and high

energy.energy.

It mostly occurs in over the air transmission such as It mostly occurs in over the air transmission such as satellite transmission.satellite transmission.

Common sources of impulse noise are lightening, Common sources of impulse noise are lightening, industrial machines, high voltage power lines.industrial machines, high voltage power lines.

Page 21: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 2121

Original image Image affected by impulse noiseOriginal image Image affected by impulse noise

Page 22: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 2222

Gaussian Noise:Gaussian Noise:

Gaussian noise has equal energy at all frequencies.

While the frequency distribution may be the same, the amplitude near zero are more common, and extreme values are less common.

Page 23: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 2323

Original image image affected by Gaussian noiseOriginal image image affected by Gaussian noise

Page 24: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 2424

Linear FiltersLinear Filters

Good for removing Gaussian noise as well as other Good for removing Gaussian noise as well as other types of noisetypes of noise

Is implemented using weighted sum of pixels in Is implemented using weighted sum of pixels in successive windows.successive windows.

Page 25: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 2525

1.Mean Filter1.Mean Filter

It is implemented by a local averaging operation where It is implemented by a local averaging operation where the value of each pixel is replaced by the average of all the value of each pixel is replaced by the average of all the values in the local neighborhood.the values in the local neighborhood.

p1p1 p2p2 p3p3

p4p4 p5p5 p6p6

p7p7 p8p8 p9p9

11 11 11

11 11 11

11 11 11

19

X

Page 26: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 2626

Salt n pepper noise 3X3 mean filter 5X5 mean filterSalt n pepper noise 3X3 mean filter 5X5 mean filter

Page 27: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 2727

Drawbacks of Mean FilterDrawbacks of Mean Filter

These examples illustrate the two main problems with These examples illustrate the two main problems with mean filtering, which are: mean filtering, which are:

A single pixel with a very unrepresentative value can A single pixel with a very unrepresentative value can significantly affect the mean value of all the pixels in its significantly affect the mean value of all the pixels in its neighborhood. neighborhood.

When the filter neighborhood straddles an edge, the filter When the filter neighborhood straddles an edge, the filter will interpolate new values for pixels on the edge and so will interpolate new values for pixels on the edge and so will blur that edge. This may be a problem if sharp edges will blur that edge. This may be a problem if sharp edges are required in the output. are required in the output.

Page 28: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 2828

Median FilterMedian Filter

The problems encountered by using a mean The problems encountered by using a mean filter are tackled by the median filter, which is filter are tackled by the median filter, which is often a better filter for reducing noise than the often a better filter for reducing noise than the mean filter, but it takes longer to compute. mean filter, but it takes longer to compute.

Page 29: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 2929

Like the mean filter , the median filter considers each pixel in Like the mean filter , the median filter considers each pixel in the image in turn and looks at its nearby neighbors to decide the image in turn and looks at its nearby neighbors to decide whether or not it is representative of its surroundings. Instead whether or not it is representative of its surroundings. Instead of simply replacing the pixel value with the of simply replacing the pixel value with the meanmean of of neighboring pixel values, it replaces it with the neighboring pixel values, it replaces it with the medianmedian of of those values.those values.

The median is calculated by first sorting all the pixel values The median is calculated by first sorting all the pixel values from the surrounding neighborhood into numerical order and from the surrounding neighborhood into numerical order and then replacing the pixel being considered with the middle pixel then replacing the pixel being considered with the middle pixel value. (If the neighborhood under consideration contains an value. (If the neighborhood under consideration contains an even number of pixels, the average of the two middle pixel even number of pixels, the average of the two middle pixel values is used.) Figure 1 illustrates an example calculation. values is used.) Figure 1 illustrates an example calculation.

Page 30: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 3030

Median filterMedian filter

Page 31: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 3131

Gaussian Smoothing FilterGaussian Smoothing Filter

They are a class of linear smoothing filters with They are a class of linear smoothing filters with the weights chosen according to the shape of a the weights chosen according to the shape of a Gaussian function.Gaussian function.

It is very good filter for removing noise drawn It is very good filter for removing noise drawn from a normal distribution.from a normal distribution.

Page 32: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 3232

The 2D zero-mean discrete Gaussian function used for processing images is as given

2

22

2

)(

, ji

ejig

A plot of this function is as shown in the figure

Page 33: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 3333

Properties of Gaussian filters:Properties of Gaussian filters:

i. Amount of smoothing performed will be same in all directions, since Gaussian functions are rotationally symmetric.

ii. Gaussian filter smooths by replacing each image pixel with a weighted average of the neighboring pixels such that the weight given to a neighbor decreases monotonically with distance from central pixel. This property helps in retaining the edges.

Page 34: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 3434

iii. The width and hence the degree of smoothing, of a Gaussian filter is parameterized by standard deviation. The larger the deviation wider the Filter and the greater the smoothing and vice versa

iii. Since Gaussian functions are separable ,large filters can be implemented very efficiently. .

Slide 32Slide 32

Page 35: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 3535

Fast detection and impulsive noise removal Fast detection and impulsive noise removal in imagesin images

Review of impulse noise:Review of impulse noise:

i.i. Impulse noise is noise of short duration and high energy.Impulse noise is noise of short duration and high energy.

ii.ii. It mostly occurs in over the air transmission such as satellite It mostly occurs in over the air transmission such as satellite transmission.transmission.

iii.iii. Common sources of impulse noise are lightening, industrial Common sources of impulse noise are lightening, industrial machines, high voltage power lines.machines, high voltage power lines.

Reference: IEEE Transactions on image processing VOL 10 No.1 Jan 2001Reference: IEEE Transactions on image processing VOL 10 No.1 Jan 2001

Page 36: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 3636

Noise detection algorithm:Noise detection algorithm:

The detection of corrupted signals in the image is performed by The detection of corrupted signals in the image is performed by calculating the distances between the central pixels and its calculating the distances between the central pixels and its neighbors and counting the number of neighbors whose neighbors and counting the number of neighbors whose distance to the central pixel is not exceeding a predefined distance to the central pixel is not exceeding a predefined threshold .threshold .

The number of pixels which are close enough to the pixel The number of pixels which are close enough to the pixel under consideration serves as an indicator whether the pixel under consideration serves as an indicator whether the pixel is corrupted by impulse noise or notis corrupted by impulse noise or not

Page 37: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 3737

The central pixel in the filtering window is detected as The central pixel in the filtering window is detected as unaffected by impulse noise if there are unaffected by impulse noise if there are mm neighbors in the neighbors in the window, which are close enough.window, which are close enough.

The closeness is defined by a distance parameter The closeness is defined by a distance parameter d. d. Otherwise, it will be replaced by the vector median of samples Otherwise, it will be replaced by the vector median of samples in the window.in the window.

Page 38: EE 6358                               Computer vision Image Filtering

04/22/2304/22/23 3838

Advantages of this method:Advantages of this method:

• The main advantages of this technique is its simplicity The main advantages of this technique is its simplicity and enormous computational speed.and enormous computational speed.

• Many well known filters introduce too much smoothing, Many well known filters introduce too much smoothing, which results in blurring of the output image. This which results in blurring of the output image. This undesired property is caused by unnecessary filtering of undesired property is caused by unnecessary filtering of the noise-free samples that should be passed to the filter the noise-free samples that should be passed to the filter output without any change.output without any change.