A Novel Method for Reconstructing Broken Contour Lines Extracted from Scanned Topographic Maps

It is known that after segmentation and morphological operations on scanned topographic maps, gaps occur in contour lines. It is also well known that filling these gaps and reconstruction of contour lines with high accuracy and completeness is not an easy problem. In this paper, a novel method is proposed dedicated in automatic or semiautomatic filling up caps and reconstructing broken contour lines in binary images. The key part of end points’ auto-matching and reconnecting is deeply discussed after introducing the procedure of reconstruction, in which some key algorithms and mechanisms are presented and realized, including multiple incremental backing trace to get weighted average direction angle of end points, the max constraint angle control mechanism based on the multiple gradient ranks, combination of weighted Euclidean distance and deviation angle to determine the optimum matching end point, bidirectional parabola control, etc. Lastly, experimental comparisons based on typically samples are complemented between proposed method and the other representative method, the results indicate that the former holds higher accuracy and completeness, better stability and applicability.


Introduction
Although photogrammetric interpretations of aerial photography and satellite imagery are the most common methods for extracting altimetry information, a great number of existing paper topographic maps, which remain the most frequent form of ground surface representation, provide a less expensive alternative: extracting contour lines from scanned topographic maps.One kind of the most interesting information shown by these paper-based topographic maps are the contour lines, which are imaginary lines that join different points located at the same elevation.The aliasing and false colors are inevitable in scanned common-conditioned topographic map, a large number of intersects and overlaps among point, line and region features, contour lines are usually the lowest layer in topographic map, all of those problems make the segmentation and vectorization of scanned topographic maps even more difficult, and also result in a great amount of caps in contour lines' images, which could not meet the demands of automatic vectorization.At present, existing techniques dedicated to realize the reconstruction of broken contour lines still could not give satisfactory results yet, and the primary defects lies in the low accuracy of end points' matching and reconnecting, lacking of stability and applicability for all kinds of scanned topographic maps (good, poor and worse).So the research on the reconstruction of broken contour lines is an open and interesting problem and field, it is a meaningful and significant work to bring forward an effective method to reconstruct broken contour lines, which could solve the problem of filling up the caps of broken contour lines exactly and completely.In this paper, we first summarize the related works in section 2. Next, in section 3, introduce the general procedure of reconstructing broken contour lines, then design a novel method to match end points accurately and automatically, a series of key algorithms and rules for supporting this method are proposed and realized.In section 4, full detailed processing flow is presented.In last section, there are some comparative experiments and analysis.

