stanford hci group / cs377s
Designing Applications that See Lecture 3: Image Processing
Designing Applications that See http://cs377s.stanford.edu
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,
stanford hci group / cs377s
Designing Applications that See http://cs377s.stanford.edu
15 January 2008 2 Lecture 3: Image Processing
15 January 2008 3 Lecture 3: Image Processing
15 January 2008 4 Lecture 3: Image Processing
Which of these two images contains a red circle?
15 January 2008 5 Lecture 3: Image Processing
Which of these two images contains a red circle?
15 January 2008 6 Lecture 3: Image Processing
Which of these two images contains a red circle?
15 January 2008 7 Lecture 3: Image Processing
15 January 2008 8 Lecture 3: Image Processing
15 January 2008 9 Lecture 3: Image Processing
15 January 2008 10 Lecture 3: Image Processing
15 January 2008 11 Lecture 3: Image Processing
(courtesy of Maria Petrou)
Position Intensity Time
15 January 2008 12 Lecture 3: Image Processing
With samples at regular points (almost always a rectilinear grid) Whose values represent gray levels, colors, or iti
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
Red Channel of Image, 1 sample per pixel 3 samples per pixel
15 January 2008 14 Lecture 3: Image Processing
Blue Channel of Image, 1 sample per pixel
(courtesy Andries van Dam)
15 January 2008 15 Lecture 3: Image Processing
(courtesy of Gonzalez and Woods)
15 January 2008 16 Lecture 3: Image Processing
(courtesy of Gonzalez and Woods)
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
15 January 2008 18 Lecture 3: Image Processing
(courtesy of Gonzalez and Woods)
15 January 2008 19 Lecture 3: Image Processing
15 January 2008 20 Lecture 3: Image Processing
(courtesy of Tobey Thorn)
Segmentation (identifying objects in an image) Classification (assigning labels to individual Classification (assigning labels to individual
Interpretation (extracting meaning from the image as a whole)
15 January 2008 21 Lecture 3: Image Processing
15 January 2008 22 Lecture 3: Image Processing
(courtesy of B. Jähne)
15 January 2008 23 Lecture 3: Image Processing
15 January 2008 24 Lecture 3: Image Processing
15 January 2008 25 Lecture 3: Image Processing
(courtesy of J.M. Rehg)
15 January 2008 26 Lecture 3: Image Processing
(courtesy R. Beau Lotto)
15 January 2008 27 Lecture 3: Image Processing
(courtesy R. Beau Lotto)
Distinguish food from nonfood Help identify predators and prey Check health of others Check health of others
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)
15 January 2008 29 Lecture 3: Image Processing
Ishihara Test for Color Blindness
15 January 2008 30 Lecture 3: Image Processing
Cones Rods
15 January 2008 31 Lecture 3: Image Processing
15 January 2008 32 Lecture 3: Image Processing
Reflectance Transmittance (courtesy of Brian Wandell)
15 January 2008 33 Lecture 3: Image Processing
15 January 2008 34 Lecture 3: Image Processing
15 January 2008 35 Lecture 3: Image Processing
15 January 2008 36 Lecture 3: Image Processing
15 January 2008 37 Lecture 3: Image Processing
15 January 2008 38 Lecture 3: Image Processing
15 January 2008 39 Lecture 3: Image Processing
15 January 2008 40 Lecture 3: Image Processing
15 January 2008 41 Lecture 3: Image Processing
(courtesy of Bill Freeman)
15 January 2008 42 Lecture 3: Image Processing
(courtesy of Bill Freeman)
15 January 2008 43 Lecture 3: Image Processing
(courtesy of Bill Freeman)
15 January 2008 44 Lecture 3: Image Processing
(courtesy of Bill Freeman)
15 January 2008 45 Lecture 3: Image Processing
(courtesy of Bill Freeman)
15 January 2008 46 Lecture 3: Image Processing
(courtesy of Bill Freeman)
15 January 2008 47 Lecture 3: Image Processing
(courtesy of Bill Freeman)
15 January 2008 48 Lecture 3: Image Processing
15 January 2008 49 Lecture 3: Image Processing
) ( illuminant For , , ) ( ) ( λ λ λ λ ρ E S M L k d E L
k k
= = ∫
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
15 January 2008 51 Lecture 3: Image Processing
15 January 2008 52 Lecture 3: Image Processing
15 January 2008 53 Lecture 3: Image Processing
15 January 2008 54 Lecture 3: Image Processing
15 January 2008 55 Lecture 3: Image Processing
Perceptual color spaces are non-convex Three primaries can span the space, but weights may be negative. Curved outer edge consists
primaries
15 January 2008 56 Lecture 3: Image Processing
15 January 2008 57 Lecture 3: Image Processing
15 January 2008 58 Lecture 3: Image Processing
15 January 2008 59 Lecture 3: Image Processing
Color can be constructed in many ways
15 January 2008 60 Lecture 3: Image Processing
(10 times actual size) (Actual size)
15 January 2008 61 Lecture 3: Image Processing
(courtesy of D. Forsyth)
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)
15 January 2008 63 Lecture 3: Image Processing
15 January 2008 64 Lecture 3: Image Processing
15 January 2008 65 Lecture 3: Image Processing
15 January 2008 66 Lecture 3: Image Processing
15 January 2008 67 Lecture 3: Image Processing
15 January 2008 68 Lecture 3: Image Processing
(courtesy of D. Forsyth)
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)
15 January 2008 70 Lecture 3: Image Processing
15 January 2008 71 Lecture 3: Image Processing
(courtesy of John McCann)
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
ε λ λ ϕ λ ψ λ σ ε
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
15 January 2008 74 Lecture 3: Image Processing
15 January 2008 75 Lecture 3: Image Processing
15 January 2008 76 Lecture 3: Image Processing
(courtesy of Sebastian Thrun)
Image 1
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)
15 January 2008 78 Lecture 3: Image Processing
(courtesy of Sebastian Thrun)
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)
15 January 2008 80 Lecture 3: Image Processing
10 5 3 4 5 1 1 1 7 7
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
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)
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 2
1 1 1 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 5 1
2 4
(courtesy of Christopher Rasmussen)
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 2
1 1 1 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 4 5 3
2 4
(courtesy of Christopher Rasmussen)
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 2
1 1 1 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 4 4 5 3
3 4
(courtesy of Christopher Rasmussen)
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 2
1 1 1 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 4 4
5 1
1 6
(courtesy of Christopher Rasmussen)
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 2
1 1 1 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 4 4 9
5 2
1 4
2 2 1
(courtesy of Christopher Rasmussen)
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 2
1 1 1 3 2 1 2 2 1 3 2 3 2 2 1 2 2 3 2 6 4 4 9
5 1
3 2
2 2 2
2 2 2 3 2 1 3 3 6 4 14 4 5 9
5 1
1 2
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
Why is I’ large in some places and small in others?
(courtesy of Christopher Rasmussen)
15 January 2008 90 Lecture 3: Image Processing
15 January 2008 91 Lecture 3: Image Processing
15 January 2008 92 Lecture 3: Image Processing
15 January 2008 93 Lecture 3: Image Processing
(courtesy of Forsyth & Ponce)
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
Mean filter (box) Median (nonlinear) Gaussian 1 1 1 1 1 1 Gaussian
15 January 2008 95 Lecture 3: Image Processing
1 1 1 1 1 1
3 x 3 box filter kernel
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
0.003 0.013 0.022 0.013 0.003
5 x 5, σ = 1
15 January 2008 97 Lecture 3: Image Processing
σ = 1 σ = 3 7 x 7 kernel Original image Box filter
Averaging Gaussian
15 January 2008 98 Lecture 3: Image Processing
(courtesy of Marc Pollefeys)
15 January 2008 99 Lecture 3: Image Processing
(courtesy Andries van Dam)
15 January 2008 100 Lecture 3: Image Processing
(courtesy of Marc Pollefeys)
15 January 2008 101 Lecture 3: Image Processing
(courtesy of Christopher Rasmussen)
15 January 2008 102 Lecture 3: Image Processing
15 January 2008 103 Lecture 3: Image Processing
15 January 2008 104 Lecture 3: Image Processing
Eliminates noise edges Makes edges smoother and thicker Removes fine detail
15 January 2008 105 Lecture 3: Image Processing
15 January 2008 106 Lecture 3: Image Processing
1 pixel 3 pixels 7 pixels
15 January 2008 107 Lecture 3: Image Processing
2 2
dy dx S + = dx dy arctan = α
0 0 0 1 2 1
1
2
1 S1= S2 =
15 January 2008 108 Lecture 3: Image Processing
Edge Magnitude = Edge Direction = S1 + S1
2 2
tan-1 S1 S2
1 2 1
1
2
1
1
Sobel kernel is separable!
= 1/4 * [-1 0 -1] 1 2 1
⊗
15 January 2008 109 Lecture 3: Image Processing
= 1/4 * [ 1 2 1]
⊗
1
1 1 2
Averaging done parallel to edge
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
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
0 1 2
1
1 2 1 0 0 0
2 1 0 1 0
0 -1
15 January 2008 111 Lecture 3: Image Processing
1 0 -1 2 0 -2 1 1
0 -1 -2
2 1
0 0 0 1 2 1
1 0 1 2
1 0 0 -1 0 1
+
15 January 2008 112 Lecture 3: Image Processing
| 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 =
1 1 1 1 1
Prewitt 1
5 5 5
Kirsch
1 1 Frei & Chen
2 2
15 January 2008 113 Lecture 3: Image Processing
(courtesy of Sebastian Thrun)
1 1 1
Prewitt 2 1 2 1
Sobel
For example, radial distortion of a fish-eye lens
15 January 2008 114 Lecture 3: Image Processing
(courtesy of M. Fiala)
Gaussian smoothing Non-maximum suppression (remove edges
Hysteresis thresholding – Improved recovery of long image contours
15 January 2008 115 Lecture 3: Image Processing
15 January 2008 116 Lecture 3: Image Processing
(courtesy of Sebastian Thrun)
15 January 2008 117 Lecture 3: Image Processing
(courtesy of Sebastian Thrun)
15 January 2008 118 Lecture 3: Image Processing
Canny Sobel (courtesy of Sebastian Thrun)
Thin multi pixel wide ridges down to single pixel width
connected to edge over high threshold
15 January 2008 119 Lecture 3: Image Processing
15 January 2008 120 Lecture 3: Image Processing
15 January 2008 121 Lecture 3: Image Processing
15 January 2008 122 Lecture 3: Image Processing
gap is gone
Original image Strong + connected weak edges
15 January 2008 123 Lecture 3: Image Processing 123
Strong edges
Weak edges
(courtesy of G. Loy)
Using default thresholds in Matlab
15 January 2008 124 Lecture 3: Image Processing
15 January 2008 125 Lecture 3: Image Processing
Fine scale, High threshold
15 January 2008 126 Lecture 3: Image Processing
High threshold
Coarse scale, High threshold
15 January 2008 127 Lecture 3: Image Processing
High threshold
Coarse scale, Low threshold
15 January 2008 128 Lecture 3: Image Processing
Low threshold
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
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
15 January 2008 131 Lecture 3: Image Processing
15 January 2008 132 Lecture 3: Image Processing
15 January 2008 133 Lecture 3: Image Processing
15 January 2008 134 Lecture 3: Image Processing
15 January 2008 135 Lecture 3: Image Processing
15 January 2008 136 Lecture 3: Image Processing
15 January 2008 137 Lecture 3: Image Processing
(courtesy of Sebastian Thrun)
Steps
Histogram RGB/HSI triplets over two images to be compared Normalize each histogram by respective total number
Similarity is Euclidean distance between color frequency vectors
Insensitive to geometric changes, including different-sized images
15 January 2008 138 Lecture 3: Image Processing
15 January 2008 139 Lecture 3: Image Processing
15 January 2008 140 Lecture 3: Image Processing
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
15 January 2008 142 Lecture 3: Image Processing
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)
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
2 y x x
15 January 2008 145 Lecture 3: Image Processing
2 y y x y x x
2 1 2 2
y y x y x x
15 January 2008 146 Lecture 3: Image Processing
y y
1 1
15 January 2008 147 Lecture 3: Image Processing
− 2 1 1
15 January 2008 148 Lecture 3: Image Processing
Closeup
15 January 2008 149 Lecture 3: Image Processing
15 January 2008 150 Lecture 3: Image Processing
15 January 2008 151 Lecture 3: Image Processing
(courtesy of Sebastian Thrun)
15 January 2008 152 Lecture 3: Image Processing
(courtesy of Sebastian Thrun)
15 January 2008 153 Lecture 3: Image Processing
(courtesy of Sebastian Thrun)
15 January 2008 154 Lecture 3: Image Processing
(courtesy of Sebastian Thrun)
15 January 2008 155 Lecture 3: Image Processing
Global, not Local
15 January 2008 156 Lecture 3: Image Processing
15 January 2008 157 Lecture 3: Image Processing
15 January 2008 158 Lecture 3: Image Processing
15 January 2008 159 Lecture 3: Image Processing
b
15 January 2008 160 Lecture 3: Image Processing
m
(courtesy of Sebastian Thrun)
most likely line parameters b,m (direction of gradient) strength (magnitude of gradient)
15 January 2008 161 Lecture 3: Image Processing
15 January 2008 162 Lecture 3: Image Processing
15 January 2008 163 Lecture 3: Image Processing
15 January 2008 164 Lecture 3: Image Processing
15 January 2008 165 Lecture 3: Image Processing