Designing Applications that See Lecture 3: Image Processing Dan - - PowerPoint PPT Presentation

designing applications that see lecture 3 image processing
SMART_READER_LITE
LIVE PREVIEW

Designing Applications that See Lecture 3: Image Processing Dan - - PowerPoint PPT Presentation

stanford hci group / cs377s Designing Applications that See Lecture 3: Image Processing Dan Maynes-Aminzade 15 January 2008 Designing Applications that See http://cs377s.stanford.edu Reminders Register on Axess Assignment #1 out today,


slide-1
SLIDE 1

stanford hci group / cs377s

Designing Applications that See Lecture 3: Image Processing

Designing Applications that See http://cs377s.stanford.edu

Dan Maynes-Aminzade 15 January 2008

slide-2
SLIDE 2

Reminders

Register on Axess Assignment #1 out today, due next Tuesday in lecture N l 377 Newsgroup: su.class.cs377s Next lecture is an interactive workshop, so bring your webcam if you have one Remember to check the course calendar for the latest readings

15 January 2008 2 Lecture 3: Image Processing

slide-3
SLIDE 3

Today’s Goals

Get an overview of various low-level image processing techniques Understand what they are good for and when to use them when to use them Next lecture: hands-on demo of these techniques in action

15 January 2008 3 Lecture 3: Image Processing

slide-4
SLIDE 4

Outline

Image basics Color Image filters Features Shapes

15 January 2008 4 Lecture 3: Image Processing

slide-5
SLIDE 5

“Image Processing”

Which of these two images contains a red circle?

15 January 2008 5 Lecture 3: Image Processing

slide-6
SLIDE 6

“Image Processing”

Which of these two images contains a red circle?

15 January 2008 6 Lecture 3: Image Processing

slide-7
SLIDE 7

“Image Processing”

Which of these two images contains a red circle?

15 January 2008 7 Lecture 3: Image Processing

slide-8
SLIDE 8

“Preattentive” Processing

Certain basic visual properties are detected immediately by low-level visual system “Pop-out” vs. serial search T k th t b f d i l th Tasks that can be performed in less than 200 to 250 milliseconds on a complex display Eye movements take at least 200 ms to initiate

15 January 2008 8 Lecture 3: Image Processing

slide-9
SLIDE 9

Preattentive Visual Search Tasks

15 January 2008 9 Lecture 3: Image Processing

slide-10
SLIDE 10

Cockpit Dials

Detection of a slanted line in a sea of vertical lines is preattentive

15 January 2008 10 Lecture 3: Image Processing

slide-11
SLIDE 11

Perspective

15 January 2008 11 Lecture 3: Image Processing

(courtesy of Maria Petrou)

slide-12
SLIDE 12

What is an Image?

Digital representation of a real-world scene Composed of discrete “picture elements” (pixels) Pi l t i d b Pixels parameterized by

Position Intensity Time

15 January 2008 12 Lecture 3: Image Processing

slide-13
SLIDE 13

What is an Image?

A 2D domain

With samples at regular points (almost always a rectilinear grid) Whose values represent gray levels, colors, or iti

  • pacities

Common image types:

1 sample per point (B&W or Grayscale) 3 samples per point (Red, Green, and Blue) 4 samples per point (Red, Green, Blue, and “Alpha”, a.k.a. Opacity)

15 January 2008 13 Lecture 3: Image Processing

slide-14
SLIDE 14

Channels

In an images with multiple samples per pixel, we refer

Red Channel of Image, 1 sample per pixel 3 samples per pixel

p , to each set of

  • ne type of

sample as a "plane" or "channel."

15 January 2008 14 Lecture 3: Image Processing

Blue Channel of Image, 1 sample per pixel

(courtesy Andries van Dam)

slide-15
SLIDE 15

Spatial Sampling

15 January 2008 15 Lecture 3: Image Processing

(courtesy of Gonzalez and Woods)

slide-16
SLIDE 16

Quantization

15 January 2008 16 Lecture 3: Image Processing

(courtesy of Gonzalez and Woods)

slide-17
SLIDE 17

What is Image Processing?

Generally, an attempt to do one of the following:

Restore an image (take a corrupted image and recreate a clean original) g ) Enhance an image (alter an image to make its meaning clearer to human observers) Understand an image (mimic the human visual system in extracting meaning from an image)

15 January 2008 17 Lecture 3: Image Processing

slide-18
SLIDE 18

Image Restoration

Removing sensor noise Restoring old, archived film and images that has been damaged

15 January 2008 18 Lecture 3: Image Processing

(courtesy of Gonzalez and Woods)

slide-19
SLIDE 19

Image Restoration

15 January 2008 19 Lecture 3: Image Processing

slide-20
SLIDE 20

