images course web page: vision.cis.udel.edu/cv march 3, 2003 lecture 8

19
Images Course web page: vision.cis.udel.edu/cv March 3, 2003 Lecture 8

Upload: janice-garrison

Post on 26-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Images

Course web page:vision.cis.udel.edu/cv

March 3, 2003 Lecture 8

Page 2: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Announcements

• Homework is due tonight by midnight (LaTeX broken in Smith 040)

• Read about convolution in Chapter 7-7.2, 7.5-7.7 of Forsyth and Ponce for Wednesday

Page 3: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Outline

• Digitization will be discussed in the camera lecture (#16)

• Image types, basic operations in Matlab

• Binary images • Image comparison• Texture mapping

Page 4: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Matlab Image Types

• Note: Although we write I(x, y), remember that Matlab uses I(r, c)

• Intensity: m x n matrix. Can be:– uint8: Unsigned 8-bit integer—i.e., in the range

[0…255]– double: Real number in range [0…1]

• True color: m x n x 3 – Basically, stacked red, green, and blue intensity

images (aka channels)

• Binary: Values are 0 or 1, type logical

Page 5: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Image Type Conversions

• Many functions work on just one channel– Run on each channel independently– Convert from color grayscale weighting each

channel by perceptual importance (rgb2gray)

• Some operations want the pixels to be real-valued– Type conversion: I2 = double(I1)

Page 6: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Image Arithmetic

• Just like matrices, we can do pixelwise arithmetic on images

• Some useful operations– Differencing: Measure of similarity– Averaging: Blend separate images or smooth a single

one over time– Thresholding: Apply function to each pixel, test value

• In Matlab: imadd, imsubtract, imcomplement, imlincomb, etc.– Beware of truncation– Can do all of these with matrix operations if you pay

attention to types and truncation

Page 7: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Thresholding

• Grayscale Binary: Choose threshold based on histogram of image intensities (Matlab: imhist)

Page 8: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Example: Image Histograms

courtesy of MathWorks

Page 9: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Derived Images: Color Similarity as Chrominance

Distance• Distance to red in YIQ space

(rgb2ntsc)• Can threshold on this

Page 10: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Connected Components

• Uniquely label each n-connected region in binary image

• 4- and 8-connectedness• Matlab: bwfill, bwselect

Page 11: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Example: Connected Components

courtesy of HIPR

Page 12: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Binary Operations

• Dilation, erosion (Matlab: imdilate, imerode)– Dilation: All 0’s next to a 1 1 (Enlarge

foreground)– Erosion: All 1’s next to a 0 0 (Enlarge

background)

Original DilatedErodedcourtesy of Reindeer Graphics

Page 13: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Moments: Region Statistics

• Zeroth-order: Size/area• First-order: Position (centroid)• Second-order: Orientation

Page 14: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Geometric Image Comparison: SSD

• Given a template image IT and an image I, how to quantify the similarity between them?

• Vector difference: Sum of squared differences (SSD)

Page 15: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Correlation for Template Matching

• Note that SSD formula can be written:

• When the last term is big, the mismatch is small—the dot product measures correlation:

• By normalizing by the vectors’ lengths, we are measuring the angle between them

Page 16: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Normalized Cross-Correlation

• Shift template image over search image, measuring normalized correlation at each point

• Local maxima indicate template matches

• Matlab: normxcorr2from Jain, Kasturi, & Schunck

Page 17: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Statistical Image Comparison:Color Histograms

• Steps– Histogram RGB/HSI triplets over two images

to be compared– Normalize each histogram by respective

total number of pixels to get frequencies – Similarity is Euclidean distance between

color frequency vectors

• Insensitive to geometric changes, including different-sized images

• Matlab: imhist, hist

Page 18: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Image Transformations

• Geometric: Compute new pixel locations – Rotate– Scale– Undistort (e.g., radial distortion from lens)

• Photometric: How to compute new pixel values when non-integral– Nearest neighbor: Value of closest pixel– Bilinear interpolation (2 x 2 neighborhood)– Bicubic interpolation (4 x 4)

Page 19: Images Course web page: vision.cis.udel.edu/cv March 3, 2003  Lecture 8

Bilinear Interpolation

• Idea: Blend four pixel values surrounding source, weighted by nearness

Vertical blend Horizontal blend