Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

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

2 Michael Eckmann - Skidmore College - CS 376b - Spring 2008 Today’s Topics Comments/Questions Enhancing images (Chap. 5)‏ –averaging (smoothing) filters –cross-correlation –convolution –smoothing examples –Prewitt and Sobel gradient masks and the idea behind them

3 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

4 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

5 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.)‏

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

7 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?

8 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

9 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Smoothing examples Gaussian function on the board http://mathworld.wolfram.com/GaussianFunction.html Let's look at a little program to generate Gaussian masks Let's look at some images and the effect of smoothing them using gimp, but gimp doesn't allow you to set the standard deviation.

10 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Estimating the gradient Often we want to find boundaries in images and know how sharp the boundaries are and in which direction the boundaries are. Given f(x,y) as our image function, we would like to compute the gradient at pixels [x,y]. The magnitude of the gradient will give us an indication of how sharp a boundary is, and the angle of the gradient will give us the direction. If we want to estimate the magnitude and direction of the gradient (where the maximum change occurs) do the following: The partial derivative of f w.r.t. x and the partial derivative of f w.r.t y make up the gradient.

11 Michael Eckmann - Skidmore College - CS 376 - Spring 2008 Estimating the gradient The partial derivative of f w.r.t. x and the partial derivative of f w.r.t y make up the gradient. We can estimate these values in a discrete image at pixel with coords x,y: –for x: take the difference between the pixel at x-1, y and x+1, y –for y: take the difference between the pixel at x, y-1 and x, y+1 We can get a better estimate if we average these calculations above and below and to the right and left of the pixel in question. Example on the board (figure 5.14)‏ These lead to the Prewitt masks The Sobel masks come from the same idea but with twice the weight given to the row/col the pixel is in.


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

Similar presentations


Ads by Google