Quadtree A quad tree is a tree of order 4. 18. Quadtrees Quadtrees, Collision Detection, Image Segmentation ... and as such it is not particularly interesting except when it is used for ... 523 524 Quadtree - Interpretation und Nutzen Example 1: Collision Detection Separation of a two-dimensional range into 4 equally sized parts. Objects in the 2D-plane, e.g. particle simulation on the screen. Goal: collision detection [analogously in three dimensions with an octtree (tree of order 8)] 525 526
Idea Grids Many objects: n 2 detections (naively) Improvement? A grid often helps, but not always Obviously: collision detection not Improvement? required for objects far away from More finegrained grid? each other Too many grid cells! What is „far away”? Grid ( m × m ) Collision detection per grid cell 527 528 Adaptive Grids Algorithm: Insertion Quadtree starts with a single node Objects are added to the node. A grid often helps, but not always When a node contains too many Improvement? objects, the node is split. Adaptively refine grid Objects that are on the boundary Quadtree! of the quadtree remain in the higher level node. 529 530
Algorithm: Collision Detection Example 2: Image Segmentation Run through the quadtree in a recursive way. For each node test ⇒ + collision with all objects contained in the same or (recursively) contained nodes. (Possible applications: compression, denoising, edge detection) 531 532 Quadtree on Monochrome Bitmap Quadtree with Approximation When there are more than two color values, the quadtree can get very large. ⇒ Compressed representation: approximate the image piecewise constant on the rectangles of a quadtree. Similar procedure to generate the quadtree: split nodes recursively until each node only contains pixels of the same color. 533 534
Piecewise Constant Approximation Intermediate Result The (w.r.t. mean squared error) best approximation (Grey-value) Image z ∈ ❘ S on pixel indices S . 36 � µ r = 1 z s Rectangle r ⊂ S . | r | s ∈ r Goal: determine � ( z s − x ) 2 arg min and the corresponding error x ∈ r s ∈ r � � ( z s − µ r ) 2 =: � z r − µ r � 2 Solution: the arithmetic mean µ r = 1 s ∈ r z s 2 | r | s ∈ r can be computed quickly after a O ( | S | ) tabulation: prefix sums! 36 we assume that S is a square with side length 2 k for some k ≥ 0 535 536 Which Quadtree? Which Quadtree? Idea: choose between data fidelity and complexity with a Conflict regularisation parameter γ ≥ 0 Choose quadtree T with leaves 37 L ( T ) such that it minimizes the As close as possible to the data ⇒ small rectangles, large following function quadtree . Extreme case: one node per pixel. Approximation = original � � z r − µ r � 2 H γ ( T, z ) := γ · | L ( T ) | + . Small amount of nodes ⇒ large rectangles, small quadtree 2 � �� � Extreme case: a single rectangle. Approximation = a single r ∈ L ( T ) Number of Leaves � �� � grey value. Cummulative approximation error of all leaves 37 here: leaf: node with null-children 537 538
Regularisation Observation: Recursion If the (sub-)quadtree T represents only one pixel, then it cannot be split and it holds that Let T be a quadtree over a rectangle S T and let T ll , T lr , T ul , T ur be the four possible sub-trees and � H γ ( T, z ) = γ � � � z r − µ r � 2 H γ ( T, z ) := min γ · | L ( T ) | + Let, otherwise, 2 T r ∈ L ( T ) M 1 := γ + � z S T − µ S T � 2 2 M 2 := � H γ ( T ll , z ) + � H γ ( T lr , z ) + � H γ ( T ul , z ) + � Extreme cases: H γ ( T ur , z ) γ = 0 ⇒ original data; then γ → ∞ ⇒ a single rectangle � H γ ( T, z ) = min { M 1 ( T, γ, z ) , M 2 ( T, γ, z ) } � �� � � �� � no split split 539 540 Algorithmus: Minimize( z , r , γ ) Analysis Input: Image data z ∈ ❘ S , rectangle r ⊂ S , regularization γ > 0 Output: min T γ | L ( T ) | + � z − µ L ( T ) � 2 2 if | r | = 0 then return 0 m ← γ + � s ∈ r ( z s − µ r ) 2 if | r | > 1 then The minimization algorithm over dyadic partitions (quadtrees) takes Split r into r ll , r lr , r ul , r ur O ( | S | log | S | ) steps. m 1 ← Minimize( z, r ll , γ ) ; m 2 ← Minimize( z, r lr , γ ) m 3 ← Minimize( z, r ul , γ ) ; m 4 ← Minimize( z, r ur , γ ) m ′ ← m 1 + m 2 + m 3 + m 4 else m ′ ← ∞ if m ′ < m then m ← m ′ return m 541 542
Application: Denoising (with addditional Wedgelets) Extensions: Affine Regression + Wedgelets noised γ = 0 . 003 γ = 0 . 01 γ = 0 . 03 γ = 0 . 1 γ = 0 . 3 γ = 1 γ = 3 γ = 10 543 544 Other ideas no quadtree: hierarchical one-dimensional modell (requires dynamic programming) 545
Recommend
More recommend