Seth, you're way ahead of me with your thoughts and methods on this, but I might offer an easier, but less precise, alternative.

As you point out, Brent probably wants to include those areas the road obscures. Since the roads are pretty narrow, one could get fairly accurate results by simply selecting the green, growing the selection by 2, and shrinking it by 2. That would force inclusion of the roads in areas they traverse. It would have the unwanted side-effect of also including small non-green areas of approximately 4 pixels in diameter. Whether that would matter or not I'll let Brent chew on, but in looking at the sample map it's pretty good.


On 1/25/2012 3:10 PM, Seth Burgess wrote:

I expect that you want more than just the green selection - you want
what the green selection would be if there were no roads/other data
overlaid, right?

The best way I can do this in a reasonably automated fashion is:

1) Extract the roads as a selection
1-a) Colors->Components->Decompose, RGB, delete all but Green channel
1-b) Levels, adjust so that only roads are black and everything else is
white (be fairly generous with what you call a road - a little slop is
better than too little road)
1-c) Copy (control-C)
2) Back in original image, Create a new layer, transparent, select it as
active layer.
3) Quick Mask
4) Paste (Control-V), Anchor (Control-H)
5) Quick Mask off
6) Select->Invert
6) Select->Grow (2)
7) Fill with white (drag from toolbox)
8) Select->None

At this point you should have 2 layers; the top has all the roads
covered by white, and the bottom your original map image

9) Run the G'MIC plug-in (probably a separate download, google for it),
select Region Inpainting, OK with defaults
Wait a few seconds, and you now have a map that has just green and grey
regions with no red or hints of roads.
10) Delete the top layer that's no longer useful.

At this point the problem of extracting what you really want (an
in-filled green image) can begin.  Its a bit messy with your image due
to compression artifacts, but you can get decent results doing a Select
by Color with threshold=28, then Select->Shrink(1) followed by
Select->Grow(1) to get rid of the smallest objects, but there's still
some garbage in the final results.  Color-To-Alpha with white and then
black can also produce a semi-transparent image, but its got a lot of
noise (other colors existed in the image that are now
really noticeable).  Experimenting with Posterize or other color
reduction/smoothing may be beneficial too, just to remove compression

This isn't suitable for anything scientific - the infill process is
certainly making guesses based on surrounding data which just doesn't
exist in the image - but hopefully it'll get you at least part of the
way to where you want to be.  You could script most of this once you
find values that work for you (though figuring out the G'MIC plug-in may
be tough as it just takes a string input in non-interactive mode).

Happy GIMPing,

Seth Burgess
gimp-user-list mailing list

Reply via email to