AN IMPLEMENTATION OF AUTOMATIC CONTOUR LINE

Appl. Comput. Math., V.9, N.1, 2010, pp.116-127
AN IMPLEMENTATION OF AUTOMATIC CONTOUR LINE EXTRACTION
FROM SCANNED DIGITAL TOPOGRAPHIC MAPS
R. SAMET1 , I.N. ASKERZADE ASKERBEYLI1 , C. VAROL1
Abstract. This paper proposes a method of implementation of automatic contour line extraction from scanned digital topographic maps. First, color image segmentation is executed to
recognize the features on digital topographic maps, second, morphological and filtering operations are presented to eliminate all unwanted information from digital topographic map except
from contour lines. Then, resolving the terminal and crossed points is processed, finally, matching and reconnecting broken contour lines are proposed.
Keywords: Digital Topographic Map, Contour Line, Color Image Segmentation, Morphological
Operation, Filtering, Reconnection.
AMS Subject Classification: 62H35, 68U10, 94A08.
1. Introduction
Topographic maps essentially consist of color point, linear, and area features to represent
topographic and geographic information about the Earth, or part of it. In topographic maps
the shape of the Earth’s surface is represented by contour lines. Contours are imaginary lines
that join points of equal elevation on the surface of the land above or below a reference surface
such as mean sea level.
A traditional topographic map includes not only contour lines, but also symbols that represent
different features such as buildings, rivers, roads etc. Different features are printed with different
colors. Usually brown is used to depict contour lines. Because of colorific dispersion, paperbased topographic maps own thousands of different colors after it has scanned. This comes into
being the aliasing and false color. Furthermore, contour lines overlapped with other features on
map can also increase extraction difficulty.
Nowadays, many applications require digital maps, such as urban/rural planning, geographic
information systems (GIS), geology, water resources management, satellite imaging, etc. Especially contour lines extraction and recognition is greatly significant for the generation of digital
elevation modeling (DEM) data.
But contour lines extraction is also a tedious and time-consuming process by using manual
techniques and procedures. Research on automated extraction of contour lines has been going
on for many years. However, it is still considerably difficult to achieve accurate contour lines
and clean up all other features from a scanned topographic map.
As Khotanzad referred recently, there are four challenges [12].
1) Aliasing is the major challenge, which is induced by the convolution of the input image
and the scanner’s point spread function [11].
1
Ankara University Engineering Faculty Department of Computer Engineering, Tandogan Kampusu, Ankara,
06100 TURKEY, e-mail: [email protected]
Manuscript received 3 September 2009.
116
R. SAMET, I.N. ASKERZADE ASKERBEYLI, C. VAROL : AN IMPLEMENTATION OF AUTOMATIC ... 117
2) Closely spaced features introduce the second challenge. Features are usually separated by
their background. However, when two features are closely spaced each other, the background is
eroded by the scanner. It results in difficulty to use background to split those features.
3) The existence of false colors is the third challenge due to RGB misalignment in the scanner.
4) Finally, the fourth challenge is intersecting and overlapping of contour lines with other
features on topographic maps.
Most of the topographic maps are not in good quality after they are scanned. In addition, it
can be difficult to segment contour lines because of bad resolution.
In our method we especially try to solve the fourth challenge to extract contour lines accurately
from a common-conditioned topographic map [3] and then we try to overcome the difficulty of
gaps.
This paper is organized as follows. Section 2 presents a brief review of related works about the
contour lines extraction from scanned topographic maps. In Section 3, the proposed method is
described. Section 4 gives an evaluation. Section 5 gives the remaining problems and discussion
part. Section 6 gives conclusion.
2. Related works
Research on automatic contour line extraction has been discussed for many years, thus a huge
amount of publications exist. The main necessary steps in this research topic are (1) topographic
map digitization by scanner, (2) color image segmentation and filtering noisy pixels, (3) thinning
and pruning the binary image, and (4) raster to vector conversion of the resulting thinned lines.
For example, Leberl [13] utilized digitized binary image to vector clean contour and drainage/
ridge sheets. Greenlee [9] attempted to extract elevation contour lines on topographic maps.
Amin [1] attempted to recognize lines and symbols.
For color topographic maps, color information is essential for recognizing its features. Researches are based on color-based maps nowadays with regard to previous years. Steps (2) and
(4) are the main issues and usually most researchers have concentrated on them.
In general, most of the segmentation methods emphasize on color space selection. For example,
in the early periods, Soille used the mean and variance of the hue channel for discriminating soil
types on a digitized soil map [17]. Loh performed color image segmentation and thinned contour
lines [14]. Ebi [5] transformed the input RGB color space into another color space considering
the chromaticity. Classification-clustering techniques are applied to the bivariate histograms
constructed from the results of two chromaticity channels. Spinello [18] quantized the hue–
saturation–value color space and build the hue histogram. The resulting peak near brown (10
30) is referred to the contour lines. Especially, toward the aliased and false colors generated in
map scanning, some new techniques about color segmentation have been developed. Wu used a
multiplayer neural to extract characters and lines from color image [19]. Although this algorithm
took color intensity and gradient into account, it could not overcome the problems of aliasing
and false colors.
To overcome the problems of aliasing and false colors, Hedley developed a gradient thresholding method [10].
In order to improve the segmentation results further, some of them adopted a few filtering
methods to remove the noise. Arrighi [2] used several morphological filters to produce a clean
mask of the contour lines. Mun San [15] applied an edge preserving smoothing method to
discard the noisy pixels. Fuzzy filter, proposed by Samet [16], achieves good noise removal
which preserves and enhances the contour lines.
118
APPL. COMPUT. MATH., V.9, N.1, 2010
Raster-to-vector conversion, i.e., Step (4), also taken as reconnecting the discontinuous contour lines, has received more attentions. Many methods are proposed that can be classified into
three categories: geometric-based approach, image-based approach, and data fusion approach.
The geometric-based approaches transform the problem of raster-to-vector conversion into
curve reconstruction. Spinello used local geometric properties to recognize the contour lines [18].
The algorithm was substantially based on the global topology of a generic topographic map. The
algorithm used Delaunay Triangulation to thin and vectorize contour line. Khotanzad [12], Mun
San [15], and Gamba [7] applied an A* search algorithm or similar to it based on the adjacency
graph to detect and link discontinuous contour lines. Yamada [20], [21] used a Multi-AngledParallel operation algorithm for the extraction of text and symbols on topographic maps. The
algorithm uses directional mathematical morphology method for extraction of contour lines.
The image-based approaches usually conform to perceptual principles, i.e., to decide for closing or grouping two different segments/pixels with two main criteria: proximity and continuity.
Arrighi [2] used mathematical morphology to process contour lines on binary image. The algorithm utilizes propagation function to detect terminal points and then uses a skeletonization
with anchor points to thin contour lines. At last, a combination of Euclidean distances between
terminal points, and differences between their directions are used joining the disconnected lines.
Eikvil [6] used line tracing algorithm technique for contour line reconstruction. When gaps occur
it is assumed that there is only one possible continuation, and the continuation can be found
along the direction of the line. The gap is crossed by searching from the point at the end of
the line within a sector around the current direction. But almost all existing closing algorithm
which are based on perception criteria fail at discontinuity points.
Dupont [4] fused external terrain elevation data to enhance the extraction of contour lines
from a scanned topographic map. The algorithm uses a watershed dividing algorithm in RGB
space to assign a pure map color to each pixel. An expert system resolves ambiguities associated
with broken and closely spaced contour lines, using some local and geometrical rules as well as
orientation information as computed from the external terrain elevation data. This algorithm
performs well for images scanned by high resolution and quality scanners but not for the image
that contains aliased and false colors.
In this paper we used image based approach. We tried to produce a modified approximation
for reconnection algorithm which uses only Euclidean distance between terminal points and
directional information of these terminal points.
3. Proposed method
In this section we propose the method for extraction of contour lines. Our method includes
the following steps:
1) Color image segmentation;
2) Morphological operations and filtering noisy pixels;
3) Resolving terminal points and crossed points;
4) Matching and reconnecting broken contour lines.
3.1. Color Image Segmentation. The color information is useful for recognizing the features
on topographic maps. There are many color spaces existence nowadays, such as RGB, CIE-LAB,
HIS, HSV. The RGB color format is in common use in digital images. The primary reason for
this is because it possesses compatibility with computer displays.
R. SAMET, I.N. ASKERZADE ASKERBEYLI, C. VAROL : AN IMPLEMENTATION OF AUTOMATIC ... 119
Generally contour lines are brown linear features. If they are presented in single pure color,
it is easy to extract them from a topographic map. But the color of contour lines is often
changed more or less in contrast to their background due to color aliasing and falsity on the
whole topographic map. Moreover, the value of the linear feature pixels in the gray image is
usually low but that of background is high, so that they can be separated easily by thresholding.
But the gray segmentation also has a problem that different linear features are not easy to be
distinguished clearly, such as both grid lines and contour lines have low gray values compared
to the background. Sometimes the pixel values are very similar and it becomes difficult to find
the grey level values of contour lines.
In topographic maps we have to handle with a standard set of colors. Since contour lines
are represented with brown color, we declared some ranges by RGB values for extracting brown
color so that we could get the contour lines. However, if the map is blurred and not pure a much
more complex algorithm must be applied for color segmentation. The result of color image
segmentation is shown in Fig.1. Fig.1 a and b show the original image and image after color
segmentation, respectively.
Figure 1.
3.2. Morphological Operations and Filtering Noisy Pixels. After color segmentation we
apply some morphological operations. There are four steps: 1) converting RGB image to binary
image, 2) dilation, 3) median filtering, 4) thinning. After these morphological operations we
filter noisy pixels.
3.2.1. Morphological Operations.
Converting RGB image to Binary Image. We convert RGB image into binary image so
that the image can be represented with two values; “logical 1” representing white for background
and “logical 0” representing black for contour lines. By converting RGB image shown in Fig.1
b into binary image we get the image shown in Fig.2 a.
Dilation. After color segmentation we can see some holes between pixels that represent contour
lines. Morphological filters allow us to produce a clean mask of the elevation contour lines.
Dilation operation is used for removal of all holes within the contour lines with filling of all one
pixel thick gaps. By applying dilation to the image shown in Fig.2 a, we get the image shown
in Fig.2 b.
120
APPL. COMPUT. MATH., V.9, N.1, 2010
Figure 2.
Median Filtering. Two-dimensional median filtering is used to simultaneously reduce noise
and preserve edges. Median filtering is a nonlinear operation often used in image processing to
reduce ”salt and pepper” noise. Median filtering is more effective than convolution when the
goal is to simultaneously reduce noise and preserve edges. By applying median filtering to the
image shown in Fig.2 b, we get the image shown in Fig.2 c.
Thinning. Last morphological operation which will be applied is thinning. Thinning algorithm
allows us to reduce the segmented image to the lines of a single-pixel thickness, while preserving
the full length of those lines (i.e., pixels at the extreme ends of lines should not be affected) [8].
The thinned contour line segments are shown in Fig.2 d. We apply thinning so that we can find
the terminal points which are necessary to reconnect the broken contour lines.
3.2.2. Filtering Noisy Pixels. When we look at Fig.2 d which shows the image after thinning operation we see some unwanted pixels which are not related with contour lines. Some
reasons such as overlapping between contours and other features, quality of the map etc. causes
distortion of different color features in digital map (Fig.3).
Figure 3.
Therefore it causes noisy pixels after color segmentation. These pixels have to be eliminated.
The special property of contour lines can be utilized to do this. The property is as following.
R. SAMET, I.N. ASKERZADE ASKERBEYLI, C. VAROL : AN IMPLEMENTATION OF AUTOMATIC ... 121
Contour lines form closed loops and/or end at physical edges of the image. So there is not
any terminal point in an accurate contour line. If two ends of a line drop into the inner of the
image, this line is not a contour line and can be removed directly.
In order to delete small line segments, we applied masks to remove them. 11 by 11 masked is
used to eliminate the noisy pixels which locate in larger areas. Then 5 by 5 mask is applied to
eliminate the noisy pixels in small areas especially between closely spaced contour lines. Fig.4
shows 5 by 5 mask which is used for this purpose.
Figure 4.
The logic of this mask can be explained easily. In Fig.4 there is a 5 by 5 mask which includes a
region filled with small dots. The sixteen outer pixels of the mask are shown by white boxes and
we assume all these pixels in this region are “logical 1” (background color) and if any number
of pixels locate in the region filled with small dots with value “logical 0”, we delete these pixels
in this region. As a result noisy pixels and small parts are eliminated. The logic of the 11 by 11
mask is the same as this one.
Unfortunately this operation also deletes some parts of contour lines, especially broken contour
lines with small length. But it is much more preferable than these noisy pixels. If they are not
eliminated they can be regarded as if they were broken contour lines and then perceived as
terminal points. This is an undesirable situation. The result of masking these pixels is shown
in Fig.2 e.
3.3. Resolving Terminal Points and Crossed Points. After we applied some morphological
operations and filters to the image we get the thinned image. When the segmentation resulting
image is thinned to eight-connected lines, at the place where a gap or thick line occurs, there is
a pair of terminal points or a crossed point defined as follows.
• The terminal point (end point) is that its five consecutive neighbours have background color
and at least one of three remaining neighbours belonging to lines (Fig.5 a).
• The crossed point is that its eight neighbours have at least three points belonging to different
lines (Fig.5 b).
122
APPL. COMPUT. MATH., V.9, N.1, 2010
Figure 5.
Before finding the terminal points to reconstruct contour lines we have to solve the problem
of crossed points. To delete these crossed points we used the global property of contour lines
not found in other linear features. This special property can be utilized remove those error lines
(crossed point). This property is as following:
• No matter how closely spaced contour lines are, they will never intersect each other. So
there is not any crossed point in an accurate contour line. If two ends of a line are both crossed
points, this line is not a contour line and can be removed directly.
To delete the crossed points we used 3 by 3 masks to whole image to detect the crossed
points. Since a contour has to move in one direction we deleted the pixels moving in two or
more directions.
Other problem is terminal points. To get exact contour lines we have to find terminal points
and match the related terminal points and reconnect them. For finding terminal points 3 by 3
masks are used. We look the 8 neighbours of the central pixel and check the pixel values in the
mask region so that we decide if the pixel at the centre is a terminal point or not. The masks
we apply to find terminal points are shown in Fig.6.
Figure 6.
As it can be seen from Fig.6 we can also decide the directional information of the terminal
points by the help of the masks. In Fig.6: “1” indicates background color (white); “0” indicates
line color (black) and at least one of three pixels shown by “X” is black. There are four rotations
for the terminals. We can simply say that if the pixel values in the mask region suit any of these
masks its rotation can be found. Direction is right for mask (a); left for mask (b); up for mask (c)
and down for mask (d). As a result we could get the coordinates and the directional information
of all terminal points.
R. SAMET, I.N. ASKERZADE ASKERBEYLI, C. VAROL : AN IMPLEMENTATION OF AUTOMATIC ... 123
3.4. Matching and Reconnecting Broken Contour Lines. Our method for connecting
broken contour lines use a combination of a distance and direction criteria and then use them
for connecting broken lines. Euclidean distances between terminal points and the directional
information of the terminal points are used in decision stage when reconnecting broken contour
lines.
Since we know the coordinates of the terminal points and directions of them for each terminal
point we calculate the Euclidean distance and check the rotational information with other terminal points. If the directional conditions are satisfied for reconnection we select the terminal
point which has the smallest Euclidean distance.
While connecting two terminal points we use x and y coordinates of each terminal and reconnect these points using the slope between their coordinates. The result of reconstructed contour
lines is shown in Fig.7.
Figure 7.
4. Evaluation
The proposed method was applied to two standard topographical maps M1 and M2 (Fig.8 a
and c, respectively). These topographical maps are two different regions with different quality
and complexity.
Figure 8.
124
APPL. COMPUT. MATH., V.9, N.1, 2010
We applied the proposed method to above maps with different dpi values. The details of
scanned maps and the processing results for two dpi values are given in Table 1.
Processing time is the time for performing contour lines extraction and reconnection from an
entire map on a personal computer with an Intel Pentium M processor 1.73-GHz and 504-MB
RAM memories. At the result of our applications we understood that by increasing the map
resolution the processing time is increased and the rate of false connections is decreased.
5. Remaining problems and discussion
Strictly automatic processing is not always a possible solution in topographic map recognition.
There are several problems that must be considered with real cartographic maps: poor conditions
and topological errors are two great opponents for the raster to vector process.
If the input image is poor it will be difficult to find a proper classification method.
One problem is that the same color is used to represent contour line elevation numbers (Fig.9).
This characteristic makes automatic approach difficult. This problem may be solved by adding
OCR (Optical Character Recognition) pre-processing.
Figure 9.
Another problem is a topological one and very difficult to detect automatically. This problem
occurs if the elements in the topographic map are with the same color and same characteristics
of contour lines.
As we discussed before there are three approaches when reconstructing the contour lines:
geometric-based approach, image-based approach, and data fusion approach. The major source
of errors is due to the fact that some connections are not successful. Fig.10 shows the problem
of image based reconstruction which is not true.
R. SAMET, I.N. ASKERZADE ASKERBEYLI, C. VAROL : AN IMPLEMENTATION OF AUTOMATIC ... 125
Figure 10.
6. Conclusion
In this paper we have focused on segmentation of the contour lines from topographic maps
and reconnection of broken contour lines.
For color classification, we utilized color segmentation and subsequent thresholding to extract
contour pixels. Mathematical morphological operations such as dilation, filtering and thinning
are used. First we applied dilation so that we could fill the small holes in segmented contour
lines. Then median filter has been adopted to reduce noise and preserve edges. We used thinning
algorithm to reduce the segmented image to the lines of a single-pixel thickness, while preserving
the full length of those lines. In order to delete small line segments and noisy pixels we applied
5 by 5 and 11 by 11 masks and removed them.
To detect and delete the crossed points we used 3 by 3 masks. We deleted the pixels which
move in two or more directions.
We found terminal points by scanning the thinned image. Directional relationships as well
as Euclidean distance information were then used for matching terminal points and connecting
broken line segments. Finally, broken contour lines are reconstructed.
Proposed method contributes to field of automated extraction of contour lines by achieving
accurate contour lines and cleaning up all other features from a scanned topographic map.
References
[1] Amin, T. and Kasturi, R. Map data processing: recognition of lines and symbols, Optical Engineering, V.4,
1987, pp.54-358.
[2] Arrighi, P. and Soilees, P. From scanned topographic maps to digital elevation models, In: Proc. of Geovision’99, Int. Symposium on Imaging Applications in Geology, 1999, pp.1-4.
[3] Chen, Y., Wang, R. and Qian, J. Extracting contour lines from common-conditioned topographic maps,
IEEE Trans.on Goescience and Remote Sensing, V.44, N.4, 2006.
[4] Dupont, F., Deseilligny, M. and Gondran, M. Terrain Reconstruction from Scanned Topographic Maps, In:
Proc. 3rd Int. Workshop Graphics Recognition, 1999, pp.53-60.
[5] Ebi, N., Lauterbach, B. and Anheier, W. An image analysis system for automatic data acquisition from
colored scanned maps, Mach. Vis. Appl., V.7, N.3, 1994, pp.148-164.
[6] Eikvil, L., Aas, K. and Koren, K. Tools for interactive map conversion and vectorization, Proc. of International
Conference on Document Analysis and Recognition, 1995, pp.14-16.
[7] Gamba, P. and Mecocci, A. Perceptual grouping for symbol chain tracking in digitized topographic maps,
Pattern Recognition Letters, V.4, 1999, pp.355-365.
[8] Gonzalez, R. and Woods, R. Digital Image Processing, Reading, MA: Addison-Wesley, 1992, pp.518-548.
[9] Greenlee, D. Raster and vector processing for scanned line work Photogrammetric Engineering and Remote
Sensing, V.10, 1987, pp.1383-1387.
[10] Hedley, M. and Yan, H. Segmentation of color images using spatial and color space information, Electronic
Imaging, V.1, 1992, pp.374-380.
126
APPL. COMPUT. MATH., V.9, N.1, 2010
[11] Khotanzad, A. and Zink, E. Color paper map segmentation using eigenvector line-fitting, In: Proc. IEEE
Southwest Symp. Image Analysis and Interpretation, 1996, pp.190-194.
[12] Khotanzad, A. and Zink, E. Contour line and geographic feature extraction from USGS color topographical
paper maps, IEEE Trans. Pattern Anal. Mach. Intell., V.25, N.1, 2003, pp.18-31.
[13] Leberl, F., Olson, D. Raster scanning for operational digitizing of graphical data, Photogrammetric Engineering and Remote Sensing, V.4, 1982, pp.615-627.
[14] Loh, L.M. and Yatim, S.M. Extracting contour lines from scanned topographic maps, In: Proc. of the
International Conference on Computer Graphics, Imaging and Visualization, 2004, pp.187-192.
[15] Mun, San, L., Mat, Yatim, S., Azam, Md, Sheriff, N. and Isrozaidi bin Nik Ismail N. Extracting contour
lines from scanned topographic maps, In: Int. Conf. CGIV’2004.
[16] Samet, R. and Namazov, M. Using Fuzzy Sets for Filtering Topographic Map Images, Int. J. Appl. Comput.
Math., V.7, N.2, 2008, pp.242-254.
[17] Soille, P. and Ansoult, M. Automated basin delineation from digital elevation models using mathematical
morphology, Signal Processing, V.20, 1990, pp.171-182.
[18] Spinello, S. and Pascal, G. Contour line recognition from scanned topographic maps, J. Winter School
Comput. Graph., V.12, 2003, pp.1-3.
[19] Wu, J., Yan, H. and Chalmers, A. Color image segmentation using fuzzy clustering and supervised learning,
Electronic Imaging, V.3, 1994, pp.397-405.
[20] Yamada, H., Yamamoto, K. and Hosokawa, K. Directional mathematical morphology and reformalized hough
transformation for the analysis of topographic maps, IEEE Trans. Pattern Analysis and Machine Intelligence,
V.15, 1993, pp.380-387.
[21] Yamada, H., Yamamoto, K. and Saito, T. Recognition of elevation value in topographic maps by multi-angled
parallelism, Pattern Recognition and Artificial Intelligence, V.8, 1994, pp.1149-1169.
Refik Samet , for a photograph and biography, see Appl. and Comput. Math. V.7, N.2, 2008, p.254.
Iman Askerzade Askerbeyli - received the BS
and MS degrees in Theory of Oscillation Department (Electronic Section) from Physical Faculty
of Moscow State University in 1985. He received
the Ph.D. (1995) and Dr. Sc. (2004) degree in
condensed matter physics from the Institute of
Physics of the Azerbaijan National Academy of
Sciences. He is an associate professor in the Department of Computer Engineering, Ankara University, Turkey and leading scientific researcher
in Institute of Physics of the Azerbaijan National
Academy of Sciences.
He is associate member of Abdus Salam International Center for Theoretical Physics (Trieste, Italy). His
current research interests include computational condensed matter physics, fuzzy logic and quantum computing.
R. SAMET, I.N. ASKERZADE ASKERBEYLI, C. VAROL : AN IMPLEMENTATION OF AUTOMATIC ... 127
Ceyda Varol - received the B.S. degree in
computer engineering from Ankara University
Computer Engineering Department, Ankara,
Turkey in 2008. She is currently working as a
software engineer in a company which works in
the field of automatic fare collection with smart
card technology and vehicle tracking systems.