Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

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

2 Michael Eckmann - Skidmore College - CS 376b - Spring 2008 Today’s Topics Comments/Questions Enhancing images (Chap. 5)‏ –greylevel mapping functions –histogram equalization –removal of salt and pepper noise in binary and grey scale images –averaging (smoothing) filters –cross-correlation –convolution

3 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

4 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

5 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

6 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.

7 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

8 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 A box filter is a simple smoothing filter which uses an equally weighted rectangular neighborhood. A gaussian filter is a smoothing filter that gives most weight to center pixel and gradually tapers off the weight the further from the center. example of a few masks on the board

9 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Cross-correlation The process described on the last slide is similar to cross-correlation of an image and a mask. Cross-correlation involves aligning the origin of the mask with a pixel in question and multiplying the corresponding mask pixel values with the pixels in the original image and summing them all up. This summed up value is the value of the new pixel. No divide takes place. Typical masks though will either sum up to 0 or 1. A smoothing mask will sum up to 1. A derivative mask will sum up to 0. examples on the board of square masks with these properties let's review figures 5.11 (and consider using [-1,+1], 5.12, and 5.13

10 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Derivative and Smoothing masks Derivative masks –values have opposite signs in order to obtain a high response in signal regions of high contrast –sum of values is 0, so a 0 results from constant regions –first derivative masks produce high abs values at points of high contrast –second derivative masks produce zero-crossings at points of high contrast Smoothing masks –values are positive and sum to 1, so resulting value is same as input in constant regions

11 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Convolution –is similar to cross-correlation except the upper-left value in the mask is multiplied by the lower-right value in the image neighborhood and so on until the lower-right value in the mask is multiplied by the upper-left value in the image. –think of the mask being flipped along the horizontal axis and then again along the vertical axis AND THEN doing cross-correlation with the flipped mask picture on the board (and take a look at handout)‏ If the mask is symmetrical both vertically and horizontally, then cross- correlation and convolution yield the same result. The two terms are often confused and sometimes used interchangeably (incorrectly.)‏

12 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Considerations resulting value of output image pixels can be much larger than the input image pixels due to the summation, it is also possible for the output image pixels to yield negative values if the mask contains negatives --- so the type of the new image needs to be considered as possibly being different than the input image type what to do at borders of the image when cross-correlating or convolving and image and a mask and the mask overlaps (doesn't have corresponding pixels for one or more mask values.)‏ –no processing -> make all the border pixels 0 in output image; copy the border pixels from input to output; make the output image smaller; reduce the size of the mask at the border locations; reflected indexing; circular indexing note: this list comes from “Digital Image Processing” by Nick Efford.

13 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Computational considerations consider the computation involved in convolution or cross-correlation –if mask is size n x n, then for each pixel in the input image, we do n 2 multiplies and n 2 -1 additions. if a mask is separable into two vectors that, when we take the cross product of them, we get the original mask (example on the board) then we can reduce the computational complexity by first convolving or correlating the image with the column vector and then the resulting image can be convolved or correlated with the row vector to get the output image (which would be the same as convolving or correlating the nxn mask with the original image). –how many multiplies and additions now?

14 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Computational considerations if a mask is separable into two vectors that, when we take the cross product of them, we get the original mask (example on the board) then we can reduce the computational complexity by first convolving or correlating the image with the column vector and then the resulting image can be convolved or correlated with the row vector to get the output image (which would be the same as convolving or correlating the nxn mask with the original image). –how many multiplies and additions now? –(2n multiplies and 2(n-1) additions) per pixel

15 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Standard Masks prewitt masks sobel masks roberts masks


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

Similar presentations


Ads by Google