Image Enhancement

Often used to increase the contrast in images that are overly dark or light Enhancement algorithms often play to humans’ sensitivity to contrast humans sensitivity to contrast

15 January 2008 20 Lecture 3: Image Processing

(courtesy of Tobey Thorn)

slide-21
SLIDE 21

Image Understanding

Image understanding includes many different tasks

Segmentation (identifying objects in an image) Classification (assigning labels to individual Classification (assigning labels to individual

  • bjects or pixels)

Interpretation (extracting meaning from the image as a whole)

15 January 2008 21 Lecture 3: Image Processing

slide-22
SLIDE 22

Image Processing: Hierarchy of Tasks

15 January 2008 22 Lecture 3: Image Processing

(courtesy of B. Jähne)

slide-23
SLIDE 23

Separating Regions with Filters

15 January 2008 23 Lecture 3: Image Processing

slide-24
SLIDE 24

What is Color?

A box of pencils?

15 January 2008 24 Lecture 3: Image Processing

slide-25
SLIDE 25

What is Color?

A quantity related to the wavelength of light in the visible spectrum?

15 January 2008 25 Lecture 3: Image Processing

(courtesy of J.M. Rehg)

slide-26
SLIDE 26

What is Color?

A perceptual attribute of objects and scenes constructed by the visual system?

15 January 2008 26 Lecture 3: Image Processing

(courtesy R. Beau Lotto)

slide-27
SLIDE 27

Color Perception

15 January 2008 27 Lecture 3: Image Processing

(courtesy R. Beau Lotto)

slide-28
SLIDE 28

How Do We Use Color?

In Biological Vision

Distinguish food from nonfood Help identify predators and prey Check health of others Check health of others

In Computer Vision

Find a person’s skin Segment (group together) pixel regions belonging to the same object

15 January 2008 28 Lecture 3: Image Processing

(courtesy of J.M. Rehg)

slide-29
SLIDE 29

Colorblindness

15 January 2008 29 Lecture 3: Image Processing

Ishihara Test for Color Blindness

slide-30
SLIDE 30

Human Photoreceptors

15 January 2008 30 Lecture 3: Image Processing

Cones Rods

slide-31
SLIDE 31

Human Cone Sensitivities

15 January 2008 31 Lecture 3: Image Processing

slide-32
SLIDE 32

Reflectance and Transmittance

15 January 2008 32 Lecture 3: Image Processing

Reflectance Transmittance (courtesy of Brian Wandell)

slide-33
SLIDE 33

Reflectance

15 January 2008 33 Lecture 3: Image Processing

slide-34
SLIDE 34

Transmittance

15 January 2008 34 Lecture 3: Image Processing

slide-35
SLIDE 35

Illumination Spectra

15 January 2008 35 Lecture 3: Image Processing

slide-36
SLIDE 36

Reflectance Spectra

15 January 2008 36 Lecture 3: Image Processing

slide-37
SLIDE 37

Assigning Names to Spectra

15 January 2008 37 Lecture 3: Image Processing

slide-38
SLIDE 38

Additive Color Mixing

15 January 2008 38 Lecture 3: Image Processing

slide-39
SLIDE 39

Subtractive Color Mixing

15 January 2008 39 Lecture 3: Image Processing

slide-40
SLIDE 40

The Color Matching Experiment

15 January 2008 40 Lecture 3: Image Processing

slide-41
SLIDE 41

Experiment Step 1

15 January 2008 41 Lecture 3: Image Processing

(courtesy of Bill Freeman)

slide-42
SLIDE 42

Experiment Step 1

15 January 2008 42 Lecture 3: Image Processing

(courtesy of Bill Freeman)

slide-43
SLIDE 43

Experiment Step 1

15 January 2008 43 Lecture 3: Image Processing

(courtesy of Bill Freeman)

slide-44
SLIDE 44

Experiment Step 2

15 January 2008 44 Lecture 3: Image Processing

(courtesy of Bill Freeman)

slide-45
SLIDE 45

Experiment Step 2

15 January 2008 45 Lecture 3: Image Processing

(courtesy of Bill Freeman)

slide-46
SLIDE 46

Experiment Step 2

15 January 2008 46 Lecture 3: Image Processing

(courtesy of Bill Freeman)

slide-47
SLIDE 47

Experiment Step 2

15 January 2008 47 Lecture 3: Image Processing

(courtesy of Bill Freeman)

slide-48
SLIDE 48

Conclusion from Experiment

Three primaries are enough for most people to reproduce arbitrary colors Why is this the case?

15 January 2008 48 Lecture 3: Image Processing

slide-49
SLIDE 49

Univariance Principle

15 January 2008 49 Lecture 3: Image Processing

) ( illuminant For , , ) ( ) ( λ λ λ λ ρ E S M L k d E L

k k

= = ∫

slide-50
SLIDE 50

Tristimulus Color Space

Three axes represent responses of the three types of receptors Horseshoe-shaped cone is the set of all human- perceptible colors

15 January 2008 50 Lecture 3: Image Processing

slide-51
SLIDE 51

Munsell Color System

Hue (Wavelength) Value (Luminosity) (Luminosity) Chroma (Saturation)

15 January 2008 51 Lecture 3: Image Processing

slide-52
SLIDE 52

Color Space

15 January 2008 52 Lecture 3: Image Processing

slide-53
SLIDE 53

How to Match a Color

Choose primaries A, B, C Given an energy distribution, which amounts

  • f primaries will match it?

F h l th i th di t ib ti For each wavelength in the distribution, determine how much of A, B, and C is needed to match light of that wavelength alone Add these together to produce a match

15 January 2008 53 Lecture 3: Image Processing

slide-54
SLIDE 54

Matching on a Color Circle

15 January 2008 54 Lecture 3: Image Processing

slide-55
SLIDE 55

RGB Color Matching

15 January 2008 55 Lecture 3: Image Processing

slide-56
SLIDE 56

Geometry of Color (CIE)

Perceptual color spaces are non-convex Three primaries can span the space, but weights may be negative. Curved outer edge consists

  • f single wavelength

primaries

15 January 2008 56 Lecture 3: Image Processing

slide-57
SLIDE 57

CIE Chromaticity Diagram

15 January 2008 57 Lecture 3: Image Processing

slide-58
SLIDE 58

RGB Color Space

15 January 2008 58 Lecture 3: Image Processing

slide-59
SLIDE 59

Constructing Colors

15 January 2008 59 Lecture 3: Image Processing

Color can be constructed in many ways

slide-60
SLIDE 60

Color Spaces

Use color matching functions to define a coordinate system for color Each color can be assigned a triple of coordinates with respect to some color space (e.g. RGB) Devices (monitors, printers, projectors) and computers can communicate colors precisely

15 January 2008 60 Lecture 3: Image Processing

slide-61
SLIDE 61

McAdam Ellipses

(10 times actual size) (Actual size)

15 January 2008 61 Lecture 3: Image Processing

(courtesy of D. Forsyth)

slide-62
SLIDE 62

Human Color Constancy

Distinguish between

Color constancy, which refers to hue and saturation Lightness constancy, which refers to gray-level.

Humans can perceive

Color a surface would have under white light (surface color) Color of the reflected light (limited ability to separate surface color from measured color) Color of illuminant (even more limited)

15 January 2008 62 Lecture 3: Image Processing

(courtesy of J.M. Rehg)

slide-63
SLIDE 63

Spatial Arrangement and Color Perception

15 January 2008 63 Lecture 3: Image Processing

slide-64
SLIDE 64

Spatial Arrangement and Color Perception

15 January 2008 64 Lecture 3: Image Processing

slide-65
SLIDE 65

Spatial Arrangement and Color Perception

15 January 2008 65 Lecture 3: Image Processing

slide-66
SLIDE 66

Spatial Arrangement and Color Perception

15 January 2008 66 Lecture 3: Image Processing

slide-67
SLIDE 67

Spatial Arrangement and Color Perception

15 January 2008 67 Lecture 3: Image Processing

slide-68
SLIDE 68

15 January 2008 68 Lecture 3: Image Processing

(courtesy of D. Forsyth)

slide-69
SLIDE 69

Land’s Mondrian Experiments

Squares of color with the same color radiance yield very different color perceptions

Photometer: 1.0, 0.3, 0.3 Photometer: 1.0, 0.3, 0.3

15 January 2008 69 Lecture 3: Image Processing

Audience: “Red” Audience: “Blue” White light Colored light (courtesy of J.M. Rehg)

slide-70
SLIDE 70

Lightness Constancy Algorithm

The goal is to determine what the surfaces in the image would look like under white light. Compares the brightness of patches across their common boundaries and computes relative brightness Establish an absolute reference for lightness (e.g. brightest point is “white”)

15 January 2008 70 Lecture 3: Image Processing

slide-71
SLIDE 71

Lightness Constancy Example

15 January 2008 71 Lecture 3: Image Processing

(courtesy of John McCann)

slide-72
SLIDE 72

Finite Dimensional Linear Models

E λ

( )=

εiψi λ

( )

i=1 m

( ) ( ) ( )

∫ ∑ ∑

⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ ⎟ ⎠ ⎞ ⎜ ⎝ ⎛ =

n j j m i i k k

d r L λ λ ϕ λ ψ ε λ σ

15 January 2008 72 Lecture 3: Image Processing

ρ λ

( )=

rjϕ j λ

( )

j=1 n

( ) ( ) ( )

∑ ∑ ∫ ∫

= = = = = =

= = ⎟ ⎠ ⎜ ⎝ ⎠ ⎝

n m j i ijk j i n m j i j i k j i j i

g r d r

, 1 , 1 , 1 , 1 1 1

ε λ λ ϕ λ ψ λ σ ε

slide-73
SLIDE 73

From Images to Objects and Regions

Attributes of regions

Bounding edges Texture

The need to compute and reason about spatial aggregations of pixels leads us to filtering Key problem is segmentation

15 January 2008 73 Lecture 3: Image Processing

slide-74
SLIDE 74

Features and Filters: Questions

What is a feature? What is an image filter? What is it good for? f d How can we find corners? How can we find edges?

15 January 2008 74 Lecture 3: Image Processing

slide-75
SLIDE 75

What is a Feature?

In computer vision, a feature is a local, meaningful, detectable part of an image

15 January 2008 75 Lecture 3: Image Processing

slide-76
SLIDE 76

Why Use Features?

High information content Invariant to changing viewpoint or changing illumination R d t ti l b d Reduces computational burden

15 January 2008 76 Lecture 3: Image Processing

(courtesy of Sebastian Thrun)

slide-77
SLIDE 77

Image 1

One Type of Computer Vision

Computer Vision Algorithm Feature 1 Feature 2 : Feature N Feature 1 Feature 2 : Feature N Image 2

15 January 2008 77 Lecture 3: Image Processing

(courtesy of Sebastian Thrun)

slide-78
SLIDE 78

Where Features Are Used

Calibration Image Segmentation Correspondence in multiple images (stereo, t t f ti ) structure from motion) Object detection, classification

