tracing and compressing digital curves andrás hajdu department of computer graphics and image...

41
Tracing and c Tracing and c ompressing ompressing digital curves 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, July 2-11 2009, Debrecen.

Upload: john-day

Post on 26-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Tracing and Tracing and ccompressingompressing digital curvesdigital curves

András Hajdu

Department of Computer Graphics and Image ProcessingFaculty of Informatics, University of Debrecen, Hungary

17th Summer School on Image Processing, July 2-11 2009, Debrecen.

Overview Overview of the problemof the problem

Tracing a curve having Tracing a curve having general topologygeneral topology

Partitioning the curve Partitioning the curve into lineinto line s segmentsegments

Overview Overview of the proposed approachof 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 underlyingAssigning an underlyinggraph to the curve - Basicsgraph to the curve - Basics

• A graph G = ( V, E )V: set of vertices, E = V×V= {{v1, v2} | v1, v2 V }: 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 underlyingAssigning an underlyinggraph to the curve - Basicsgraph 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 underlyingAssigning an underlyinggraph to the curvegraph to the curve

The curve tracing (CT) algorithm:

1. 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.

2. Create an Euler decomposition Ci of C based on GC.

3. Trace all the Ci’s separately through their Euler paths.

i=1

n

Realization of CT algorithmRealization of CT algorithm - -preprocessingpreprocessing

• 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 algorithmRealization of CT algorithm - -locating verticeslocating 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 algorithmRealization of CT algorithm - -extracting edgesextracting 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 algorithmRealization of CT algorithm - -the underlying graphthe underlying graph

end points:1,10

junction points:2,3,4,5,6,7,8,9,11,12,13

Realization of CT algorithmRealization of CT algorithm - -junctions of special typejunctions 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.

edge end point

edge point

junction point

degenaratedintersection

K = 2

K = 9

Realization of CT algorithmRealization of CT algorithm - -tracing the componentstracing 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 algorithmRealization of CT algorithm - -tracing through junctionstracing 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, . . ., Ek

edge 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 algorithmRealization of CT algorithm - - tracing through junctions tracing through junctions

we arrive at E0 ... ... we go on with E2

Realization of CT algorithmRealization of CT algorithm - -restrictions for tracingrestrictions for tracing

The most straight direction cannot be always selected freely at junctions.

We must obey the graph traversal (Fleury’s) algorithmto 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 algorithmRealization of CT algorithm - - complete tracing 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

Realization of CT algorithmRealization of CT algorithm - - complete tracing complete tracing of the of the

curvecurve

Compressing the curve -Compressing the curve -steps of compressionsteps 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 -Compressing the curve -alphabet of digital line segmentsalphabet of digital line segments

Λ is a finite alphabet of Bresenham line segments of all orientations having length at most T.

T=6, first octant

Compressing the curve -Compressing the curve -alphabet of digital line segmentsalphabet of digital line segments

all orientations

Compressing the curve -Compressing the curve -alphabet of digital line segmentsalphabet 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 -Compressing the curve -replacing curve segmentsreplacing curve segments

• Online curve compression is used:during tracing the curve, current curve segment is replaced from Λ if it violates linearity:

Information loss is allowed as Bresenham segments differ, but linearity is common criterion.

the segment should stay between two parallel lines [Rosenfeld and Klette].

Compressing the curve -Compressing the curve -comparing with JBEAMcomparing 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 in cells to be substituted by beamlets.

Compressing the curve -Compressing the curve -comparing with JBEAMcomparing with JBEAM

Test curvesTest curves

Euler curvesEuler curvesNon-Euler curveNon-Euler curve(decomposition)(decomposition)

Compressing the curve -Compressing the curve -comparing with JBEAMcomparing with JBEAM

~50% improvement

With tracing, the proposed CT algorithm avoids subdivision.

Compressing the curve -Compressing the curve -comparing with MPEG-4comparing with MPEG-4

• In MPEG-4 a vertex-based shape approximation was developed to code the outline of shapes.

• 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 -Compressing the curve -comparing with MPEG-4comparing with MPEG-4

ddmax max = 2 / 2= 2 / 2 guarantees straight polygon segments.guarantees straight polygon segments.

ddmax max = 1= 1 had similar performance than the proposed.had similar performance than the proposed.

ddmax max = 1.4= 1.4 is reported perceptually acceptable.is reported perceptually acceptable.

Compressing the curve -Compressing the curve -comparing with MPEG-4comparing with MPEG-4

Test curves (shapes have simple closed boundary)Test curves (shapes have simple closed boundary)

Compressing the curve -Compressing the curve -comparing with MPEG-4comparing with MPEG-4

~similar performance with MPEG-4 for dmax=1

(dmax=1 violates the linearity criterion for MPEG-4)

Compressing the curve -Compressing the curve -comparing with MPEG-4comparing with MPEG-4

Partitioned test curvesPartitioned test curves

Compressing the curve -Compressing the curve -comparing with MPEG-4comparing 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 -Compressing the curve -more MPEG-4 improvementsmore 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 –Alternative approaches –weighted graphsweighted 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 –Alternative approaches –weighted graphsweighted graphs

number of letters needed to compress edges (weights)

Alternative approaches –Alternative approaches –compressing edges separatelycompressing edges separately

• Compression can be executed at edge level without tracing.

• This simple approach also avoids curve subdivision, but has drawbacks:

– the coordinates of the start pixel of each curve segment for appropriate geometric positioning.

– lack of junction information leads to distortion at junctions during decompression (the curve segments must be connected ad-hoc).

Alternative approaches –Alternative approaches –compressing edges separatelycompressing edges separately

Optimal tracing performs well for curves having more straight sections (e.g. General, Lines)

Alternative approaches –Alternative approaches –avoiding Euler decompositionavoiding 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 –Alternative approaches –avoiding Euler decompositionavoiding 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 –Alternative approaches –avoiding Euler decompositionavoiding Euler decomposition

Path with minimal weight sum:{1,6,7,4,6,10,15,13,9,7,4,{1,6,7,4,6,10,15,13,9,7,4,3,2,33,2,3,5,8,9,11,15,,5,8,9,11,15,16,17,1616,17,16,14,8,5,14,13,11,10,12},14,8,5,14,13,11,10,12}

Start

End

Discussion,Discussion,applicationsapplications

• 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 publicationsRelated 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 Processing 17/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.

ACKNOWLEDGEMENTThis 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.