* * *

Author Topic: Generating lakeborders with BGRABitmap, how?  (Read 1358 times)

stab

  • Full Member
  • ***
  • Posts: 167
Generating lakeborders with BGRABitmap, how?
« on: January 13, 2017, 02:14:38 pm »
Is there any such functionality in BGRABitmap by which
you can interactivly point in an area with equal rgb-values
in an image, reach the border and create a vector of the border.
Would like to use such a routine to semiautomatically digitize
lakes from a computer generated topografic map(i.e not scanned).

 :-\

Regards
stab

lainz

  • Hero Member
  • *****
  • Posts: 2082
Re: Generating lakeborders with BGRABitmap, how?
« Reply #1 on: January 13, 2017, 02:55:06 pm »
I know that bgrabitmap has direct pixel access, and lazpaint has a magic wand selection tool (select by color). And if I remember well you can make vectors with bgrabitmap.

So the big question is how to put all these stuff together.

If you reach the selection (like with the magic wand) you can make a vector of it taking the most outside pixels as points of the vector.

Here look for some comments on how to use the 'magic wand' stuff:
http://forum.lazarus.freepascal.org/index.php/topic,33928.msg221018.html#msg221018

There is support for SVG
https://github.com/bgrabitmap/bgrabitmap/blob/master/bgrabitmap/bgrasvg.pas

circular is the author of bgrabitmap, hopefully when he come back to the forum can help you better!

stab

  • Full Member
  • ***
  • Posts: 167
Re: Generating lakeborders with BGRABitmap, how?
« Reply #2 on: January 13, 2017, 03:04:37 pm »
Thanks for your reply.

Going to follow your link and read about the "magic wand"

Phil

  • Hero Member
  • *****
  • Posts: 2324
Re: Generating lakeborders with BGRABitmap, how?
« Reply #3 on: January 13, 2017, 04:28:17 pm »
create a vector of the border.
Would like to use such a routine to semiautomatically digitize
lakes from a computer generated topografic map(i.e not scanned).

Converting raster maps to vector shapes (and vice versa) is a common task that most GIS programs can do. Have you considered using GIS software to do this? I assume your topo map is in a standard raster file format that something like the GDAL library can read (it can read just about any raster format). If so, you could try the gdal_polygonize.py script to convert your raster data to polygon shapes in a standard shapefile.

http://www.gdal.org/gdal_polygonize.html

Once in a shapefile you can display the polygons in any GIS, or roll your own with something like the TP4G_Map control for Lazarus:

https://macpgmr.github.io/MacXPlatform/PascalDynLibs_3.html

You could also display the polygons overlaid on a aerial photo in a Web app fairly easily.

https://macpgmr.github.io/MacXPlatform/WebAppOverview_2.html


circular

  • Hero Member
  • *****
  • Posts: 2602
    • Personal webpage
Re: Generating lakeborders with BGRABitmap, how?
« Reply #4 on: January 16, 2017, 12:44:07 pm »
Hello !

You can try the VectorizeMonochrome from BGRAVectorize unit.

You need to supply a bitmap with white background and black shapes on it and it will return a polypolygon, i.e. a series of polygons (separated by EmptyPointF if there is more than one polygon).

So to sum up :
- you have a picture with some shape
- create another bitmap that will contain the black shape on white background : create it with white background and do a ParallelFloodFill
- then call VectorizeMonochrome
- free the temporary black'n'white bitmap

Regards
Conscience is the debugger of the mind

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus