A Vectorizer for Color Topographic Maps - CiteSeerX

4 downloads 0 Views 72KB Size Report
usually bitmap files. Bitmap files for maps ... paper map. Our work starts with a bitmap file and ends .... have to convert this curves to its Bezier form. 4 .- Character ...
Proceedings of the IASTED International Conference Signal and Image Processing. October 27-31, 1998, Las Vegas, Nevada - U.S.A.

A Vectorizer for Color Topographic Maps Xulio Fernández, Fernando Riveiro, Óscar M. López, Xaime Rial, José V. Oliveira, Fernando Martín. Departamento de Tecnologías de las Comunicaciones. E.T.S.I.T. Universidad de Vigo. Ciudad Universitaria s/n. 36200 Vigo (Pontevedra). Spain. Phone: +34-986-812131. Fax: +34-986-812116. E-mail: [email protected], [email protected], [email protected], [email protected].

add a new road or bridge to a map without redrawing it from scratch. We chose the CAD formats DXF and DWG (the most popular in the CAD world). From now on, we will explain in some detail the different image processing steps we take to perform the whole vectorization process. These processes are: - Color Splitting. - Line Processing. - Line Vectorization. - Character location and preprocessing. Each stage covers one concrete part of the whole process.

Abstract: In this work, we describe a vectorizer for color topographic maps. We dedicate some detail to the processes of color splitting, thinning (and postthinning) of lines and line following. Then we enter the problem of creating a B-Spline curve from a set of points that need to be closely aproximated. Finally, we address the issue of locating and recognizing the characters that are present on the map. Technical Areas (keywords): Machine Vision, Image Understanding, Image Coding and Compression; Other: Pattern Recognition.

1 .- Color Splitting: A topograhic map is made of many lines of different colors. Generally the background color is a bright one and the lines are darker. When we scan a map, we obtain many spurious colors, mainly from line borders. We suppose we have the map as a 256 colors (indexed palette) bitmap. It's not possible to obtain directly a bitmap of this format. Color scanners produce 24 bits per pixel, true color, bitmaps. Nevertheless, it's possible to compute an optimal 256 colors palette for these images. A method is, for example, using the L.B.G. algorithm for vector quantizer design [1] in the color (R,G,B) space. This initial reduction of colors does not imply any loss of color information because the number of different colors in a topographic map is much less than 256 (usually no more than 6 or 8) and makes the final process of splitting much easier. Luminance threshold: The first step to split the colors is removing the background, via a luminance threshold. As the background is brighter than the lines, this is an easy step.

