Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 376b Introduction to Computer Vision 02 / 25 / 2008 Instructor: Michael Eckmann.

Similar presentations


Presentation on theme: "CS 376b Introduction to Computer Vision 02 / 25 / 2008 Instructor: Michael Eckmann."— Presentation transcript:

1 CS 376b Introduction to Computer Vision 02 / 25 / 2008 Instructor: Michael Eckmann

2 Michael Eckmann - Skidmore College - CS 376b - Spring 2008 Today’s Topics Comments/Questions In class exam on March 5th, details to follow by tomorrow review my program to perform dilation and erosion using openCV thresholding –automatic thresholding using Otsu method Enhancing images (Chap. 5)‏ –greylevel mapping functions –histogram equalization –removal of salt and pepper noise in binary and grey scale images –averaging (smoothing) filters

3 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 thresholding thresholding is a way to make a binary image out of a greyscale image –assume t and t h are thresholds (for an 8bit greyscale image, a value between 0 and 255)‏ –threshold above makes all pixels with greyvalue >= t be 1, others 0 –threshold below makes all pixels with greyvalue < t be 1, others 0 –threshold inside makes all pixels with t <= greyvalue < t h be 1, others 0 –threshold outside makes all pixels with t > greyvalue OR greyvalue >= t h be 1, others 0 can use a histogram to compute these thresholds –if the histogram is bimodal (2 modes) that are distinct (contain a valley with values near 0 between the modes) then can choose a threshold as a greyvalue in the valley (example on the board)‏

4 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 thresholding Otsu method of automatic threshold determination (1979)‏ assumes a bimodal distribution (may not work well when this assumption does not hold)‏ range of grey values: 0 to I Histogram probabilities for each grey value –P(i) = # of pixels with greyvalue i / total # of pixels in image The procedure works like follows –choose a threshold t –compute the variance of the pixels with grey values less than or equal to t the pixels with grey values greater than t –the best t is when the weighted sum of the Within-Group variance is minimized

5 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 thresholding assume group 1 is comprised of the pixels with grey values <= t and group 2 is comprised of the others the Within-Group variance is defined to be q 1 (t)*Var 1 (t) + q 2 (t)*Var 2 (t)‏ where q 1 (t) = Sum of the P(i)'s for all i's <= t q 2 (t) = Sum of the P(i)'s for all i's > t computing all this stuff for every possible threshold t would be very inefficient. However, there is a way to make it more efficient by extracting all the computations that are not dependent on t.

6 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 thresholding Instead of minimizing the Within-Group variance, one can maximize the Between-Group variance which is a formula containing only q 1 (t) and the means of the two groups. q 1 (t+1) is easily computed from q 1 (t) how? mean 1 (t+1) can be computed from mean 1 (t) and q 1 (t)‏ similarly for mean 2 (t+1)‏

7 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 thresholding Dynamic thresholding - If the intensities of the pixels are strongly dependent on the location in the image, then one can use local thresholds (and apply them only in the local area) as opposed to global thresholds Knowledge-based thresholding – uses prior knowledge of the shape/size of objects to determine the regions and the thresholds

8 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Enhancing Images When to enhance an image –if an image contains unwanted (for whatever reason) variation of some data we wish to extract e.g., reduce noise, enhance contrast, enhance contours/edges A pixel in our output image can depend on –a local neighborhood of pixels in the input image –global information about the input image

9 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Enhancing Images Grey-level mapping –specify a function whose domain is the input image intensities and whose range is the output image intensities –sometimes called contrast stretching –example of some mapping functions on the board and in the gimp point operator –Out[x,y] = f(In[x,y])‏ output pixel value depends only on the input pixel value (not a neighborhood) but f can depend on global parameters

10 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Enhancing Images Histogram equalization –the idea is, given an input image and its histogram, we want to create an output image with an approximately uniform histogram and use all the available grey levels in the output image –the transformation should be single-valued and monotonically increasing Compute probabilities of each of the input grey values cumulative distribution function (cdf) which is a function on each grey value and whose value is the sum of all probabilities <= that grey value multiply the cdf by L-1, where L is the # of grey values in output image round the value to an integer

11 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Enhancing Images Examples on the board of computing: probabilities of each of the input grey values cumulative distribution function (cdf) which is a function whose domain is each grey value and value of the function is the sum of all probabilities <= that grey value multiply the cdf by L-1, where L is the # of grey values in output image round the value to an integer Let's look on the web for examples of original and histogram equalized images.

12 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Enhancing Images Removal of salt-and-pepper noise from binary images –can match a 3x3 mask of all 1's except center is 0 –and if match (including the 0's – not like morphology), then set the 0 pixel to 1 –also match a 3x3 mask of all 0's except center is 1 –and if match (including the 0's – not like morphology), then set the 1 pixel to 0 removal of salt-and-pepper noise from greyscale images is typically done with a median filter –consider a neighborhood around each pixel, –sort the grey values and choose the median value (the one that appears in the middle of the sorted list)‏ –e.g. a 5x5 neighborhood will have 25 pixels, the median is the 13 th highest value

13 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Enhancing Images Contrast the median filter with an averaging filter (often called a smoothing filter)‏ A smoothing filter computes a new value of a pixel by the following –given a mask of values, multiply each value in the mask by the corresponding pixel value in the image and add them up –then divide by the total of the grey values in the mask example of a few 3x3 masks on the board


Download ppt "CS 376b Introduction to Computer Vision 02 / 25 / 2008 Instructor: Michael Eckmann."

Similar presentations


Ads by Google