February 13, 2014 Sam Siewert
Computer and Machine Vision
Lecture Week 5 Part-1
Outline of Week 5 Background on 2D and 3D Geometric Transformations – Chapter 2 of CV Fundamentals of 2D Image Transformations and Convolutions (CV Chapters 3 & 4) Introduction to More Advanced 2D Transformations – Bottom Up C without OpenCV Simple 2D Center-of-Mass Tracking Introduction to 2D Pattern Matching – Next Time
Sam Siewert 2
Backgrounder
2D and 3D Geometric Math Overview (Chapter 2 – CV)
Sam Siewert
3
Understand Geometric Transform Types
Figure 2.4 – 2D Planar Transformations
Sam Siewert 4
Primitive 2D Transformation Properties
Sam Siewert 5
Primitive 3D Transformation Properties
Sam Siewert 6
Translation and Rotation Studied in Physics (and Linear Systems) Vectors, Rotation Matrices – 2D & 3D Simple C++ Starter – vectmat.zip Ground-up OpenCV Tutorial - http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/ https://www.khanacademy.org/math/linear-algebra Sam Siewert 7
OpenCV Linear Algebra
Sam Siewert 8
http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/
OpenCV Linear Algebra
Sam Siewert 9
http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/
Based on Studies of Perspective by Artists and Physics of Light
Sam Siewert 10 http://en.wikipedia.org/wiki/File:Perspectiva-2.svg
Silk Screen
Illumination
Observer Viewpoint
Rays
Painted/Traced Edge
Orthographic Parallel Projection Cartography – Orthographic – Mercator
(Cylindrical)
Sam Siewert 11
http://en.wikipedia.org/wiki/File:Axonometric_projection.svg
http://en.wikipedia.org/wiki/File:Cylindrical_Projection_basics2.svg
Vanishing Point Linear Perspective (1 to 3 Vanishing Points) Curvilinear (4 or 5 Vanishing Points)
Sam Siewert 12
Single Vanishing Point Double Vanishing Point
http://en.wikipedia.org/wiki/File:Zentralperspektive.png http://en.wikipedia.org/wiki/File:TwoPointPerspective.png
http://en.wikipedia.org/wiki/File:Frankfurt_Airport_tunnel.JPG
Perspective Concept
Sam Siewert 13
viewpoint
Object
Render Plane Intersections
http://en.wikipedia.org/wiki/File:Perspectiva-1.svg
Perspective Projection Normal Projection Used in Ray Tracing – Define Extents of Render Plane – l=left, r=right, t=top, b=bottom – Viewpoint “e” is shown on Render Plane – Move e out of Plane to Location of Camera/Viewer
Sam Siewert 14
Fundamentals of Computer Graphics, 3rd Edition - page 75
2D Image Transformations
Basic PSF Convolutions
Sam Siewert
15
Pixel Neighborhood Convention {P} – Originally Sampled Frame or Sub-frame of Pixels {Q} – First Transformation of {P} – Negative Image – {Q}=Saturation – {P} – Where Saturation for 8-bit Gray-level is 255
– Difference Image – {R} = {Q} – {P} is the time of sample of {Q} is greater than {P}
– A threshold (Part 2) – From Histogram
P0 is the Pixel of Interest in a Neighborhood – So, for all pixels in {P}, if Q0=P1, then {Q} is the same image shifted
one pixel to the left – If {Q}={P}+beta, modifies brightness – If {Q}={P} x gamma, modifies contrast – If {Q}={P} x gamma + beta, modifies both contrast and brightness – This Can Define a PSF for an Image Convolution – e.g. Sharpen
Sam Siewert 16
P4 P3 P2P5 P0 P1P6 P7 P8
Common PSF Convolution See www.dspguide.com/CH24.PDF
– For all pixels, do {Q0 = P0*h0+P1*h1+P2*h2+P3*h3+P4*h4+P5*h5+P6*h6+P7*h7+P8*h8; }
Convolution of causes no change to image
Sam Siewert 17
0 0 00 1 00 0 0 http://www.dspguide.com/ - Chapter 24
Median Filter Concept
For all Pixels in Image do – minPixel = min(P1, P2, P3, P4, P5, P6, P7, P8) – maxPixel = max(P1, P2, P3, P4, P5, P6, P7, P8)
– If(P0 < minPixel) Q0 = minPixel – Else If (P0 > maxPixel) Q0 = maxPixel – Else Q0 = P0
Sam Siewert 18
Standard Median Filter Algorithm
Sam Siewert 19
// zero histogram for 0…255 for (i=0; i<=255; i++) hist[i]=0; for all pixels in Image P do { // All pixels in the kernel note value for (m=0; m<=8; m++) hist[P[m]]++; i=0; sum=0; while (sum < 5) { sum = sum + hist[i]; i = i + 1; } Q0 = i – 1; for(m=0; m<=8; m++) hist[P[m]]=0; }
Q4 Q3 Q2Q5 Q0 Q1Q6 Q7 Q8
Median Filter Algorithm – Nearest Neighbor (p. 108-109)
The Median Filter Uses Binning in range of 0 to Saturation of PGM (0 to 255) – Obviates need to Sort the Value of Neighbors in Kernel
3x3 – Q0 is the 5th largest neighbor in the Kernel – Must Zero Histogram of size 256 for Each Pixel – Loop through all neighbors and bin them – Each P[m] neighbor’s value is the index into the histogram
of counts for pixels at that value
This filter provides noise suppression, but softens edges Truncated Median Filter Removes Noise and Sharpens
Sam Siewert 20