Create a solid line from stippled
-
- Posts: 3
- Joined: 2015-11-17T22:06:44-07:00
- Authentication code: 1151
Create a solid line from stippled
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.
Thanks for the help!
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.
Thanks for the help!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Create a solid line from stippled
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.
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.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Create a solid line from stippled
Does this help?
If so, see http://www.imagemagick.org/Usage/morphology/
Code: Select all
convert oDsSkai.png -morphology erode diamond:1 result.png
-
- Posts: 3
- Joined: 2015-11-17T22:06:44-07:00
- Authentication code: 1151
Re: Create a solid line from stippled
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.
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.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Create a solid line from stippled
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.
You also can increase the diamond:1 to diamond:2 or use octagon or some other shape kernel.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Create a solid line from stippled
"-morphology open" may also be useful here.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Create a solid line from stippled
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.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Create a solid line from stippled
For example:
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.
Code: Select all
convert oDsSkai.png -morphology open disk:1 c.png
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.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Create a solid line from stippled
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
-
- Posts: 3
- Joined: 2015-11-17T22:06:44-07:00
- Authentication code: 1151
Re: Create a solid line from stippled
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!
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!
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Create a solid line from stippled
If you have a map that is colored regions rather than lines, then -Canny might help create an edge outline.