15 January 2008 78 Lecture 3: Image Processing

(courtesy of Sebastian Thrun)

slide-79
SLIDE 79

What Makes a Good Feature?

Invariance

View point (scale, orientation, translation) Lighting condition Object deformations Partial occlusion

Other Characteristics

Uniqueness Sufficiently many Tuned to the task

15 January 2008 79 Lecture 3: Image Processing

(courtesy of Sebastian Thrun)

slide-80
SLIDE 80

What is Image Filtering?

Modify the pixels in an image based on some function of a local neighborhood of the pixels

15 January 2008 80 Lecture 3: Image Processing

10 5 3 4 5 1 1 1 7 7

slide-81
SLIDE 81

Linear Filtering

Linear case is simplest and most useful

Replace each pixel with a linear combination of its neighbors.

The specification of the linear combination is called the convolution kernel. called the convolution kernel.

15 January 2008 81 Lecture 3: Image Processing

10 5 3 4 5 1 1 1 7 7

*

0.5 1.0 0.5

=

kernel

slide-82
SLIDE 82

I(.) I(.) I(.) I(.) I(.) I(.) I(.) I(.) I(.)

15 January 2008 82 Lecture 3: Image Processing

g22 + g22 I(i,j) f (i,j) = g12 + g12 I(i-1,j) g13 + g13 I(i-1,j+1) + g21 g21 I(i,j-1) g23 + g23 I(i,j+1) + g31 g31 I(i+1,j-1) g32 + g32 I(i+1,j) g33 + g33 I(i+1,j+1) g11 g11 I(i-1,j-1)

