I have GPS route drawn on raster map with red color (nothing else is exactly #ff0000 red in image).
I would like to find out how to make each pixel neighbouring red pixel also red. Or any other way to make this route more visible.
Small example picture:
Thanks for any hints.
Making 1 px wide routeline wider
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Making 1 px wide routeline wider
I have renamed your input map as "mapRedPath.png".
The following Windows BAT command make a copy. For that copy, it turns red into white and everything else black. It thickens the white line. Then it makes black transparent, and turns white into red. The result is composited over the map.
This works with any colour of path. As "red" uses a single channel, it could probably be optimised.
The following Windows BAT command make a copy. For that copy, it turns red into white and everything else black. It thickens the white line. Then it makes black transparent, and turns white into red. The result is composited over the map.
Code: Select all
convert ^
mapRedPath.png ^
( +clone ^
-fill Black +opaque Red ^
-fill White -opaque Red ^
-morphology dilate disk:1 ^
-transparent black ^
-fill Red -opaque White ^
) ^
-compose Over -composite ^
m.png
snibgo's IM pages: im.snibgo.com
Re: Making 1 px wide routeline wider
Thanks! This works brilliantly.
Morphology seems to contain many interesting tools for neighborhood which I was unable to find myself.
Morphology seems to contain many interesting tools for neighborhood which I was unable to find myself.