Introduction to Computer Vision

1 / 31

# Introduction to Computer Vision - PowerPoint PPT Presentation

Lecture 05 Roger S. Gaborski. Introduction to Computer Vision. Quiz Review In Class Exercise Correlation – Convolution Filtering. Example. Histogram PDF  CDF Equalized Image Filtering using Correlation continued. Histogram Equalization.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Introduction to Computer Vision' - ronna

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Lecture 05

Roger S. Gaborski

Introduction to Computer Vision

Roger S. Gaborski

Quiz Review

• In Class Exercise
• Correlation – Convolution
• Filtering

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)
Spatial Filtering
• Neighborhood processing
• Define center point (x, y)
• Perform operations involving only pixels in the neighborhood
• Result of operation is response to process at that point
• Moving the pixel results in a new neighborhood
• Repeat process for every point in the image

Roger S. Gaborski

Linear and Nonlinear Spatial Filtering
• Linear operation
• Multiply each pixel in the neighborhood by the corresponding coefficient and sum the results to get the response for each point (x, y)
• If neighborhood is m x n , then mn coefficients are required
• Coefficients are arranged in a matrix, called
• filter / filter mask / kernel / template
• Mask sizes are typically odd numbers (3x3, 5x5, etc.)

Roger S. Gaborski

Image origin

y

Kernel coefficients

x

Roger S. Gaborski

Correlation and Convolution
• Correlation
• Place mask w on the image array f as previously described
• Convolution
• First rotate mask w by 180 degrees
• Place rotated mask on image as described previously
• Convolution = 180 degree rotation + correlation

Roger S. Gaborski

Example: 1D 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 0
• Move w to the right one value, repeat process
• Continue process for whole length of f

Roger S. Gaborski

Reminder
• ‘full’ is the result we obtain from the operations on the previous slide. If instead of aligning the left most element of f with the right most element of w we aligned the center element of w with the left most value of f we would obtain the ‘same’ result, same indicating the result is the same length of the original w

Roger S. Gaborski

Chapter 3

www.prenhall.com/gonzalezwoodseddins

Roger S. Gaborski

‘Full’

correlation

Roger S. Gaborski

‘Same’

correlation

etc.

Roger S. Gaborski

Example - Convolution
• Convolution is the same procedure, but the filter is first rotated 180 degrees.
• Convolution = 180 degree rotation + correlation
• If the filter is symmetric, correlation and convolution results are the same

Roger S. Gaborski

Chapter 3

www.prenhall.com/gonzalezwoodseddins

This can be simply extend to images

Roger S. Gaborski

Linear Filtering in MATLAB

g = imfilter(f, w, filtering mode, boundary, size)

• filters the imput image f with the filter mask w.
• f is input image. It can be of any class (logical/numeric) and dimension.
• g is output image
• filter mode:

- \'corr\' : correlation, and default mode

- \'conv\' : convolution

Roger S. Gaborski

Parameters
• g = imfilter(f, w, filtering mode, boundary, size)

Boundary options

- X pad boundary with value X. Default X = 0.

Size options

- \'same\' g is the same size of f (default mode)

- \'full\' g is full filtered by w, so size of g is increased

Roger S. Gaborski

MATLAB function for filtering: imfilter
• g = imfilter(f, w, ‘replicate’)
• Correlation is the default filtering mode.
• If filters are pre-rotated 180 degrees, can simply use default(corr) for convolution
• If filter is symmetric, doesn’t matter

Roger S. Gaborski

Chapter 3

www.prenhall.com/gonzalezwoodseddins

Roger S. Gaborski

Example:Smoothing
• w = ones(31); (31x31 filter)
• % Normally the coefficients (w) are scaled to sum to one
• % In this example only coefficients are not scaled by 312
• % Convolution should result in a blurred result
• gd = imfilter(f, w);
• % Default mode: correlation filtering
• imshow(gd, [ ]);

Roger S. Gaborski

Chapter 3

www.prenhall.com/gonzalezwoodseddins