Related works
In general, vectorization of contour lines from scanned map needs four major steps: ①color segmentation for contour lines' image; ②binary, thinning and pruning shears; ③filling up caps in broken contour lines and reconstructing them; ④raster to vector conversion of all thinned and reconnected contour lines.Despite most of the attentions have been put on step1 and step2 for a long time, a slightly greater attention has been paid to step3: automatic or semi-automatic reconstruction of broken contour lines.A great amount of professors have carried out a lot of research works about reconstruction of broken contour lines, and there are many papers have been published.This paper analyzed the latest related research.When binary image is segmentated from scanned map, Morphological filters is applied to the resulted binary image for noise reduction, and a reconnection algorithm based on local information is designed: firstly Distance is computed by combining Euclidean distances between extremities and differences between their directions, then extremities in lower distance are connected (Arrighi and Soille 1999).Another approach named A* search algorithm is similar to Arrighi's method (Khotanzad and Zink 2003;Mun San et al. 2004).The images processed by those approaches still cause some problems such as overlapping contour lines and false connections (Figure 1(a)).A line tracing technique for reconnecting the contour lines, in which an interruption is resolved by searching from an end point of a line and the corresponding end point might be found within a sector around the current direction (Eikvril et al. 1995).A semi-automatic method for broken contour lines' reconstruction based on orientation, angle and Euclidean distance is proposed (Ismail and Sheiriff 2006).But this method is not optimal and cannot reconnect some contours (Figure 1  An approach based on Delaunay Triangulation and Voronoi Diagrams is proposed which uses the concept of medial axis of a curve λ: a point in the plane belongs to the medial axis of a curve λ, if at least two points located on the curve λ are at the same distance from this point (Amenta et al.1998;Ghircoias and Brad 2001).Its disadvantage is insufficient information and unsolved gaps.An improved method on the basis of min pair of breakpoints algorithm is: colorate contour lines, build spatial grid-index, find connect point between two break points on the basis of different color and distance, then connect the connect-points (Huang et al. 2006).GGVF (Generalized gradient vector flow) snake model algorithm is proposed to extract contour lines and use the directional field information to reconnect the broken contour lines (Xin et al. 2006).An automatic approach for filling up gaps between contour lines is: gradient orientation field generation from contour line normal; matching of end-points which is based on perfect matching algorithm; and filling the gap between each pair of end points (Pouderoux and Spinello 2007).The disadvantage of this approach is its processing time is very long for users.An advanced semi-automatic approach is based on local and geometric properties, such as parabolic and opposite directions, the y-ordinate's differences of end points, back-tracing (Samet and Hancer 2012).But false connections and unsolved caps could not be avoided (Figure 2).Knowledge based on reconnection techniques was summarized, which aim at developing various solutions for reconnecting broken contour lines and compare their performance based on their ability to determine the search space for locating the extension point and its ability to reconnect (Pradhan et al. 2013) A great amount of original scanned maps with high curve density are in poor or even worse quality.Reconnection errors (intersecting and overlapping) and unsolved gaps are still not handled with effectively and completely by using methods discussed above.In this paper, we proposed a novel reconstruction method based on a series of key algorithms and rules, which aims to be a semiautomatic procedure solution for reconnecting broken contour lines from binary images of scanned topographic maps, avoiding wrong reconnections and increasing completeness rate so as to reduce the human intervention as much as possible.

Proposed method
In this section, only the task of filling up the gaps and reconstruction of broken contour lines is handled with.It is assumed that other necessary tasks (topographic map digitization; color image segmentation and thresholding; filtering noisy pixels; thinning and pruning the binary image) are done before the task of filling up the gaps and reconnection of contour lines.In other words, an input for proposed method is post-segmentation, binary and thinned contour line image.The reconstruction of broken contour lines includes three stages: ①end points detection; ②end points matching; ③reconnection of matched end points.The end points detection mean that the ending pixel has only one neighbor.End points matching mean that detecting and identifying the most suitable chosen end point to an unfilled end point.Reconnection of matched end points could be finish with Cubic Spline Interpolation or Newton Interpolation method (Parker 1997;Giesen 2000).In this paper, Newton Interpolation method which has effective performance and provides users smooth curves is used.Based on the global topology properties(auto-enclosed, parallel and equidistant) and local properties(smoothing and continuous) of contour lines, in order to overcome the defects and faults of the other methods, the new proposed method designs and adopts a series of key algorithms, such as multiple incremental back-tracing to compute weighted average direction angle of end point, the max constraint angle control mechanism based on multiple gradient ranks, combination of weighted Euclidean distance and deviation angle between end points to determine the optimum matching point, bidirectional parabola control，etc.In order to enforce the global and local restraint for end points' matching and reconnection, raise the accuracy and completion rate, and enhance the ability of dealing with all kinds of complicated samples of contour line image, the proposed method emphasizes its stability and adaptability throughout its procedure.