slide-83
SLIDE 83

Step 1

2 2 3 2 5 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 2 4 1 1 1 1 1

  • 1
  • 1

1 2

  • 1

1 1 1 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 5 1

  • 2
  • 1

2 4

  • 1

(courtesy of Christopher Rasmussen)

slide-84
SLIDE 84

Step 2

2 2 3 2 4 5 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 2 4 2 1 1 1 1

  • 1
  • 1

1 2

  • 1

1 1 1 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 4 5 3

  • 1
  • 2

2 4

  • 2

(courtesy of Christopher Rasmussen)

slide-85
SLIDE 85

Step 3

2 2 3 2 4 4 5 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 3 4 2 1 1 1 1

  • 1
  • 1

1 2

  • 1

1 1 1 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 4 4 5 3

  • 3
  • 1

3 4

  • 2

(courtesy of Christopher Rasmussen)

slide-86
SLIDE 86

Step 4

2 2 3 2 4 4 2 5 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 1 6 2 1 1 1 1

  • 1
  • 1

1 2

  • 1

1 1 1 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 4 4

  • 2

5 1

  • 3
  • 3

1 6

  • 2

(courtesy of Christopher Rasmussen)

slide-87
SLIDE 87

Step 5

2 2 3 2 4 4 2 5 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 2 2 1 1

  • 1
  • 1

1 2

  • 1

1 1 1 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 4 4 9

  • 2

