Making 1 px wide routeline wider

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
zwak
Posts: 4
Joined: 2013-05-21T05:08:55-07:00
Authentication code: 6789

Making 1 px wide routeline wider

Post by zwak »

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:
Image

Thanks for any hints.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Making 1 px wide routeline wider

Post by snibgo »

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.

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
This works with any colour of path. As "red" uses a single channel, it could probably be optimised.
snibgo's IM pages: im.snibgo.com
zwak
Posts: 4
Joined: 2013-05-21T05:08:55-07:00
Authentication code: 6789

Re: Making 1 px wide routeline wider

Post by zwak »

Thanks! This works brilliantly.
Morphology seems to contain many interesting tools for neighborhood which I was unable to find myself.
Post Reply