850 likes | 968 Views
Introduction to Computer Vision. Lecture 5 Dr. Roger S. Gaborski. Example. Histogram PDF CDF Equalized Image Filtering using Correlation continued. Histogram Equalization. Consider an image with the following gray level values: Construct the pdf Construct the cdf
E N D
Introduction to Computer Vision Lecture 5 Dr. Roger S. Gaborski
Example • Histogram PDF CDF Equalized Image • Filtering using Correlation continued
Histogram Equalization • Consider an image with the following gray level values: • Construct the pdf • Construct the cdf • Equalize the image using the cdf (not histeq)
Histogram Equalization • Consider an image with the following gray level values: • Construct the pdf 1/9 2/9 3/9 4/9 5/9 .1 .2 .3 .4 .5
pdf cdf 1/9 2/9 3/9 4/9 5/9 .1 .2 .3 .4 .5 Histogram Equalization Look Up Table 1/9 2/9 3/9 4/9 5/9 6/9 7/9 8/9 1 cdf probability .1 .2 .3 .4 .5 Gray level value Gray level value
Histogram Equalization • Consider an image with the following gray level values: • Construct the pdf • Construct the cdf • Equalize the image using the cdf (not histeq)
Chapter 3 www.prenhall.com/gonzalezwoodseddins
Example - Correlation • Assume w and f are one dimensional • Origin of f is its left most point • Place w so that its right most point coincides with the origin of f • Pad f with 0s so that there are corresponding f points for each w point (also pad end with 0s) • Multiply corresponding points and sum • In this case (example on next page) result is zero • Move w to the right one value, repeat process • Continue process for whole length of f
‘Full’ correlation
‘Same’ correlation etc.
Noise Issues • g(x,y) = f(x,y) + n(x,y) • Where • f(x,y) is the original image • n(x,y) is the noise term (see text, page 143 for different types of noise) • How does noise affect the image? • Can we remove the effects of noise?
Sources of Noise • Sensor (thermal, other) • Electronic circuitry noise • Transmission noise
Standard Deviation • Statistics – analyzing data sets in terms of the relationships between the individual points • Standard Deviation is a measure of the spread of the data [0 8 12 20] [8 9 11 12] • Calculation: average distance from the mean of the data set to a point s = Σi=1n(Xi – X)2 (n -1) • Denominator of n-1 for sample and n for entire population
Standard Deviation • For example [0 8 12 20] has s = 8.32 [8 9 11 12] has s = 1.82 [10 10 10 10] has s = 0
Variance • Another measure of the spread of the data in a data set • Calculation: s2 = Σi=1n(Xi – X)2 (n -1) Why have both variance and SD to calculate the spread of data? Variance is claimed to be the original statistical measure of spread of data. However it’s unit would be expressed as a square e.g. cm2, which is unrealistic to express heights or other measures. Hence SD as the square root of variance was born.
Histogram of Noise n(x) = (1 / 22 ) * exp( -(x-u)2 / 2) where is standard deviation and u the mean
Controls the Width of the Bell-shaped Curve • Integral under curve is 1 Small Large
Data sig=ones([1 1000]); figure, stem(sig(1:15)),axis([0 15 0 2])
Averaging • Averaging will smooth the signal • smoothData(i) = noisyData(i-1)+noisyData(i)+noisyData(i+1) 3
Result of 3 Point Averaging Noisy Input Averaging with 3 Components First two responses due to edge effects (padded with zeros)
Data from Row 300 Note: Noise values (amplitude) varies rapidly – high frequency component
Can We Recover the Original Image from the Noisy Image? Noisy Input Three Point Averaging
Simple Averaging Filter • Averaging is effective a low pass filter. High frequency noise fluctuations are ‘blocked’ by the filter. • This can be an issue for fine detail. Fine detail in image will also be smoothed. • Tradeoff between keeping fine details in image and reducing noise.
Thresholded Diff Image Details lost by low pass filtering
Nagao-Matsuyama FilterAn Attempt to Keep Fine Detail • Uses 9 5x5 windows (defined on next slide). • Each 5x5 window has a distinct subwindow defined • Calculate the variance for the pixels in each subwindow • Output is the mean of the pixels in the subwindow that has the lowest variance
Nagao-Matsuyama Filter Average pixel values under red pixels. Calculate the corresponding variance. Use the filter with the smallest variance.
Nagao-Matsuyama Filter • Why does this make sense?? • Why minimum variance?? • When would a block of image data have high variance?? • Low variance??
How Could You Implement This Filter? Want to calculate variance of pixels in image where 1’s are located in filter Cannot use imfilter
Implementation • B = NLFILTER(Image,[5 5],FUN) applies the function FUN to each 5-by-5 sliding block of A. FCN 1.Calculate variance for each filter 2.Choose filter with smallest variance 3.Calculate average with chosen filter (scaled by number of 1’s )
Recall: Variance • Calculation: s2 = Σi=1n(Xi – X)2 (n -1)
Edges • We would like to develop algorithms that detect important edges in images • The ‘quality’ of edges will depend on the image characteristics • Noise can result in false edges
Profile of Edge - Analysis • Same gray level input range [0,1] • Edge is located at ‘peak’ of first derivative • Cannot choose only one threshold value because range of first derivative depends on slope of gray level values • The edge is located where the second derivative goes through zero-independent of slope of gray level signal
The derivative operation can be used to detect edgesHow can the derivative operator be approximated in a digital image??
MATLAB Examples • Approximation to derivative – difference of adjacent data values • data = [ .10 .14 .13 .12 .11 .10 .11 .34 .33 .32 .35 .10 .11 .12 .12 .12]; • diff operator: second- first data value (.14-.10) • diff(data) = 0.04 -0.01 -0.01 -0.01 -0.01 0.01 0.23 -0.01 -0.01 0.03 -0.25 0.01 0.01 0 0 diff operator is approximation to first derivative
Estimate of Second Derivative • diff(diff( data)) • -0.05 0 0.0 0 0.02 0.22 -0.24 0 0.04 -0.28 0.26 0 -0.0100 0
Simulated Data data diff(data) diff(diff(data))