5 2

  • 2
  • 1

1 4

  • 1

2 2 1

(courtesy of Christopher Rasmussen)

slide-88
SLIDE 88

Step 6

2 2 3 2 4 4 2 5 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 2 2 2 1

  • 1
  • 1

1 2

  • 1

1 1 1 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 6 4 4 9

  • 2

5 1

  • 2
  • 2

3 2

  • 2

2 2 2

slide-89
SLIDE 89

Final Result

2 2 2 3 2 1 3 3 6 4 14 4 5 9

  • 2

5 1

  • 1
  • 1

1 2

  • 1

1 1 1 2 1 3 3 2 2 1 2 1 3 2 2 12 7 6 8 6 14 5 9 5 9 5 11

I’ I

Why is I’ large in some places and small in others?

(courtesy of Christopher Rasmussen)

slide-90
SLIDE 90

Filtering Example

15 January 2008 90 Lecture 3: Image Processing

slide-91
SLIDE 91

Filtering Example

15 January 2008 91 Lecture 3: Image Processing

slide-92
SLIDE 92

Filtering Example

15 January 2008 92 Lecture 3: Image Processing

slide-93
SLIDE 93

Problem: Image Noise

15 January 2008 93 Lecture 3: Image Processing

(courtesy of Forsyth & Ponce)

slide-94
SLIDE 94

Solution: Smoothing Filter

If object reflectance changes slowly and noise at each pixel is independent, then we want to replace each pixel with something like the average of neighbors

Disadvantage: Sharp (high-frequency) features lost

15 January 2008 94 Lecture 3: Image Processing

7 x 7 averaging neighborhood Original image

slide-95
SLIDE 95

Smoothing Filter: Details

Filter types

Mean filter (box) Median (nonlinear) Gaussian 1 1 1 1 1 1 Gaussian

Can specify linear

  • peration by shifting

kernel over image and taking product

15 January 2008 95 Lecture 3: Image Processing

1 1 1 1 1 1

3 x 3 box filter kernel

slide-96
SLIDE 96

Gaussian Kernel

  • Idea: Weight contributions of neighboring pixels by nearness

0.003 0.013 0.022 0.013 0.003 0.013 0.059 0.097 0.059 0.013 0.022 0.097 0.159 0.097 0.022 0.013 0.059 0.097 0.059 0.013

15 January 2008 96 Lecture 3: Image Processing

  • Smooth roll-off reduces “ringing” seen in box filter

0.003 0.013 0.022 0.013 0.003

5 x 5, σ = 1

slide-97
SLIDE 97

Gaussian Smoothing Example

15 January 2008 97 Lecture 3: Image Processing

σ = 1 σ = 3 7 x 7 kernel Original image Box filter

slide-98
SLIDE 98

Gaussian Smoothing

Averaging Gaussian

15 January 2008 98 Lecture 3: Image Processing

(courtesy of Marc Pollefeys)

slide-99
SLIDE 99

“Box” vs. “Cone” Filters

15 January 2008 99 Lecture 3: Image Processing

(courtesy Andries van Dam)

slide-100
SLIDE 100

Smoothing Reduces Noise

15 January 2008 100 Lecture 3: Image Processing

(courtesy of Marc Pollefeys)

slide-101
SLIDE 101

What causes an edge?

Depth discontinuity Change in surface

  • rientation

Reflectance discontinuity (change in surface properties) Illumination discontinuity (light/shadow)

15 January 2008 101 Lecture 3: Image Processing

(courtesy of Christopher Rasmussen)

slide-102
SLIDE 102

How Can We Find Edges?

15 January 2008 102 Lecture 3: Image Processing

slide-103
SLIDE 103

Spatial Structure of Edges

Edges exist at different scales from fine (whiskers) to coarse (stripes) Solution: Gaussian smoothing

15 January 2008 103 Lecture 3: Image Processing

slide-104
SLIDE 104

Blurring Example

15 January 2008 104 Lecture 3: Image Processing

slide-105
SLIDE 105

Scale

Increasing smoothing:

Eliminates noise edges Makes edges smoother and thicker Removes fine detail

15 January 2008 105 Lecture 3: Image Processing

slide-106
SLIDE 106

Effect of Smoothing Radius

15 January 2008 106 Lecture 3: Image Processing

1 pixel 3 pixels 7 pixels

slide-107
SLIDE 107

The Edge Normal

15 January 2008 107 Lecture 3: Image Processing

2 2

dy dx S + = dx dy arctan = α

slide-108
SLIDE 108

Sobel Operator

  • 1 -2 -1

0 0 0 1 2 1

  • 1 0

1

  • 2 0

2

  • 1 0

1 S1= S2 =

15 January 2008 108 Lecture 3: Image Processing

