CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9....

29
CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy of Diane H. Theriault

Transcript of CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9....

Page 1: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

CS201: Computer Vision Lect 06: Face Detection

John Magee

Slides Courtesy of Diane H. Theriault

Page 2: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Framing

• In Computer Vision, we want to analyze and interpret images and video

• First:

– How are images represented?

– How are images formed?

– What kinds of tasks are we interested in doing?

Page 3: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Framing

• Next: How do you find things you are looking for?

– Version 1: Thresholding / Color Analysis

• Post-processing (morphological operators)

– Need to clean up messy output

• Binary image analysis – Try to reason about the objects that you find

Page 4: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Framing

• Next: How do you find things you are looking for?

– Version 2: Compute features in the images

• Example: Gradients

• Example: General Filter Responses (Today)

• Example: Corners and Keypoints (Next week)

– How to combine and use image features will be our focus when considering object recognition and many other tasks

Page 5: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Framing

• Different points of view about tasks in computer vision. Examples:

– Algorithmic (e.g. represent image as a graph)

– Statistical (Images are noisy measurements)

– Signal processing (think of image as a 2D signal)

– Machine Learning (train models using data)

Page 6: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Question of the Day:

• How can we find faces in images?

Page 7: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Face Detection

• Compute features in the image (Today)

• Apply a classifier

• Viola & Jones. “Rapid Object Detection using a Boosted Cascade of Simple Features”

Page 8: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Features with Image Filtering

• Perform image filtering by convolving an image with a “filter”/”mask” / “kernel” to obtain a “result” / “response”

• The value of the result will be

positive in regions of the image that “look like” the filter

• One type of image feature is the way the image responds to different types of filters

Image

Filter

Page 9: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Image Filtering

• To perform convolution:

• Multiply each element of the filter with the corresponding element of the image

• Sum the results -1 -1

1 1

Image

Filter

-1 -1

1 1

What is the response of the image to the filter (the result) in the region denoted by the red box?

Page 10: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Image Filtering

-1 -1

1 1

Image

Filter

1 1

-1 -1

• To perform convolution:

• Multiply each element of the filter with the corresponding element of the image

• Sum the results

What is the response of the image to the filter (the result) in the region denoted by the red box?

Page 11: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Image Filtering

-1 -1

1 1

Image

Filter

1 -1

-1 1

• To perform convolution:

• Multiply each element of the filter with the corresponding element of the image

• Sum the results

What is the response of the image to the filter (the result) in the region denoted by the red box?

Page 12: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Image Filtering

-1 -1

1 1

Image

Filter

1 -1

1 -1

1 -1

1 -1

Filter

• To perform convolution:

• Multiply each element of the filter with the corresponding element of the image

• Sum the results

What is the response of the image to the filters (the result) in the region denoted by the red box?

Page 13: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Features with Image Filtering

• Perform image filtering by convolving an image with a “filter”/”mask” / “kernel” to obtain a “result” / “response”

• The value of the result will be

positive in regions of the image that “look like” the filter

• One type of image feature is the way the image responds to different types of filters

Image

Filter

Page 14: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

What do Faces “Look Like”?

• Make a “face filter”?

Page 15: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

What do Faces “Look Like”?

• Chosen features are responses of the image to the “Haar-like” box filters

Page 16: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Image With Faces

Page 17: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Filter Responses

Page 18: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Filter Responses

Page 19: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Image with Non-faces

Page 20: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Filter Responses

Page 21: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Filter Responses

Page 22: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Convolution is Expensive!

• Computational complexity of brute force convolution is linear in the number of pixels in the filter

– if your image is NxM, and your filter is 3x3, then the cost is 9*N*M (that’s a teeny face!)

– If your image is NxM and your filter is 20 x 20, then the cost is 400*N*M

Page 23: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Computing the Responses Efficiently

• Viola and Jones chose “box” filters

• To compute the response, you take the difference of the sum of the image values in the boxes (Red minus blue)

• What if you could compute the sum of the image values in a box without visiting every pixel in the box?

Box filter

Page 24: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Computing the Responses Efficiently

• The Integral Image is the computational trick that made this paper a star

• In the Integral Image, every pixel contains the sum of all of the pixels above and to the left

Page 25: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Computing the Responses Efficiently

• Once integral image has been computed, the sum of the pixels in any sized box can be computed with 4 numbers

• Red

Page 26: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Computing the Responses Efficiently

• Once integral image has been computed, the sum of the pixels in any sized box can be computed with 4 numbers

• Red – blue

Page 27: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Computing the Responses Efficiently

• Once integral image has been computed, the sum of the pixels in any sized box can be computed with 4 numbers

• Red – blue – green

Page 28: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Computing the Responses Efficiently

• Once integral image has been computed, the sum of the pixels in any sized box can be computed with 4 numbers

• Red – blue – green + orange

• (lower right) – (upper right) – (lower left) + (upper left)

Page 29: CS201: Computer Vision Lect 06: Face Detection John Mageejmagee/cs201/slides/CS201... · 2014. 9. 16. · CS201: Computer Vision Lect 06: Face Detection John Magee Slides Courtesy

Discussion Questions:

• Describe how you use the integral image to compute the sum of any region in an image

• Using the integral image, how many operations does it take to compute the sum of a region that is 3×3? 10×10? 10×30?

• How would you use the integral image to efficiently compute the response of an image region to a box filter?

• How many operations do you need to compute the response of an image region to a box filter containing two pieces? three? four?

• What is a simple way you might try to classify image regions as containing a face or not, using the response of the image region to a box filter?