EE 6358 Computer vision Image Filtering
description
Transcript of 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
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
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
04/22/2304/22/23 44
Linearity:Linearity:1D Convolution:1D Convolution:
2D convolution:2D convolution:
04/22/2304/22/23 55
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.
04/22/2304/22/23 77
Image with poor contrastImage with poor contrast
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.
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]
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
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
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
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.
04/22/2304/22/23 1414
Original picture Original picture
After histogram modificationAfter histogram modification
04/22/2304/22/23 1515
Original pictureOriginal picture After histogram modificationAfter histogram modification
04/22/2304/22/23 1616
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
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.
04/22/2304/22/23 1919
Original image Image with noise Original image Image with noise
Salt and pepper noise
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.
04/22/2304/22/23 2121
Original image Image affected by impulse noiseOriginal image Image affected by impulse noise
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.
04/22/2304/22/23 2323
Original image image affected by Gaussian noiseOriginal image image affected by Gaussian noise
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.
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
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
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.
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.
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.
04/22/2304/22/23 3030
Median filterMedian filter
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.
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
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.
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
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
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
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.
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.