Edge Magnitude = Edge Direction = S1 + S1

2 2

tan-1 S1 S2

slide-109
SLIDE 109

The Sobel Kernel, Explained

1 2 1

  • 1

1

  • 2

2

  • 1

1

1

Sobel kernel is separable!

= 1/4 * [-1 0 -1] 1 2 1

15 January 2008 109 Lecture 3: Image Processing

  • 1
  • 2
  • 1

= 1/4 * [ 1 2 1]

  • 1

1

  • 1
  • 2

1 1 2

Averaging done parallel to edge

slide-110
SLIDE 110

Combining Kernels

) ( ) ( h g I h g I ⊗ ⊗ = ⊗ ⊗

[ ]

1 1 ⊗

[ ]

0.0030 0.0133 0.0219 0.0133 0.0030 0.0133 0.0596 0.0983 0.0596 0.0133

15 January 2008 110 Lecture 3: Image Processing

[ ]

1 1 − ⊗

[ ]

0.0219 0.0983 0.1621 0.0983 0.0219 0.0133 0.0596 0.0983 0.0596 0.0133 0.0030 0.0133 0.0219 0.0133 0.0030

slide-111
SLIDE 111

Robinson Compass Masks

  • 1 0 1
  • 2 0 2
  • 1 0 1

0 1 2

  • 1 0

1

  • 2 -1

1 2 1 0 0 0

  • 1 -2 -1

2 1 0 1 0

  • 1

0 -1

  • 2

15 January 2008 111 Lecture 3: Image Processing

1 0 -1 2 0 -2 1 1

  • 1

0 -1 -2

  • 1 0
  • 1

2 1

  • 1
  • 2 -1

0 0 0 1 2 1

  • 2 -1 0
  • 1 0

1 0 1 2

slide-112
SLIDE 112

Robert’s Cross Operator

1 0 0 -1 0 1

  • 1 0

+

15 January 2008 112 Lecture 3: Image Processing

  • r

| I(x, y) - I(x+1, y+1) | + | I(x, y+1) - I(x+1, y) | [ I(x, y) - I(x+1, y+1) ]2 + [ I(x, y+1) - I(x+1, y) ]2 S = S =

slide-113
SLIDE 113

Claim Your Own Kernel!

1 1 1 1 1

  • 1
  • 1

Prewitt 1

  • 2
  • 1
  • 3

5 5 5

  • 3
  • 3
  • 3
  • 3

Kirsch

  • 1
  • 1

1 1 Frei & Chen

2 2

15 January 2008 113 Lecture 3: Image Processing

(courtesy of Sebastian Thrun)

1 1 1

  • 1
  • 1
  • 1

Prewitt 2 1 2 1

  • 1
  • 2
  • 1

Sobel

slide-114
SLIDE 114

What’s Not a Convolution?

Nonlinear systems

For example, radial distortion of a fish-eye lens

15 January 2008 114 Lecture 3: Image Processing

f

(courtesy of M. Fiala)

slide-115
SLIDE 115

John Canny’s Edge Detector

John Canny, “Finding Edges and Lines in Images,” Master’s Thesis, MIT, June 1983. Developed a practical edge detection algorithm with three properties algorithm with three properties

Gaussian smoothing Non-maximum suppression (remove edges

  • rthogonal to a maxima)

Hysteresis thresholding – Improved recovery of long image contours

15 January 2008 115 Lecture 3: Image Processing

slide-116
SLIDE 116

Sobel Example

15 January 2008 116 Lecture 3: Image Processing

(courtesy of Sebastian Thrun)

slide-117
SLIDE 117

Canny Example

15 January 2008 117 Lecture 3: Image Processing

(courtesy of Sebastian Thrun)

slide-118
SLIDE 118

Comparison

15 January 2008 118 Lecture 3: Image Processing

Canny Sobel (courtesy of Sebastian Thrun)

slide-119
SLIDE 119

Canny Edge Detection

Steps:

  • 1. Apply derivative of Gaussian
  • 2. Non-maximum suppression
  • Thin multi-pixel wide “ridges” down to single pixel

Thin multi pixel wide ridges down to single pixel width

  • 3. Linking and thresholding
  • Low, high edge-strength thresholds
  • Accept all edges over low threshold that are

connected to edge over high threshold

15 January 2008 119 Lecture 3: Image Processing

slide-120
SLIDE 120

Non-Maximum Suppression

Select the single maximum point across the width of an edge.

15 January 2008 120 Lecture 3: Image Processing

slide-121
SLIDE 121

Linking to the Next Edge Point

Assume the marked point q is an edge point. Take the normal to Take the normal to the gradient at that point and use this to predict continuation points (either r or p).

15 January 2008 121 Lecture 3: Image Processing

slide-122
SLIDE 122

Edge Hysteresis

Hysteresis: A lag or momentum factor Idea: Maintain two thresholds: kHIGH and kLOW U k t fi d t d t t t d Use kHIGH to find strong edges to start edge chain Use kLOW to find weak edges which continue edge chain Typical ratio of thresholds is roughly kHIGH / kLOW = 2

15 January 2008 122 Lecture 3: Image Processing

slide-123
SLIDE 123

Canny Edge Detection (Example)

gap is gone

Original image Strong + connected weak edges

15 January 2008 123 Lecture 3: Image Processing 123

Strong edges

  • nly

Weak edges

(courtesy of G. Loy)

slide-124
SLIDE 124

Canny Edge Detection (Example)

Using default thresholds in Matlab

15 January 2008 124 Lecture 3: Image Processing

slide-125
SLIDE 125

Choosing Parameters

15 January 2008 125 Lecture 3: Image Processing

slide-126
SLIDE 126

Choosing Parameters

Fine scale, High threshold

15 January 2008 126 Lecture 3: Image Processing

High threshold

slide-127
SLIDE 127

Choosing Parameters

Coarse scale, High threshold

15 January 2008 127 Lecture 3: Image Processing

High threshold

slide-128
SLIDE 128

Choosing Parameters

Coarse scale, Low threshold

15 January 2008 128 Lecture 3: Image Processing

Low threshold

slide-129
SLIDE 129

Image Arithmetic

Just like matrices, we can do pixelwise arithmetic on images Some useful operations

Differencing Measure of similarity Differencing: Measure of similarity Averaging: Blend separate images or smooth a single one over time Thresholding: Apply function to each pixel, test value

15 January 2008 129 Lecture 3: Image Processing

slide-130
SLIDE 130

Image Type Conversion

Many processing functions work on just one channel, so the options are:

Run on each channel independently Convert from color → grayscale weighting each channel b t l i t by perceptual importance

15 January 2008 130 Lecture 3: Image Processing

slide-131
SLIDE 131

Thresholding

Grayscale → Binary: Choose threshold based on histogram of image intensities

15 January 2008 131 Lecture 3: Image Processing

slide-132
SLIDE 132

Image Comparison: Histograms

15 January 2008 132 Lecture 3: Image Processing

slide-133
SLIDE 133

Color Similarity

One measure is “Chrominance Distance”: distance from color to a reference color

15 January 2008 133 Lecture 3: Image Processing

slide-134
SLIDE 134

Image Comparison

One approach to template matching is a sum of squared differences:

15 January 2008 134 Lecture 3: Image Processing

slide-135
SLIDE 135

Correlation for Template Matching

Note that SSD formula can be written: h h l b h h 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

15 January 2008 135 Lecture 3: Image Processing

slide-136
SLIDE 136

Normalized Cross-Correlation

Shift template image over search image, measuring normalized correlation at each point Local maxima indicate template matches

15 January 2008 136 Lecture 3: Image Processing

slide-137
SLIDE 137

Template Matching Example

15 January 2008 137 Lecture 3: Image Processing

(courtesy of Sebastian Thrun)

slide-138
SLIDE 138

Statistical Image Comparison: Color Histograms

Steps

Histogram RGB/HSI triplets over two images to be compared Normalize each histogram by respective total number

  • f pixels to get frequencies

Similarity is Euclidean distance between color frequency vectors

Insensitive to geometric changes, including different-sized images

15 January 2008 138 Lecture 3: Image Processing

slide-139
SLIDE 139

Connected Components

After thresholding, method to identify groups or clusters of like pixels Uniquely label each n-connected region in binary image binary image 4- and 8-connectedness

15 January 2008 139 Lecture 3: Image Processing

slide-140
SLIDE 140

Connected Components Example

15 January 2008 140 Lecture 3: Image Processing

slide-141
SLIDE 141

Binary Operations

Dilation, erosion

Dilation: All 0’s next to a 1 → 1 (Enlarge foreground) Erosion: All 1’s next to a 0 → 0 (Enlarge background)

15 January 2008 141 Lecture 3: Image Processing

slide-142
SLIDE 142

Image Moments: Region Statistics

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

15 January 2008 142 Lecture 3: Image Processing

slide-143
SLIDE 143

Other Effects

Art Effects

Posterizing Faked “Aging” “Impressionist” pi el remapping pixel remapping

Technical Effects

Color remapping Grayscale conversion Contrast balancing

15 January 2008 143 Lecture 3: Image Processing

(courtesy Andries van Dam)

slide-144
SLIDE 144

Finding Corners

Edge detectors perform poorly at corners. Corners provide repeatable points for matching, so are worth detecting. P bl Problem:

Exactly at a corner, gradient is ill-defined. However, in the region around a corner, gradient has two or more different values.

15 January 2008 144 Lecture 3: Image Processing

slide-145
SLIDE 145

Harris Corner Detector

⎥ ⎤ ⎢ ⎡

∑ ∑

2 y x x

I I I C

15 January 2008 145 Lecture 3: Image Processing

⎥ ⎥ ⎦ ⎢ ⎢ ⎣ =

∑ ∑ ∑ ∑

2 y y x y x x

I I I C

slide-146
SLIDE 146

Simple Case

First, consider case where:

⎥ ⎦ ⎤ ⎢ ⎣ ⎡ = ⎥ ⎥ ⎦ ⎤ ⎢ ⎢ ⎣ ⎡ =

∑ ∑ ∑ ∑

2 1 2 2

λ λ

y y x y x x

I I I I I I C

This means dominant gradient directions align with x or y axis If either λ is close to 0, then this is not a corner, so look for locations where both are large.

15 January 2008 146 Lecture 3: Image Processing

⎦ ⎣ ⎥ ⎦ ⎢ ⎣

∑ ∑

y y

slide-147
SLIDE 147

General Case

It can be shown that since C is rotationally symmetric:

⎤ ⎡

1 1

λ

So every case is like a rotated version of the

  • ne on last slide.

15 January 2008 147 Lecture 3: Image Processing

R R C ⎥ ⎦ ⎤ ⎢ ⎣ ⎡ =

− 2 1 1

λ λ

slide-148
SLIDE 148

So, To Detect Corners

Filter image with Gaussian to reduce noise Compute magnitude of the x and y gradients at each pixel Construct C in a window around each pixel p (Harris uses a Gaussian window – just blur) Solve for product of lS (determinant of C) If lS are both big (product reaches local maximum and is above threshold), we have a corner (Harris also checks that ratio of lS is not too high)

15 January 2008 148 Lecture 3: Image Processing

slide-149
SLIDE 149

Gradient Orientation

Closeup

15 January 2008 149 Lecture 3: Image Processing

slide-150
SLIDE 150

Corner Detection

Corners are detected where the product of the p ellipse axis lengths reaches a local maximum.

15 January 2008 150 Lecture 3: Image Processing

slide-151
SLIDE 151

Harris Corners

15 January 2008 151 Lecture 3: Image Processing

(courtesy of Sebastian Thrun)

slide-152
SLIDE 152

Example (σ=0.1)

15 January 2008 152 Lecture 3: Image Processing

(courtesy of Sebastian Thrun)

slide-153
SLIDE 153

Example (σ=0.01)

15 January 2008 153 Lecture 3: Image Processing

(courtesy of Sebastian Thrun)

slide-154
SLIDE 154

Example (σ=0.01)

15 January 2008 154 Lecture 3: Image Processing

(courtesy of Sebastian Thrun)

slide-155
SLIDE 155

Features?

15 January 2008 155 Lecture 3: Image Processing

Global, not Local

slide-156
SLIDE 156

Vanishing Points

15 January 2008 156 Lecture 3: Image Processing

slide-157
SLIDE 157

Vanishing Points

15 January 2008 157 Lecture 3: Image Processing

  • A. Canaletto [1740], Arrival of the French Ambassador in Venice
slide-158
SLIDE 158

From Edges to Lines

15 January 2008 158 Lecture 3: Image Processing

slide-159
SLIDE 159

Hough Transform

y mx b + − = y x m b + − = ' ' y x m b + ' ' ' '

15 January 2008 159 Lecture 3: Image Processing

y x m b + − = ' ' ' '

slide-160
SLIDE 160

Hough Transform: Quantization

b

15 January 2008 160 Lecture 3: Image Processing

m

(courtesy of Sebastian Thrun)

slide-161
SLIDE 161

Hough Transform: Algorithm

For each image point, determine

most likely line parameters b,m (direction of gradient) strength (magnitude of gradient)

Increment parameter counter by strength value Cluster in parameter space, pick local maxima

15 January 2008 161 Lecture 3: Image Processing

slide-162
SLIDE 162

Hough Transform: Results

15 January 2008 162 Lecture 3: Image Processing

slide-163
SLIDE 163

Hough Transform?

15 January 2008 163 Lecture 3: Image Processing

slide-164
SLIDE 164

Summary

Many kinds of mathematical operations can be performed on images to extract basic information about shapes and features Image processing does not itself lead to Image processing does not itself lead to image understanding… But it’s often a good start

15 January 2008 164 Lecture 3: Image Processing

slide-165
SLIDE 165

Reading for Next Lecture

Introduction to the MATLAB Image Processing Toolbox Assignment #1 Question #4: MATLAB introduction introduction

15 January 2008 165 Lecture 3: Image Processing