Multiple incremental back-tracing
Previous methods usually detect and compute end points' directional angle by back-traceing fixed number of pixels from each end point, and use the linked-line between each end point and its back-tracing terminal point to construct directional angle.Back-tracing fixed number of pixels is inadequate and may cause some problems.For example, the direction of end point seems to be on x-axis or y-axis.It is very difficult to match with its pair which may not be on the x-axis or y-ordinate due to the property that contour lines generally have opposite and parabolic directions.In addition, the amount of back-traceing pixels is difficult to fix.If too little pixels are used for backtracing, the main tendency of a contour line may be ignored (Figure 3(a)).On the contrary, if too many pixels are used, the information of local direction of a contour line would be difficult to be reflected (Figure 3(b)).Therefore, only one-time back-tracing fixed amount of pixels tends to cause wrong results and has its uncertainty.Because this, we put forward a algorithm of multiple incremental back-tracing and weighted mean value to get end points' directional angle(Figure 3 (c)  (d)), aiming at applying multiple incremental backtracing to obtain weighted mean value as end points' directional angle, so that the results' stability and accuracy are further guaranteed.In figure3(d), P 1 means 1st back-tracing by l 1 pixels, P 2 means 2nd back-tracing by l2 pixels, P i means i-th backtracing by li pixels, P i +1 means (i+1)-th back-tracing by li+1 pixels, P n means n-th back-tracing by ln pixels.So this algorithm's main idea is: firstly build a back-tracing pixels dataset { 1 ,  2 , … ,   , … ,   }, which stores amount of increasing back-tracing pixels, place restrictions on minimum number {  } and maximum number {  } based on each contour line's actual length which end point P belongs to; next execute back-tracing to locate a terminal end point   , compute linked-line's directional angle between P and   i, lastly compute weighted mean value of directional angles' data set { 1 ,  2 , … ,   }, then the result would be assigned to ultimate directional angle value.The formulas for computing ultimate directional angle may be expressed as shown below (1 (1) (3)  {3,5,7,9,11,13,15}, thus seven times' back-tracing would be executed.Besides, there are some other conditions should be noticed: {  } = 3 , {  } = 15, with {  } < ,  represents broken contour line's actual length.This algorithm takes both broken contour line's local geometrical properties and global tendency into account.Therefore, its computational results possess higher accuracy, eliminating randomness and uncertainty caused by single back-tracing.

Max constraint angle control mechanism
As is shown in Figure 4(a), Let α is the directional angle of end point P ( 0 ,  0 ), which indicates the general progressive tendency of the broken contour line from this starting point, let β is the inclined angle of connecting line between P and  ′ (  ,   ), which indicates the progressive tendency of  ′ similarly.Thus the deviation angle ∆,with ∆ = | − |, could directly reflect the transitional smoothing degree while two matched end points connecting with each other.According to the geometrical properties of contour line, matching and connecting between two end points ought to be gently and smoothing, the acute transitional cases, such as closed angle and acute angle, are disallowed (Figure 4(b) cases with ∆ ≥60°).Therefore, it is very useful to construct max constraint angle condition to control the deviation angle, let φ represent max constraint angle, which can help to control local transitional smoothing degree, and avoid abnormal transitional cases effectively, like closed angle, acute angle and so forth.contour line's shapes in the whole map are various and complicated, then setting single max constraint angle is deficient and not comprehensive enough.If the value is much bigger, this means that the constraint is too loose and liable to lead to intersecting errors.On the contrary, much smaller value would exclude a lot of end points which seem to be against to the condition but is fit for matching and connecting.So it is necessary to build a flexible mechanism to strength applicability, for this purpose, we propose max constraint angle control mechanism based on the gradient ranks.This mechanism's main idea is: firstly, build a max constraint angle dataset  = { 0 ,  1 ,  2 , … ,   }, with   ( = 0,1,2, … , ) is an incremental element in T; then use   as a fixed value to control transitional smoothing degree between two end points; next, move   to next element to control unsolved end points until the last element φ_n has been used.On one side, the dataset T should be flexible and comprehensive based on considering all complicated cases of the whole binary image, each element's value is ascending step by step, and restrain the smoothing degree from small to large.On the other side, each element   implies the local transitional smoothing degree under a fixed range.As we see in Figure 5, T could be constructed according to whole map's morphological characteristics, for example, set  = {0°, 20°, 30°, 45°, 50°, 60°}, then Figure 5 shows a variety of transitional morphology under different deviation angles.When   ≤ 45°, the transition between two match end points is suitable and conforms to common cases; when 45°<   ≤ 60°, the transition is unnatural and liable to cause errors, decision should be cautious when using this scope; when   >60°, the transition is extremely steep, that is to say {  } should be smaller than 60°.

Fig. 5. Different smoothing degree under gradient ranks' max constraint angle
In fact, this mechanism firstly focuses on the most gently and simple broken contour lines, and intends to accomplish those end points' matching; thereafter, it increases max constraint angle value to solve the remaining end points gradually.So this mechanism realizes a procedure from simple to complex, from gently to steep, reveals local and global geometrical properties of contour lines, could eliminate intersects and other errors.

Combination of weighted Euclidean distance and angle to compute matching measurement
Previous processing algorithms have guarantee smooth transition when connecting matched end points, but there is still not a ultimate measurement indicator for completing right matching between either end points and reserved end points.In other words, it is of crucial importance to design an algorithm to provide ultimate measurement indicator.As we all know, distance and deviation angle are the two primary impact factors, whereas Samet's method (Samet and Hancer 2012) use the minimum y-ordinate distance as ultimate measurement indicator to decide optimal match end point.That algorithm is simple and computational-cost is very low, though, the results are unreliable.For example, the minimum y-ordinate distance is not equal to minimum spatial distance, conversely the minimum xordinate distance may be very large, so Samet's method is likely to cause wrong connections (See in Figure 2 red drawing).Euclidean distance is the actual plane distance, and is superior to y-ordinate distance when judging near and far, at the same time, computing accuracy is improved dramatically.In this paper, the y-ordinate distance is replaced by Euclidean distance.On this basis, we propose an algorithm which could gain a quantitative comparison measurement to determine optimal match end point based on weighted combination of Euclidean distance and deviation angle.This algorithm set weightings on Euclidean distance and deviation angle partly, and combine them to compute a reference value, which is set as a quantitative comparison measurement, and the minimum value gained from all values assigns the optimal matching end point.Distance's weighting and deviation angle's weighting reflect its importance and influencing factor in the computing of matching measurement.The more approaching to each other, the more possible it is to match successfully; the smaller the deviation angle is, the more smoothing the transition of connection is.All in all, the minimum matching measurement has its reasonability and validity.The main idea of this algorithm is: computing the Euclidean distance   and deviation angle ∆  between the center end point P_0 and the chosen end points   ( = 0,1, … )firstly; next computing the value ,   by combining weighted distance and deviation angle; at last, detect the matched end points by chosing   = min{  }( = 0,1, … ).Finally,   may be discretized with formula (5): = ∆σ  *  1 +   *  2 ( = 0,1, … ) (5) Let  1 represents deviation angle's weighting, represents Euclidean distance of  0   , , w 2 represents distance's weighting.The measuring units of distance and angle are different, and directly combining operation is disallowed.It is essential to convert angle to distance to make them to be under the same measuring unit, so we finish this conversion.The main idea of the conversion is: ( 1 replace the deviation angle with arc length to compute matching measurement.The converting formulas are below (6) (7): =   *  1 +   *  2 (7) Let r represents a given circle radius, ∆  represents converted central angle,   represents arc length.Generally, the weightings  1 and  2 assigned to distance and angle should flexible and variable.Gradient ranks' max constraint angle mechanism controls transitional smoothing degree effectively and excludes a lot of end points with acute angle, then more attention should be paid to spatial distance near or far, in case of long distance cause intersection and other errors.Therefore, distance's weighting should be emphasized and superior to angle's weighting, the latter is a beneficial supplement to the former.For example, set  1 = 0.2,  2 = 0.8.These two values should be varied according to the matching results.

Bidirectional control based on parabola
Although previous algorithm and mechanism focus too much on right matching and smoothing transition from global to local, they are insufficient to deal with end points presenting acute angle parabola shape(Fig1(b) marked by black rectangle).After color map's scanning and segmentting, there are a lot of end points presenting acute angle parabola shape in binary image.In Samet's method, clockwise end points' direction codes matching algorithm was designed and applied to solve this problem.But only part of these end points have been solved, a lot of end points at counterclockwise direction can not be solved and are liable to lead to errors.Bidirectional codes matching algorithm based on parabola shape is put forward in this article.Its main idea is to extent clockwise and counterclockwise bidirectional codes matching (see Fig6 and Table 1), in order to improve the accuracy and comprehensiveness in direction codes matching.This algorithm is an important supplement to solve complicated and acute parabola end points, raising completeness rate of whole image effectively.Step6: Use bidirectional parabola shape end points' direction code matching algorithm to reconnect end points which possess the feature of acute angle parabola.
Step7: Results are summarized and programe exit.

Experiments and analysis
In order to test the effectiveness, stability and applicability, the proposed method has been applied to many different samples for analyzing and comparing with other methods.Due to the paper's length limit, three images of relatively complex topographic maps in different quality are used in this paper, and the experimental results' evaluations are presented from two aspects: one is qualitative evaluation, the other is the analysis of measurement indicators, including the number of finished connections, number of false connections, completeness rate, accuracy rate, etc.We have used Samet's method and proposed method to process three typetical images respectively.Although  (5) completeness rate; and (6) accuracy rate.Here let  represents the number of total gaps,  1 represents the number of filled gaps,  2 represents the number of not filled gaps,  1 represents the percent of reconnected number,  2 represents accuracy percent.In general, T is very difficult to be obtained from contour lines' images automatically, which is acquired manually;  1 could be recorded in processing automatically; and  2 merely could be acquired by checking the original image and resulting image manually.The formulas of computing  1 and  2 are given below (8) (9): | 1 | (9) Analysis and comparision results of proposed method and Samet's method are given in Table 2, and all the numerical indicators come from previous three experimental samples (Fig 8,Fig 9 and Fig 10).Table 2 Analysis and comparision results of proposed approach and Samet's method

Conclusion
In this paper, a novel method is proposed for reconstruction of broken contour lines.Because all existed techniques and methods can still not get satisfactory results yet, the proposed method is dedicated to achieve good stability and effectiveness in processing different quality images.This method designs and utilizes a series of key algorithms and mechanisms based on the geometrical and topological properties of contour lines.
The excellent contribution of the proposed method is that it can eliminate the errors of other methods, increase the accuracy and completeness rate in end points' matching and reconnecting effectively.For the difficult gaps which hold acute angle parabola, proposed method utilizes bidirectional parabola control algorithm to solve this problem.At last, comparative experiments between proposed method and the other representative Samet's (b)).

Fig . 3 .
Fig .3.(a) go back with too little pixels; (b) go back with too much pixels; (c) multiple incremental back-tracing; (d) the algorithm of multiple incremental back-tracing.

Fig. 4 .
Fig. 4. (a) Max constraint angle's computation; (2) End points' connecting and transitional cases The formula for computing deviation angle and max constraint angle condition may be expressed as shown below (4): ∆ = | − α| <  (4) The condition of max constraint angle focuses too much on single end point's local constraint, lacking of global controlling function based on whole map.Maybe a given max constraint angle could solve part of broken contour lines' transition when connecting them, but the caps and

Fig
Fig 6.Bidirectional matching of end points based on parabola shape End point direction's code Fig7(b), Fig8(b) and Fig9(b) demonstrate that Samet's method could implement reconnecting most of broken contour lines, obvious errors(marked with black circle), for example intersects and failing to fill up bigger or steep caps, are still unresolved.On the contrary, Fig7(c), Fig8(c) and Fig9(c) indicate that the proposed method has almost reconnected all the broken contour lines, especially realized matching almost all end points with each other correctly, and the little remained unconnected broken contour lines hold steep parabolas (marked with black rectangle).
Step5: Judge whether all max restrained degree ranks have been traversed, if yes go to Step 6, else set   =  +1 , go to Step 4.