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

20
CS 376b Introduction to Computer Vision 02 / 08 / 2008 Instructor: Michael Eckmann

Transcript of CS 376b Introduction to Computer Vision 02 / 08 / 2008 Instructor: Michael Eckmann.

CS 376bIntroduction to Computer Vision

02 / 08 / 2008

Instructor: Michael Eckmann

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

Today’s Topics• PGM, PPM file formats (see webpages and examples)

• RGB color model• HW (required)• Image acquisition/formation and representation

– problems with digital images

– some definitions

• quantization problems

• compression comment

• frames of reference

• hole counting algorithm from ch. 1

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

RGB Color Model• Color = rR + gG + bB

• r, g and b range from 0.0 to 1.0

• notice:

white's (r,g,b) = (1,1,1)

black's (r,g,b) = (0,0,0)

complementary colors are

those that add up to (1,1,1)

can anyone tell me 2?

• image from “Computer Graphics” by Hearn and Baker

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

individual Homework• write a C++ program to generate a semi random PPM image

(named verticalStripes.ppm) with 400 columns and 300 rows

– each stripe should

• be 10 pixels high and 400 pixels wide

• start with a random 3 byte RGB color (each R G and B should be a number 0 - 255)

– select the largest of the random R G B generated and gradually and regularly alter that channel from that number down to 0 along the row of 300 pixels

– so, 30*3 random numbers are to be generated (3 at a time)

• use one set of 3 as the R G and B value of of the leftmost pixel for 10 rows

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

team Homework• you should group into 2 teams of 2 and 1 team of 3 students

– each team should have at least one student who took CG to help with 2.2 part c)

• exercises from the text

– 2.2 (p. 25)

– 2.4 (p. 34)

– and ...

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

team Homework• 2.8 (p. 39)

• find two images (a face and a landscape) on the web with a license that allows you to use them legally (e.g. creative commons) provide attribution regardless whether the license requires it (and the exact url where you found it)

– use gimp (or another program) to save it in PPM ascii, PPM raw, GIF, TIFF and 5 different quality levels (10, 25, 40, 55, 70 and original) of JPEG – make sure to change name of JPEG files when saving to diff. quality levels

• always start from the original to produce the 5 other quality levels

– make a chart containing file size in bytes for each format and examine by eye the various images and make quality judgements (consider the overall picture and fine details) specify the #rows&cols

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

CCD cameras

• image figure 2.2 in “Computer Vision” by Shapiro and Stockman

• discrete cells convert light energy into electrical charges and they integrate the light energy falling on them during the time the shutter is open

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

Video• 30 frames (images) per second for NTSC video

– can be a different rate of images e.g. 15, 60

• almost always compressed due to the large size

– example:

• a 640 x 480 image with 3 bytes per pixel uncompressed is how big?

• a 90 minute video w/ 30 frames per second uncompressed with each frame as above is how big?

• COTS (commercial off the shelf) CCD video cameras are made for other purposes than for computer vision

– e.g. pixels may not be square (4:3 ratio)

• computer vision most likely prefers/assumes square pixels

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

Problems in digital images• geometric distortion

•due to an imperfect lens the light beams don't travel on the correct path

•e.g. barrel distortion for small focal lengths

• scattering

•medium that the light travels through is rarely a vacuum, hence the light bends (e.g. air, water, other liquids ...)

• blooming

•each CCD cell is close to their neighbors so, light can leak between neighboring cells

• CCD variations

•some cells might not be all equally sensitive due to variations in the manufacturing process

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

Problems in digital images• clipping or wrap-around

•when an analog value is converted to digital, high values may be “clipped” to the max digital value, wrap around is like a modulus operator

• quantization effects

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

• chromatic distortion

•lens has the index of refraction (bending) different for different wavelengths (colors)

•let's look back at the lightbulb picture, what's the effect?

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

Problems in digital images

• images from “Computer Vision” by Shapiro and Stockman

• Blooming(left) & Barrel distortion (right)

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

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

from Shapiro & Stockman figure 2.9 in “Computer Vision”

quantization problems example

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

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

frames of reference• world (W)

• object (O)

• camera (C)

• real image (F)

• pixel (I)

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

frames of reference

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)

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

hole counting algorithm

Michael Eckmann - Skidmore College - CS 376 - Spring 2008

hole counting algorithm