It is currently Tue Jul 23, 2024 4:27 am


All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Binary GIMP and scripts for vectorization of features
PostPosted: Mon Jan 06, 2014 3:44 am  (#1) 
Offline
New Member

Joined: Jan 06, 2014
Posts: 1
This is both a question for people more gimp-savvy than I am, and hopefully helpful information to those who are less gimp-savvy than I am. Let's get this sorted!

I am interested in processing raster maps to vectorize them and create .kml files (a Google-earth friendly vector format) of certain linear features, such as trails and bike paths. Think of your local trails .pdf map with the important polylines transformed to vectors that can be read into Google Earth. In short, I need to get my linear raster features cleanly moved into a vector format. I have gotten quite a ways along here, but I decided it was time to ask the gimp experts for advice on preparing my rasters for vectorization. I am thinking that someone has must have set up a scripted gimp environment for this with with all i's dotted and t's crossed?

My main question at this point is summarized as follow: "Is there a standard script or formal workflow to set gimp up to prepare rasters for vectorization?" Everything needs to be in binary mode, so 'pencil' not 'paintbrush', and a hard-edged eraser on call and not a dithering one. Export to a raster format should be cleanly binary.

I can set my vectorization software (ArcScan by ArcMap on a 60-day trial, for now, but there are open source alternatives) to recognize a minimum pixel line width for vectorization. Areas that are 3 or more pixels wide are solid lines--e.g., bike/hike lanes that are not part of city streets. After that, raster line areas that are greater than 0 and less than 3 pixels across are the boundaries of hollow lines--e.g., bike lanes that are part of city streets. (For these thin lines, diagonally-adjacent pixels are generally considered connected.) Dashed lines have their own rules, too: for instance, good vectorization algorithms should be able to continue lines between gaps of a certain minimum width.

The workflow is to take a local trail map converted into a gimp-friendly format (.png, .tif, etc.) and separate the trails from the background crap. Analyzing and cleaning up the results between steps is implied here, but should be minimal. The raster-to-vector component is a different set of tools, of course, but I think folks like me all need to know the cleanest and easiest way to get maps ready for processing.

Here we go:

1) Use gimp to limit the colors in the image as follows: image->mode->indexed->generate optimum palette->maximum number of colors: 16.

In my test case, red raster lines were existing trails, with hollow red lines being part of streets--the centerline is of interest here--and solid red lines being separate; gold lines were unimproved trails (same codes for solid and hollow); purple ones were trails from different agencies; and grey dashed lines were trails planned in the future. White, wheat, blue, light green, black, and a few other colors were used for information I am not interested in extracting as they are readily available from my local GIS agency, if needed;

2) At this point, each color (trail type) should be ready to save as a separate gimp layer;

3) Look for a gimp script for "sg-indexed-decompose." After processing this today (1/6/2014), I am not sure why, but I had to move the new layers out of the script-created group in order to see them;

4) Each layer by color that you need to vectorize should then be exported to its own file and set to binary by:

image->mode->indexed->use black and white palette, or:
image->mode->indexed -> optimum palette of two colors;

There is a difference, I think, but vectorization software might be fussy as to what it expects: trial and error here;

5) Export each layer as its own raster file to vectorize. I used the .tif format;

6) Open your new rasters in your vectorization software and process.

In order to process with ArcScan, the program demanded that I double-click on the .tif filename when adding it and then select only one channel when adding the layer, then set that to unique values in the symbology ("must be computed") or else reclassify into two values. It seemed a bit buggy, but then maybe I need to apply a patch. I an sure I will be further along tomorrow with this at the ArcScan end, but gimp is the area where I really need help. My teenagers are tired of answering my questions.

Perhaps I am laying down the gauntlet here: can you streamline the process to get your local trail map ready for vectorization?


Share on Facebook Share on Twitter Share on Orkut Share on Digg Share on MySpace Share on Delicious Share on Technorati
Top
 Post subject: Re: Binary GIMP and scripts for vectorization of features
PostPosted: Mon Jan 06, 2014 10:15 am  (#2) 
Offline
Script Coder
User avatar

Joined: Apr 23, 2010
Posts: 1553
Location: not from Guildford after all
rodentia wrote:
3) Look for a gimp script for "sg-indexed-decompose." After processing this today (1/6/2014), I am not sure why, but I had to move the new layers out of the script-created group in order to see them;

GIMP does not appear to support Indexed mode images that contain layer groups (I still need to fix the script to handle this scenario). For the moment, I'd recommend converting your image to RGB mode ("Image->Mode->RGB") before running the script. Better still, use my Quantize script in your Step 1). Quantize only affects the active layer and leaves the image in RGB mode.

rodentia wrote:
Perhaps I am laying down the gauntlet here: can you streamline the process to get your local trail map ready for vectorization?

It should be possible to write a script to simplify things, even if the simplification is only combining the steps of multiple scripts into one; for example, a script that runs Quantize, Indexed Decompose, and then saves each layer as TIFF.

Going further, depending upon how you are "separat[ing] the trails from the background crap", it might be feasible to create the requisite vectors with GIMP.

_________________
Any sufficiently primitive technology is indistinguishable from a rock.


Top
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


   Similar Topics   Replies 
No new posts Attachment(s) Export Layers - new features

2

No new posts Measuring facial features.......

5

No new posts Attachment(s) very old scripts

11

No new posts HELP: looking for page with old scripts

2

No new posts Former GIMP Scripts

8



* Login  



Powered by phpBB3 © phpBB Group