400 likes | 643 Views
Parallel Banding Algorithm to Compute Exact Distance Transform with the GPU. Thanh -Tung Cao Ke Tang Anis Mohamed Tiow-Seng Tan. Euclidean Distance. if p = ( p 1 , p 2 ,..., p n ) and q = ( q 1 , q 2 ,..., q n )
E N D
Parallel Banding Algorithm to Compute Exact Distance Transform with the GPU Thanh-Tung Cao Ke Tang Anis Mohamed Tiow-Seng Tan
Euclidean Distance • if p = (p1, p2,..., pn) and q = (q1, q2,..., qn) are two points in Euclidean n-space, then the distance from p to q, or from q to p is given by:
Voronoi diagram • A set of points (called seeds, sites, or generators) is specified beforehand and for each seed there will be a corresponding region consisting of all points closer to that seed than to any other.
Euclidean Distance Transform 100 100
Exact Euclidean Distance Transform • Let Si,jbe the nearest site, among all sites in row j,of the pixel (i, j), and let Si = {Si,j| Si,j NULL, j = 0, 1, 2, . . . , n−1} be the collection of such closest sites for all pixels in column i. Note that Si,jisNULLwhen there is no site in row j. • Let Pi be the set of sites whose Voronoi regions intersect the pixels in column i. These sites are termed the proximate sites of column i.
Fact 1 • Consider column i and let b(i1, j) and b′(i2, j) be two sites in row j. If |i1 − i| < |i2 − i|, then the Voronoi region of b′ cannot intersect column i. • This fact means that for each column i, there can be at most one site along a row that can potentially be a proximate site, or basically, Pi ⊆ Si. As a result, |Pi| ≤ n.
Fact 2 • Consider columni and let a(i1, j1), b(i2, j2), c(i3, j3) be any three sites with j1 < j2 < j3. Let the intersection of the perpendicular bisector of a and b and column i be p(i, u), and that of b and c be q(i, v). If u > v then the Voronoi region of b cannot intersect column i. • When the mentioned situation happens, we say that a and cdominateb on column i. In this case, bPi.
Fact 3 • Let q(i, v) and p(i, u) be two pixels in column i such that u > v, and let a(i1, j1) and c(i3, j3) be the closest sites to q and p respectively. Then we have j1 ≤ j3. • This fact means that the proximate sites of column ihave their Voronoi regions appear in exactly the same order as when they are sorted by their y-coordinates.
Exact Euclidean Distance Transform • Phase 1: For each pixel (i, j), compute Si,j. • Phase 2: Compute the set Pi for each column i using Si. • Phase 3: Compute the closest site for each pixel (i, j) using Pi
Parallel Banding Algorithm Phase 1 - Band Sweeping Band 1 Band 2 Band 3 Band 4
Parallel Banding Algorithm si i Phase 1 - Band Sweeping Band 1 Band 2 Band 3 Band 4 si,j si,j (i,j)
Parallel Banding Algorithm Phase 1 - Band Sweeping Band 1 Band 2 Band 3 Band 4
Parallel Banding Algorithm Phase 1 - Band Sweeping Band 1 Band 2 Band 3 Band 4
Parallel Banding Algorithm Phase 1 - Band Sweeping Band 1 Band 2 Band 3 Band 4
Parallel Banding Algorithm Phase 2 - Hierarchical Merging Band 1 Band 2 Band 3 Band 4
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si i Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 Band 1
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si i Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 Band 1 Si,2 Si,1 stack
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si i Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 (i,v) Si,3 Band 1 v u Si,2 Si,1 (i,u) stack
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si i Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 (i,v) Band 1 Si,3 Si,2 Si,1 (i,u) stack
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si i (i,u) Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 Si,4 Band 1 v u Si,5 Si,6 Si,3 Si,7 Si,2 Si,1 (i,v) stack
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si (i,v) i Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 Si,4 Band 1 (i,u) v u Si,2 Si,1 stack
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si (i,v) i Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 Si,4 (i,u) Band 1 v u Si,2 Si,1 stack
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si i Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 (i,v) Si,5 Band 1 (i,u) v u Si,4 Si,2 Si,1 stack
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si i Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 Si,6 Band 1 Si,5 Si,4 Si,7 Si,2 Si,1 stack
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si i (i,u) Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 Si,7 Band 1 v u Si,6 Si,5 Si,4 Si,2 Si,1 stack (i,v)
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si i Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 (i,u) Si,7 Band 1 v u Si,5 Si,4 (i,v) Si,2 Si,1 stack
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si i (i,v) Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 Si,7 Band 1 v u (i,u) Si,4 Si,2 Si,1 stack
Parallel Banding Algorithm • Phase 2 - Hierarchical Merging si i Si,1 Si,2 Si,3 Si,4 Si,5 Si,6 Si,7 Band 1 Si,7 Si,4 Si,2 Si,1 stack
Parallel Banding Algorithm i • Phase 2 - Hierarchical Merging Si,7 Si,4 Band 1 Si,2 Si,1 stack i Si,8 Si,9 Band 2 Si,12 Si,13
Parallel Banding Algorithm i • Phase 2 - Hierarchical Merging Band 1 Si,7 Band 2 Si,8 Si,4 Si,9 Si,2 Si,1 Si,12 Si,13 stack
Parallel Banding Algorithm i • Phase 2 - Hierarchical Merging Band 1 Si,12 Si,13 Si,9 Si,8 Si,7 Band 2 Si,4 Si,2 Si,1 stack
Parallel Banding Algorithm Phase 2 - Hierarchical Merging i proximate texture Band 1
Parallel Banding Algorithm Phase 3 - Block Coloring Case 1 pi i a a b m3 b
Parallel Banding Algorithm Phase 3 - Block Coloring Case 2 pi i a a b m3 b
Parallel Banding Algorithm Phase 3 - Block Coloring Case 2 pi i a a b m3 a a b b b