0 .- Introduction: Topographic maps are of great use in areas such as: civil engineering, mobile communications (for coverage computations), architecture... These maps are usually in paper form, and if stored in a digital system, they are usually bitmap files. Bitmap files for maps usually come from the process of scanning one paper map. Our work starts with a bitmap file and ends with a CAD (Computer Assisted Design) File. CAD files are vector files, not bitmaps; id est: they store a set of mathematically defined objects (circles, squares, inserted text, curves with some equation... ) instead of storing a value for each pixel. Vector files have the following advantages (in the context of topographic maps applications): - Vector files need much less storing capability. - Vector files can be scaled to any size with no loss in resolution (it's the same principle of "true-type" fonts). - Vector files can be modified with CAD programs, this is important because we can 281-096

1

automatically. This way of working allows the user to make a fine adjustment for a concrete kind of planes and repeat it automatically for the rest of the planes of the same kind. When the process has finished, the user can decide to join some of the splitted colors. The joining of splitted colors can not be made automatically. This stage is not a fully automatic process, as it needs human supervision.

Generalized erosion: Afterwards, we perform a generalized erosion, id est: we substitute the pixel under study with the darker pixel of a region centered on it (structuring element). The structuring element is a square of size equal to the expected stroke width of the lines. This erosion contributes to make the colors of the line pixels more uniform and darker. The pixels in the center of the lines have a more pure color than the pixels in the borders. Clustering method: Next, we apply a clustering method [2] to the colors in the palette of our image. We define a distance D in the HSV color space. If the distance between two colors is lower than D, we join those two colors into one. The resulting color is computed according to the relative histogram (repetition) values of the two initial colors. Once we are not able to join more color pairs with an specific value of D, we increase D's value (until a limit). The process stops when there are not changes in the image after two processes of increasing the value of D. Not having a change when increasing D’s value means we are in a stable position in the color distribution. This clustering method is automatic and does not need to know which colors is it looking for. This is an advantage over typical clustering methods.

2 .- Line Processing: After the former stage, we have the map divided into some monocolor maps, each of them representing the lines corresponding to one of the colors formerly split. These maps are, of course, bi-level images with only two possible values on each pixel. Our purpose, now, is to identify each individual line, to be able to perform a vectorization algorithm on these lines. Filtering noise: The first processing step is filtering out some of the noise. We remove all the isolated pixels and also the small spots. Thinning algorithm: After that, a "thinning" algorithm is applied [3]. With this algorithm, we should have a stroke width of "one pixel". Post-thinning: Nevertheless, we sometimes have pixel configurations that may represent potential problems for the line following process. Two of such cases are shown in Fig. 2. In the first case the pixel under study can be removed. In the second the pixel must be maintained.

Fig. 2: Post-thinning filtering.

We have designed a set of rules that are able to remove all the pixels that are not essential for connectivity. This process is called "postthinning" [4] and a result of it can be seen in figure 3. Fig. 1: Color clustering on a palette (in the HS domain).

This process is shown to the user, id est: the operator sees the evolution of the color map. The user can stop the process at any time, when the color reduction is what he wants. The interactions with the user can be stored in some configuration parameters in order to repeat the process

Fig. 3: Result of thinning and post-thinning.

2

Classifying the line points: After that, we classify the points in the image into the following classes: points with only one neighbour (end points), two neighbours (line points) and more than two neighbours (intersection points). Line following: We follow the different lines, beginning in the end points and paying special attention to the intersection points. In an intersection it is necessary to determine if it is possible to continue the line after it, and which is the line to follow after the intersection point. The algorithm we use is based in the difference of slopes between all the outgoing lines. We also pay attention to some special cases: like dotted lines and gaps due to noise. Macropoints: Usually the intersections are not so simple as the one in Fig. 3. The number of pixels involved in the intersection are quite more than one (Fig. 4). To deal with these situations we created a data structure called “MacroPoint”. Pixels that make up a “MacroPoint” are treated as if they were a single one.

Fig. 5: Vectorization of three elementary curves.

Internal representation of the lines is always performed using polylines (with all the pixels of the line) or using B-Splines (each line represented by a set of control points). Each kind of curve allows a different precision with a different graphic speed (B-Splines are the most precise and also the slowest, polylines are the less precise and the fastest). For the external graphic representation we can not use B-Splines but we have to convert this curves to its Bezier form. 4 .- Character Location and Preprocessing: We have ignored so far the effects of our processing on the text possibly present on the map. To illustrate these effects we will use an example:

Fig. 4: Examples of MacroPoints (the shaded pixels make up the Macropoints).

This was a point of especial difficulty due to the lack of technical literature on this theme. This part was designed by ourselves at 100%. 3 .- Line Vectorization: After having the individual lines, we perform an approximation of them using cubic B-Spline curves. This method is based on an LMS approach that allows the computation of the optima B-Spline parameters. Basically, this approach consists on writting the equations for an exact spline (and overdetermined system, for which it is impossible to find an exact solution) and finding the minimum error solution (mean square error) [5], [6]. This method is only valid for very smooth curves. If a line has some 'corners' it must be split into different smooth curves, we do that using the SSS algorithm [7].

Fig. 6: Text before color splitting (original map).

If text overlaps with the lines in the map, the text is usually written in black so the color splitting process gets a first separation of text. It only will appear with the black lines.

Fig. 7: Text after color splitting.

3

color splitting (Fig. 7). We activate each pixel that is contiguous to the thinned character if (and only if) that pixel is active in the non-thinned version. Note that we only work with pixels contiguous to the thinned characters, id est: the maximum stroke width after flooding is 3. This flooding process tries to recover the character pixels but leaving out the pixels that are part of the lines crossing over the character. Notice that we also have removed the need for distinguishing between bold and non-bold characters in the recognition step. All the steps so far complete a very specific segmentation process. We will now comment other preprocessing steps that we do at this point to improve the quality of the recognizer input: - We correct the skew angle for each text region. We base ourselves on the character bounding boxes positions. - We detect and correct slant (if necessary). For this we use the central axis of each character. After these processing steps we obtain characters suitable for an O.C.R. stage (clean and very easy to recognize for a human observer). We are now working in the development of this O.C.R.

Fig. 8: Text after thinning and post thinning.

After the thinning we perform line following. This step does not modify the image any more but labels some point sets as “lines”. It is at this point where we start searching for characters. Characters are made of short (often interconnected) and nearby lines. We study all lines in the output of the line processor and we select those ones that may be part of a character. We use two features for this first selection: line size (number of points) and the size of the minimum bounding box for the line. We establish two thresholds over these two numbers to select possible character strokes. Note that with this method, we have removed spurious lines from the map that were overlapping with our text. Afterwards, we want to group the nearby character strokes to get character regions. We obtain the top and bottom point from each stroke and then we join the nearby top and bottom points. Two points are joined if they can be included inside a fixed size box. This size is related to the expected size of the characters.

5 .- Integration: All the former processes are coded in standard C++ and have been embedded into a Windows 95 program. The program has a beautiful and easy to use user interface. Besides the image processing steps, it is also able to get an image from a scanner and to print any of the intermediate images. 6 .- Future Lines: As the first future line, we are already working in an O.C.R. for the recognition of the text that we located in the previous section. We have some experience in designing O.C.R. systems under special conditions [8], [9]. More generally we would improve the general application giving it the possibility to recognize especial symbols widely used in topographic maps, giving a new step towards image understanding.

Fig. 9: Grouping of the strokes that make up the characters “m” and “p”.

Then, we have to group the strokes forming individual characters. For this reason we use again the expected character size. We obtain a set of bounding boxes, each of them contains an individual character (we refine this set removing those boxes that are contained into another one). Flooding the text lines: Applying a recognizer directly on the thinned characters would not yield good results. So we apply a flooding algorithm using information from the bilevel image after

7 .- Conclusions: We have designed a system able to convert map images from raster (bitmap) formats to a 4

vector format. Vector format is more suitable for many applications: civil engineering, map analysis. Besides vector formats allow a more efficient storage of digital maps. The output of our application uses the more common file formats from today’s industry: DXF and DWG. We have not implemented the recognition of the text present in the maps yet. However, we are able to locate text regions (this avoids making the vectorization of the lines forming characters as it is a vanish process) and to segment them into individual characters. A new version with built-in text recognition will be available soon.

Time Recognition of V.L.P.'s (Vehicle License Plates)". Lecture Notes on Computer Science. Springer-Verlag. September, 1997. [9] F. Martín, X. Fernández. "Métodos Avanzados de Reconocimiento de Patrones, Aplicación al Reconocimiento de Matrículas de Automóviles". Accepted for Proceedings of URSI-98. Pamplona (Spain). 1998.

8 .- References: [1] J. Linde, A. Buzo, R. M. Gray. "An Algorithm for Vector Quantizer Design". IEEE Transactions on Communications. 1980. [2] O. M. López, F. Riveiro, X. Fernández. "Separacion de Colores Orientada a la Vectorizacion de Planos Topograficos". Proceedings of URSI-96. Madrid (Spain). September, 1996. [3] J. Parker, C. Jennings, D. Molaro. "A Force Based Thinning Stategy with Sub-Pixel Precision". Department of Computer Science. University of Calgary (Canada). Internal document, made available over the INTERNET. [4] O. M. López, F. Riveiro, X. Fernández. "Procesado Previo al Seguimiento de Lineas: Post-Thinning y Macropuntos". Proceedings of URSI-97. Bilbao (Spain). September, 1997. [5] X. Rial, X. Fernández. "Aproximacion de Contornos Usando B-Splines Cubicos". Proceedings of URSI-95. Valladolid (Spain). September, 1995. [6] P. Saint-Marc, H. Rom, G. Medioni. "BSpline Contour Representation and Symmetry Detection". IEEE Transaction on Pattern Analysis and Machine Intelligence. November, 1993. [7] M. A. Fischler, H. C. Wolf. "Locating Perceptually Salient Points on Planar Curves". IEEE Transactions on Pattern Analysis and Machine Intelligence. February, 1994. [8] X. Fernández, F. Martín, J.L. Lijó, F. Pita, M. Pérez. "A System for the Automatic and Real 5