3

I am trying to extract the contour lines from colour topographic maps. The goal is to build a 3D demonstration of the area, using an engine developed by me from zero. Untill now everything worked great (making the 3D engine from zero and displaying objects etc.), but now I got stuck...

I have seen many documents describing algorithms for doing such a thing, however - they use a short language which I have a hard time understanding and assume a very strong knowledge of image proccessing.

I would be very pleased if any of you could tell me of a good resource to learn from how to do it, or tell of a sequence of resources which will allow me to combine them into a complete alogrithm. If you know any book which contains a chapter on ther matter, or has descriptions which will allow me to combine some elements in them into my own system, it would be of great help.

If you know of someone who did a similar thing - it would also help me to know him.

Thanks in advance !

Justin
  • 1,881
  • 4
  • 20
  • 40
Nati Cohen
  • 230
  • 4
  • 11

2 Answers2

1

You can use GDAL library which provides API for generating contours from raster. See GDALContourGenerate function. If you want to learn about algorithms details, just take a look into the source code of GDAL.

You also can experiment with this GDAL capability using command line utility: gdal_contour

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
mloskot
  • 37,086
  • 11
  • 109
  • 136
  • This is an interesting answer. I have downloaded GDAL and tested its Contour extraction. it gave an output of a .shp file. I looked at it with Shape Viewer and it looks promising, even though there were some errors in my test. – Nati Cohen Oct 25 '11 at 22:28
0

We do all our 3D terrain modeling from USGS DEM (Digital elevation model) files.

Edit: Convert your scanned images into grayscale and increase the contrast until you have the contour lines and not much else (either via image editing software or programmatically). At this point your lines should be black. Scan through the pixels and record all the black pixels that border other black pixels.. say you need a match of at least two other bordering pixels. You could also apply some kind of volume formula to each saved region.. say.. anything less than 50 contiguous pixels is thrown out.

Sam Axe
  • 33,313
  • 9
  • 55
  • 89
  • Thank you Boo. However, this was not my question. I need to extract the contour lines from scanned 2d maps using regular image formats such as jpg or bmp. – Nati Cohen Oct 25 '11 at 21:13
  • It was a diffent way to go about it. I was suggesting that you recreate the contour lines from DEM instead of scanned images. However, if you really want to go with images, then I will ammend my answer. – Sam Axe Oct 25 '11 at 21:16
  • Thanks again Boo. I have checked with Photoshop the proposed algorithm you described (on an image from Wiki). It does help masking the contour lines from the background. I believe that with the combination of some other filters and some algorithms which I have seen described in some documents - I can get a good result. – Nati Cohen Oct 26 '11 at 09:31