basic image topology and geometry1 - computer sciencerklette/ccv-sevilla/pdfs... · 2014-06-09 ·...
TRANSCRIPT
Digital Topology Digital Geometry
Basic Image Topology and Geometry1
(80 min lecture)
See Material inReinhard Klette: Concise Computer Vision
Springer-Verlag, London, 2014
ccv.wordpress.fos.auckland.ac.nz
1See last slide for copyright information.1 / 38
Digital Topology Digital Geometry
Agenda
1 Digital Topology
2 Digital Geometry
2 / 38
Digital Topology Digital Geometry
An Example of a Topological Problem
What is the topological complexity of this door handle: How many cutsare needed at least for transforming it into a simply connected volume?
3 / 38
Digital Topology Digital Geometry
Components in Images
How many grey components? How many black components? How manywhite components?
Is the “black line” crossing “on top” of the “grey line”? Is a componenttopologically simple, or does it have a hole?
4 / 38
Digital Topology Digital Geometry
We Know this Problem from Euclidean Topology
See the checker board in the Euclidean plane:
One black component or one white component?
5 / 38
Digital Topology Digital Geometry
It Depends on the Central Corner where 4 Squares Meet
Say: If “grey > white” then the central corner is grey, and if “white >grey” then it is white.
Who decides? We do. For the checkerboard, and also for the image.
If only two shades then we could also go with open and closed squares.6 / 38
Digital Topology Digital Geometry
We Decide the Order of Importance (the key)
Assumed key: black > grey > white, then
Pixel adjacency by connectedness of pixel squares in Euclidean topologyComponents of pixels by transitive closure of pixel adjacencyDefault key for grey-level images: 0 < 1 < . . . < Gmax = 2a − 1
7 / 38
Digital Topology Digital Geometry
K-Adjacency for Binary Images
In grey-level image 0 for “black” and Gmax for “white”, but in binaryimage 0 for “white” and 1 for “black”
Key for binary images either
0 < 1: 4-adjacency for open 0-pixels, 8-adjacency for closed 1-pixels
1 < 0: 4-adjacency for open 1-pixels, 8-adjacency for closed 0-pixels
8 / 38
Digital Topology Digital Geometry
What is a ”Border of a Component”?
Two scanlines arrive at objects of interest (lights); at this moment atracing procedure starts for going around on the border of the object
9 / 38
Digital Topology Digital Geometry
Definition of Borders
We define borders of “objects”
We can decide whether p ∈ Ω is in an object component, or not(e.g. by using a local decision criterion at p)
The location p ∈ Ω of a border pixel of a component S ⊆ Ω
1 is in set S and
2 there is at least one pixel location q ∈ Ω such that
1 q is adjacent to p but2 q /∈ S
The chosen adjacency (4-, 8-, or K-adjacency) specifies in general differentsets of border pixels for the same image region S
10 / 38
Digital Topology Digital Geometry
Border Tracing Strategy
Select pixel adjacency (4-, 8-, or key-adjacency) for objects or the image
When at a border pixel:
Test all the adjacent pixels in a defined order (i.e. aim at having theobject region either always on the right, or always on the left)
Generate a sequence of border pixels p0, p1, . . . , pi
Local Circular Orders
For every pixel location p we select uniformly a local circular order
ξ(p) = 〈q1, . . . , qn〉
which lists (exactly once) all pixel locations which are adjacent to p
Possible: Clockwise or counter-clockwise local circular orders
11 / 38
Digital Topology Digital Geometry
Examples of Local Circular Orders
Assume clockwise numberings of pixels qi around p; see upper right
Possible local cycles for 4- or 8-adjacency for p:
ξ(p) = 〈q1, q7, q5, q3〉 ξ(p) = 〈q1, q2, q3, . . . , q8〉
ξ(p) = 〈q1, q3, q5, q6, q7〉 ξ(p) = 〈q1, q2, q3, . . . , q8〉
Possible local cycles for K-adjacency with key “black > gray > white”12 / 38
Digital Topology Digital Geometry
Example of a Traced Border
Consider tracing for 4-adjacency; black pixel = ”object pixel”
12
34
q0 p0 p1 p2
p3 p4
Left: Selected local circular orderRight: Arrival at an object when going from q0 to p0
Note: Tracing the same pixel for a second time is not a stop criterion
13 / 38
Digital Topology Digital Geometry
Border Tracing Algorithm by Klaus Voss
1: Let (q0, p0) = (q, p), i = 0, and k = 1;2: Let q1 be the pixel which follows q0 in ξ(p0);3: while (qk , pi ) 6= (q0, p0) do4: while qk in the object do5: Let i := i + 1 and pi := qk ;6: Let q1 be the pixel which follows pi−1 in ξ(pi ) and k = 1;7: end while8: Let k = k + 1 and go to pixel qk in ξ(pi );9: end while
10: The calculated border cycle is 〈p0, p1, . . . , pi 〉;
14 / 38
Digital Topology Digital Geometry
Agenda
1 Digital Topology
2 Digital Geometry
15 / 38
Digital Topology Digital Geometry
Geometry in Digital Images
Images are given with a resolution of Ncols × Nrows , i.e. the size of Ω
This resolution influences the accuracy when solving geometric tasks
Examples of geometric tasks
Area or perimeter of an object region
Length or curvature of a path in an image
An increase in image resolution should support an increase in accuracy formeasured properties (known as multigrid convergence of measurements)
This needs to be ensured by the used measurement algorithms
16 / 38
Digital Topology Digital Geometry
Circle or Ellipse?
Ellipses in 2D image, but circles in 3D scene
In this lecture: Analysis of 2D geometry only17 / 38
Digital Topology Digital Geometry
The “Staircase Effect”
Length a√
2 of a diagonal pq in a square with sides of length aBut: Length of diagonal 4-paths always equal to 2a
q
p
q
p
q
p
0 10
1
x
y
x
y
x
y
x
y
0 10
1
0 10
1
0 10
1
Also: Perimeter of a digitised unit disks always equal to 418 / 38
Digital Topology Digital Geometry
How to Measure Length in the Euclidean Plane?
Length is measured for arcs
Consider the length of a polygonal approximation of an arc
Defined by points φ(ti ) on the arc
Let points φ(ti ) move closer and closer together (i.e. increase of n)
We obtain more line segments on the polygonal approximation
Their length converges against the length of the given arc19 / 38
Digital Topology Digital Geometry
Observation
The use of the length of a 4-path for estimating the length of a digital arccan lead to errors of 41.4% compared to arcs prior to digitisation
without any chance to reduce these errors in some cases by using highergrid resolution. This method is not recommended for length measurementsin image analysis.
May be Weighted Edges Can Solve the Problem?
Another attempt: Use the length of an 8-path for length measurements
Use weight√
2 for diagonal edges and weight 1 for isothetic edges (i.e.parallel to one of the coordinate axes)
20 / 38
Digital Topology Digital Geometry
Example
Consider digitised line segment pq with slope 22.5 and length 5√
5/2
What are the lengths of those 8-paths when using the proposed weights?
21 / 38
Digital Topology Digital Geometry
Answer
For a grid with edges of length 1 (shown on the left)
The length equals 3 + 2√
2
For any grid with edges of length 1/2n, for n ≥ 1
The length equals (5 + 5√
2)/2
Result
Length of 8-paths not converging to 5√
5/2 as grid edge length goes to 0
Observation
The use of the length of an 8-path for estimating the length of a digital arccan lead to errors of 7.9% compared to arcs prior to digitisation
This upper bound for errors might be acceptable in some applications
22 / 38
Digital Topology Digital Geometry
A Solution with Convergence to True Length
Polygonal Simplification of Borders
We recall the scheme illustrated on Page 19
1 Segment a given digital arc into maximum-length digital straightsegments (DSSs) as on the next page
2 Take the sum of lengths of those straight segments
Measurement converges to the true length of a digitized arc when goingfor images with finer and finer grid resolution
23 / 38
Digital Topology Digital Geometry
Illustration of Arc Segmentation into DSSs
Clockwise (left) and counterclockwise (right) polygonal approximationof the border of a region by maximum-length DSSs
(For details see algorithms for DSS calculation)24 / 38
Digital Topology Digital Geometry
Area Estimation is Simpler
First: How is area defined in the Euclidean plane?
(1) Area of triangle 〈p, q, r〉, for p = (x1, y1), q = (x2, y2), r = (x3, y3)
A =1
2· |x1y2 + x3y1 + x2y3 − x3y2 − x2y1 − x1y3|
(2) Area of simple polygon 〈p1, p2, . . . , pn〉, for pi = (xi , yi ), i = 1, 2, . . . , n
A =1
2
∣∣∣∣∣n∑
i=1
xi (yi+1 − yi−1)
∣∣∣∣∣with y0 = yn and yn+1 = y1
(3) In general: Area of a measurable set R ⊂ R2
A =
∫Rdx dy
25 / 38
Digital Topology Digital Geometry
How to Measure the Area of a Region in an Image?
Answer by C. F. Gauss in the early 19th century:
Count all the grid points (i.e. pixel locations) in the digitised set andmultiply by the size of a grid square (i.e. the pixel size)
Next page: Illustration of an experiment
1 Given: Simple polygon defined in a grid of size 512× 512having area A = 102, 742.5 and perimeter P = 4, 040.7966 . . .
2 Subsample this polygon in images of reduced resolution
3 Estimate area and perimeter in images and compare with A and P
26 / 38
Digital Topology Digital Geometry
Different Digitizations
27 / 38
Digital Topology Digital Geometry
Results
Area: As proposed by Gauss, the number of pixels (i.e. grid cells)times the square of the edge length
Perimeter: Number of cell edges on the frontier of the polygon timesthe length of an edge (i.e. illustrating failure of 4-adjacency again)
28 / 38
Digital Topology Digital Geometry
Relative Deviation
Relative deviation
is the absolute difference between estimated property values Pest and P forsubsampled polygon and original polygon, respectively, divided by P
|Pest − P|P
Relative deviation in percent
|Pest − P|P
· 100
29 / 38
Digital Topology Digital Geometry
Curvature for Border Characterization
Shapes may also be characterised byhigh-curvature points orchange in curvature along the border
30 / 38
Digital Topology Digital Geometry
A Third Property: Curvature
Curvature can be defined at non-singular points of a smooth arc γ(t)in the Euclidean plane
Curvature at a point p on γcan be defined in different ways
Option 1: Rate of change of angle of a tangential line at p
Option 2: Derivative at p (requires a parameterised representation of γ)
There are more options (e.g. radius of osculating circle)
31 / 38
Digital Topology Digital Geometry
Option 1: Rate of Change
xx
yy
ψ
p
t=a
t
n
L(t)
Starting at t = a, the arc to p = γ(t) has the length l = L(t)
n is the normal, and t the tangent defining angle ψ
While p is sliding along γ, angle ψ will change
32 / 38
Digital Topology Digital Geometry
Rate of Change in ψ
Defines curvature κtan(p)
κtan(t) =dψ(t)
dl
(1) “Fast change” in ψ = “high curvature”
(2) “Slow change” in ψ = “low curvature”
(3) No change in ψ = p on a straight segment of γ
33 / 38
Digital Topology Digital Geometry
Convex, Inflection or Straight, or Concave
κtan(t) can be
1 negative: p is a convex point
2 zero: p is a point of inflection or on a straight segment
3 positive: p is a concave point
n
n
34 / 38
Digital Topology Digital Geometry
Option 2: Curvature of a Parametrized Arc
Assume a parametric representation γ(t) = (x(t), y(t)). Then:
κtan(t) =x(t) · y(t) − y(t) · x(t)
[ x(t)2 + y(t)2 ]1.5
with
x(t) =dx(t)
dt, y(t) =
dy(t)
dt, x(t) =
d2x(t)
dt2, y(t) =
d2y(t)
dt2
35 / 38
Digital Topology Digital Geometry
Now: Curvature in an Image
How to define curvature of a border of an object region at pixel location p?
pi
pi-k
pi+k
Example:Go k = 3 steps forward and backward for points pi−k and pi+k
Use those three points now for estimating curvature
36 / 38
Digital Topology Digital Geometry
Example: Following Option 2
Given: Digital curve 〈p1, . . . , pm〉, where pj = (xj , yj) for 1 ≤ j ≤ m
Assume: Samples along parametrized curve γ(t) = (x(t), y(t)), t ∈ [0,m]At pi thus γ(i) = pi
Functions x(t) and y(t) locally interpolated by second order polynomials
x(t) = a0 + a1t + a2t2
y(t) = b0 + b1t + b2t2
Let x(0) = xi , x(1) = xi−k , x(2) = xi+k for k ≥ 1; analogously for y(t)
Curvature at pi then defined by
κi =2(a1b2 − b1a2)
[ a21 + b21 ]1.5
37 / 38
Digital Topology Digital Geometry
Copyright Information
This slide show was prepared by Reinhard Klettewith kind permission from Springer Science+Business Media B.V.
The slide show can be used freely for presentations.However, all the material is copyrighted.
R. Klette. Concise Computer Vision.c©Springer-Verlag, London, 2014.
In case of citation: just cite the book, that’s fine.
38 / 38