cs 376b introduction to computer vision 02 / 11 / 2008 instructor: michael eckmann

19
CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Upload: lisa-nicholson

Post on 21-Jan-2016

221 views

Category:

Documents


0 download

TRANSCRIPT

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

CS 376bIntroduction to Computer Vision

02 / 11 / 2008

Instructor: Michael Eckmann

Page 2: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376b - Spring 2008

Today’s Topics• Comments/Questions

• Image acquisition/formation and representation

– some definitions

• quantization problems

• compression comment

• frames of reference

• hole counting algorithm from ch. 1

• connected components using union-find

• masks and application of masks

Page 3: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

Problems in digital images• quantization effects

•converting a continuous range to a discrete range (we'll see one type of problem with this shortly)

Page 4: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

some definitions• analog image

– “infinite” precision in space and intensity value

• digital image

– discrete 2D array of limited precision intensity values

• grey-scale image

– one intensity per pixel (e.g. if one byte intensity range is 0-255)

• multispectral image

– a vector of values at each pixel (for color, usually 3 values representing values for red, green and blue)

• binary image

– each pixel has value 0 or 1

Page 5: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

some definitions• labelled image

– all pixel values are from some finite alphabet

– usually generated from a digital image based on some way to decide which label a pixel gets

– example on board

• picture function

– f(x,y) where x and y are spatial variables and f(x,y) is the intensity at x,y

Page 6: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

from Shapiro & Stockman figure 2.9 in “Computer Vision”

quantization problems example

Page 7: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

compression comment• run coding is used as part of some compression algorithms

• to give you a sense of how an image can be losslessly compressed using run length coding

– count runs of 0's and runs of 1's

• example using 1 byte (8 bits) greyscale image

– divide up your image into 8 “bit planes”

• each plane is a binary image

• run code each binary image

• note 127 -> 128 problem– solution --- first convert all to a “grey code” which has

the property that successive greyscale differences differ in only 1 bit

Page 8: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

frames of reference• world (W)

• object (O)

• camera (C)

• real image (F)

• pixel (I)

Page 9: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

frames of reference

Page 10: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

hole counting

• external corners

• internal corners

• these are sufficient as long as the holes are “4-connected” and simple (e.g. no donuts)

Page 11: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

hole counting algorithm

Page 12: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

hole counting algorithm

Page 13: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

connected components using union-find

• A connected components labeling of a binary image B is a labeled image LB in which the value of each pixel is the label of its connected component.

• The union-find data structure stores a collection of disjoint sets and allows the efficient implementation of union and find.

– contains trees where each tree contains one of the disjoint sets

– can be stored as an array of parents where index=label and array[index]=parent label

• union – construct the union of two sets

– given the two sets' labels AND the union-find data structure

• find --- find the “root label” of a set

• examples on the board of trees and a parent array (fig. 3.9)

Page 14: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

connected components using union-find

X: label of first set,

Y: label of second set,

PARENT: array w/ union-find data structure

union (X, Y, PARENT)

{

j:=X

k:=Y

while (PARENT[j] != 0) { j:=PARENT[j]; }

while (PARENT[k] != 0) { k:=PARENT[k]; }

if (j != k) then PARENT[k]:=j;

}

(from algorithm 3.4 in Shapiro/Stockman “Computer Vision”)

Page 15: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

connected components using union-find

X: label of set,

PARENT: array w/ union-find data structure

find (X, PARENT)

{

j:=X

while (PARENT[j] != 0) { j:=PARENT[j]; }

return j;

}

(from algorithm 3.3 in Shapiro/Stockman “Computer Vision”)

Page 16: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

connected components using union-find

• Now, the classical connected-components using union-find is:

– PASS 1: travel each row from left to right

• if see a foreground pixel, examine the label of pixel above and to left (if they are labeled, then label the current pixel the lower of the two labels)

– if neither above or left pixel has labels (i.e. they are background pixels), then pick a new label for current pixel

– if both above and left pixel have different labels, enter the equivalence class into the union-find data structure (perform a union of the two sets)

• all foreground pixels have been labeled and we have a set of equivalence classes for all labels

Page 17: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

connected components using union-find

• classical connected-components using union-find (cont.)

– PASS 2:

• relabel the labels of the pixels with the root label of the equivalence class in the union-find data structure (using the find algorithm to determine this root label)

• see Algorithm 3.6 on page 65 in Shapiro and Stockman

• Let's do an example on the board.

Page 18: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

masks

• a mask is a set of pixel positions whose values are weights

• a mask has an origin, which is usually in the center of symmetrical masks

• masks are applied to images to alter their pixel values based on the pixels in their neighborhoods

– compute a new value by multiplying the corresponding weights in the mask with the values of the image pixels and sum up (and usually divide by sum of weights)

– replace pixel value with this new value

• look at an example on the board

Page 19: CS 376b Introduction to Computer Vision 02 / 11 / 2008 Instructor: Michael Eckmann

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

binary morphology

• a structuring element is a typically small binary image representing some shape

• binary image morphological operations

– dilation – increase the size of regions

– erosion – decrease the size of regions

– closing – closes up holes within regions– is a dilation followed by an erosion

– opening – get rid of jutting out portions of regions– is an erosion followed by a dilation