410 likes | 560 Views
Tracing and c ompressing digital curves. András Hajdu Department of Computer Graphics and Image Processing Faculty of Informatics, University of Debrecen , Hungary 17th Summer School on Image Processing , Ju ly 2-11 2009, Debrecen . Overview of the problem. Overview
E N D
Tracing and compressingdigital curves András Hajdu Department of Computer Graphics and Image Processing Faculty of Informatics, University of Debrecen, Hungary 17th Summer School on Image Processing, July 2-11 2009, Debrecen.
Overview of the proposed approach • Assign an underlying graph to the curve • Find an Euler decomposition of the graph • Trace the Euler components with respect to a linear optimality criterion at junctions • Compress the curve components using an alphabet of line segments (polygon approximation)
Assigning an underlyinggraph to the curve - Basics • A graphG = (V,E) V: set of vertices, E=V×V= {{v1, v2} | v1, v2V}: set of edges. • G is undirected, loops and multiple edges allowed. • The degree of a vertex is the number of edges containing it. • A path is a list of edges: {v1,v2}, {v2,v3}, . . . , {vn-1,vn}. • A route is a closed path with v1= vn. • A path containing all the edges exactly once is an Euler path (route)
Assigning an underlyinggraph to the curve - Basics • An Euler decomposition of G is the union of its edge-disjoint Euler subgraphs Gi (i=1,...,n). • Results on Euler graphs and decompositions: • Every Euler graph is connected, • A connected graph has Euler route iff all of its vertices have even degree, • A connected graph has Euler path iff at most two vertices have odd degree, • Every connected graph has an Euler decomposition.
Assigning an underlyinggraph to the curve • The curve tracing (CT) algorithm: • Assign a graph GC = ( VC, EC) to the curve C, where VC contains all the end and junction points of C. The edges are the curve segments connecting these vertices. • Create an Euler decomposition Ciof C based on GC. • Trace all the Ci’s separately through their Euler paths. n i=1
Realization of CT algorithm -preprocessing • The input can be any one-pixel wide self intersecting object (curve) for graph assignment. • To guarantee one-pixel wideness, thinning can be applied first to remove undesired thickening pixels.
Realization of CT algorithm -locating vertices • Vertices are assigned to curve junctions and end points Junctions: curve points with more than two 8-neighbors, End points: curve points with exactly one 8-neighbor.
Realization of CT algorithm -extracting edges • Non-vertex 8-neighbors of vertices with exactly two 8-neighbors are marked as edge end points. • Edges are 8-connected paths connecting edge end points. edge end point edge point junction point
Realization of CT algorithm -the underlying graph end points: 1,10 junction points: 2,3,4,5,6,7,8,9,11,12,13
Realization of CT algorithm -junctions of special type • Junctions degenerate if tangents of curve segments almost coincide. • Junction points closer than a threshold K are found, and the pixels between them are merged. degenaratedintersection edge end point edge point junction point K = 2 K = 9
Realization of CT algorithm -tracing the components • The first step to trace an Euler curve is to locate a starting vertex having odd degree. • Then, we take an edge from the starting vertex to initialize the tracer. possible starting vertices: 1 (finishing at 10) 10 (finishing at 1) possible starting edges: {1,4} (finishing with {8,10}) {10,8} (finishing with {4,1})
Realization of CT algorithm -tracing through junctions • More Euler paths may exist. Which edge to take next at junctions? • For better polygon approximation, go on straight: • calculate the centre of the junction having E1, . . ., Ekedge end points (we arrive at E0) • calculate the change of direction for all Ei: • select the most linear direction towards El with:
Realization of CT algorithm - tracing through junctions we arrive at E0 ... ... we go on with E2
Realization of CT algorithm -restrictions for tracing The most straightdirection cannot be always selected freely at junctions. We must obey the graph traversal (Fleury’s) algorithm to extract an Euler path: • Always leave one edge available to get back to the starting vertex or to the other odd vertex. • Do not use an edge to go to a vertex unless there is another edge available to leave it.
Realization of CT algorithm - complete tracing Euler path: {1,4,5,2,4,8,13,11,7,5,2,3,6,7,9,13,12,6,3,12,11,9,8,10} Start End
Compressing the curve - steps of compression • A finite alphabet of digital line segments is defined. • The traced curve is compressed online to replace curve segments with letters from the alphabet. • Complementary variable length (Huffmann) coding is applied.
Compressing the curve - alphabet of digital line segments Λ is a finite alphabet of Bresenham line segmentsof all orientations having length at most T. T=6, first octant
Compressing the curve - alphabet of digital line segments all orientations
Compressing the curve - alphabet of digital line segments • Cardinality of Λ: • Number of bits to code a letter: To keep cardinality small, we consider unique (Bresenham) segments to connect two points.
Compressing the curve - replacing curve segments • Online curve compression is used:during tracing the curve, current curve segment is replaced from Λ if it violates linearity: the segment should stay between two parallel lines [Rosenfeld and Klette]. Information loss is allowed as Bresenhamsegments differ, but linearity is common criterion.
Compressing the curve - comparing with JBEAM • JBEAM [Huo and Chen] is a state-of-the-art algorithm for the compresson of one-pixel wide objects. • It divides binary (curve) imageusing quadtree decomposition till having single linear curve segments incells to be substituted by beamlets.
Compressing the curve - comparing with JBEAM
Compressing the curve - comparing with JBEAM ~50% improvement With tracing, the proposed CT algorithm avoids subdivision.
Compressing the curve - comparing with MPEG-4 • In MPEG-4 a vertex-based shape approximation was developed to code the outline ofshapes. • The boundary is approximated by a polygon, with a recursive splitting process that starts with the longest axis (diameter). • If the distance of the curve and polygon segment is > dmax the segment is splitted into two new parts.
Compressing the curve - comparing with MPEG-4
Compressing the curve - comparing with MPEG-4
Compressing the curve - comparing with MPEG-4 ~similar performance with MPEG-4 for dmax=1 (dmax=1 violates the linearity criterion for MPEG-4)
Compressing the curve - comparing with MPEG-4
Compressing the curve - comparing with MPEG-4 MPEG-4 recommends the application of a complementary variable length coding, e.g. Huffmann coding ~50% improvement in compression performance.
Compressing the curve - more MPEG-4 improvements Some more minor recommendations from MPEG-4: • For lossy shape coding the selection of the vertices on the object boundary is not optimal. Therefore, the vertices can be shifted by 1 pixel within a neighborhood of size 3 × 3. • The maximal length of the alphabet elements can be fixed dynamically as the length of the longest polygon segment. In this case, this length information should be transmitted, as well.
Alternative approaches – weighted graphs • The same finite alphabet of line segments and online curve compression is considered. • Weighted graph approaches can be considered with a natural weight function for the edges: • The number of letters needed:
Alternative approaches – weighted graphs number of letters needed to compress edges (weights)
Alternative approaches – compressing edges separately • Compression can be executed at edge level without tracing. • Thissimple approach also avoids curve subdivision, but has drawbacks: • the coordinates of the start pixel of each curve segment for appropriate geometricpositioning. • lack of junction information leads to distortion at junctions during decompression (the curve segments must be connected ad-hoc).
Alternative approaches – compressing edges separately Optimal tracing performs well for curves having more straight sections (e.g. General, Lines)
Alternative approaches – avoiding Euler decomposition • Our basic approach is to decompose every underlying graph into Euler subgraphs. • Decomposition can be avoided with taking some edges more than once (Chinese Postman Problem, CPP). • Advantage is that we can avoid graph decomposition. • Disadvantage is the redundant compression of edges. • Algorithmic solution is known for the CPP problem:we must try to select the redundant edges with keepingthe extra weight sum minimal.
Alternative approaches – avoiding Euler decomposition • Vertices 1,2,3,12,16,17 are of odd degree (non-Euler) • Allowing edges {2,3} and {16,17} twice gives minimal weight sum for an Euler traversal.
Alternative approaches – avoiding Euler decomposition Start End Path with minimal weight sum: {1,6,7,4,6,10,15,13,9,7,4,3,2,3,5,8,9,11,15,16,17,16,14,8,5,14,13,11,10,12}
Discussion, applications • To ”untie” curves can have impact in curve watermarking (with providing the data in terms of few large blocks) • Tracing the curve according to its ”natural” direction looks feasible to reconstruct hand-written text or figures, or to classify vessel types (arterial/venous): (image is from Rothaus et al. 2007)
Related publications • A. Hajdu and I. Pitas: Piecewise linear digital curve representation and compression using graph theory and a line segment alphabet, IEEE Trans. on Image Processing17/2 (February 2008), 126-133. • A. Hajdu and I. Pitas: Compression optimized tracing of digital curves using graph theory, IEEE International Conference on Image Processing (ICIP 2007), San Antonio, Texas, USA, Vol. VI, 453-456. ACKNOWLEDGEMENT This work was partially supported by the project SHARE: Mobile Support for Rescue Forces, Integrating Multiple Modes of Interaction, EU FP6 Information Society Technologies, Contract Number FP6-004218.