Page 1 of 1

Create a solid line from stippled

Posted: 2015-11-17T22:34:59-07:00
by meteorlologist
Hi folks,
I am trying to create a solid border to overlay onto maps. I have a border that is very stippled, comprising of a bunch of dots. Is there any way to "connect the dots" and thicken the line so that I have a solid border to work with? It seems that it should be possible with -morphology but every approach I have tried does not work.

Image


Thanks for the help!

Re: Create a solid line from stippled

Posted: 2015-11-17T23:23:26-07:00
by snibgo
The difficulty here is knowing what is a gap that needs filling, as opposed to a gap between two separate features. Can you say for sure what the gap size is that needs filling?

It looks like a plot from NGIS coastline data or similar, where the software has simply plotted the points without joining them up. And it might have been resized at some time. Getting better data may be a better solution.

Re: Create a solid line from stippled

Posted: 2015-11-18T00:12:37-07:00
by fmw42
Does this help?

Code: Select all

convert oDsSkai.png -morphology erode diamond:1 result.png
If so, see http://www.imagemagick.org/Usage/morphology/

Re: Create a solid line from stippled

Posted: 2015-11-18T00:32:36-07:00
by meteorlologist
I made the borders myself from a satellite image, so there was a lot of noise to try to filter through. This is the cleanest I've been able to come up with, once I got enough "coastline" to be solid I started picking up other data as well (trying to pull these out from a satpic with black or white borders, except the satellite data itself is often white and the land is black!).

I tried using erode diamond but it doesn't seem to make a difference.

Once I have a good coastline, I can re-use it forever. Might just take it into paint and color it by hand the old-fashioned way.

Re: Create a solid line from stippled

Posted: 2015-11-18T10:29:07-07:00
by fmw42
For me, it made the line segments a bit longer and especially darker/thicker. What IM version and platform are you using?

You also can increase the diamond:1 to diamond:2 or use octagon or some other shape kernel.

Re: Create a solid line from stippled

Posted: 2015-11-18T11:45:10-07:00
by snibgo
"-morphology open" may also be useful here.

Re: Create a solid line from stippled

Posted: 2015-11-18T12:09:59-07:00
by fmw42
I originally tried -morphology open, but saw little or no change with diamond:1. I did not try larger kernels. So that is why I just used erode with as small a kernel as I could.

Re: Create a solid line from stippled

Posted: 2015-11-18T13:09:45-07:00
by snibgo
For example:

Code: Select all

convert oDsSkai.png -morphology open disk:1 c.png
This fills some gaps in lines. However, it also fills small areas between lines, which may be undesirable.

I can't see a simple solution, but nor do I understand what result is wanted. If the OP edits a small portion of the image to be what is wanted, this might provide insight.

Re: Create a solid line from stippled

Posted: 2015-11-18T20:45:31-07:00
by fmw42
In IM, I believe your best possibility is -morphology. IM does not have any function to follow lines and fill gaps. There is some code in the Canny edge detector to do some of that, but it relies upon a gradient image and you do not have that. If you started from a map with colored regions, you could try the Canny edge detector. See viewtopic.php?f=4&t=25405

Re: Create a solid line from stippled

Posted: 2015-11-18T20:58:21-07:00
by meteorlologist
Thanks for the advice everyone. After trying several approaches, the solution is that this is a job for human intervention, I'll have to go through my satellite map and manually draw the borders in a unique color, then make all other colors transparent to pull out just the border outlines.

Not the fastest solution but probably the best, I only need one border map then I can overlay it forever. Thanks again for the advice!

Re: Create a solid line from stippled

Posted: 2015-11-19T00:01:49-07:00
by fmw42
If you have a map that is colored regions rather than lines, then -Canny might help create an edge outline.