I have a mask, a background and a foreground image combining them with -compose.
I would like to draw an edge where the black and the white of the mask meet, similar to this example from the manual:'
mask - how to draw edge?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: mask - how to draw edge?
Use -edge or -morphology edge (or edgein or edgeout) on the mask to create a new blank/white edge image. Then use -compose screen to apply it to your previouls result. If done with parenthesis processing, it can all be done in one command line.
see
http://www.imagemagick.org/script/comma ... s.php#edge
http://www.imagemagick.org/Usage/morphology/#edgein
http://www.imagemagick.org/Usage/compose/#screen
see
http://www.imagemagick.org/script/comma ... s.php#edge
http://www.imagemagick.org/Usage/morphology/#edgein
http://www.imagemagick.org/Usage/compose/#screen
- Draoidh
- Posts: 69
- Joined: 2012-07-03T11:29:44-07:00
- Authentication code: 13
- Location: soon to be independent Scotland
Re: mask - how to draw edge?
edgeout after some playing around with the kernels did it for me!
screen only seems useful if you want white text (as per the manual example)?
screen only seems useful if you want white text (as per the manual example)?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: mask - how to draw edge?
Take your white edge image and use it as a mask to overly a negated edge mask in a composite. Negating the edge image makes the edges black on white background, but the original edge images is the opposite and is used as the mask image. see http://www.imagemagick.org/Usage/compose/#compose
convert image \( whiteedge -negate \) whiteedge -compose over -composite result
alternately
convert image \( -clone -fill black -colorize 100% \) whiteedge -compose over -composite result
convert image \( whiteedge -negate \) whiteedge -compose over -composite result
alternately
convert image \( -clone -fill black -colorize 100% \) whiteedge -compose over -composite result
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: mask - how to draw edge?
For more ways see...
IM Examples, Transforms, Edge Outlines
http://www.imagemagick.org/Usage/transform/#edge_jitter
This looks at both anti-aliased shapes, and aliased bitmap shapes, as well as a vector approach.
NOTE drawing an edge is tricky as an edge has a 0 width, BUT lines have a a width of typically 1 pixel. This means a drawn edge may be inside, outside, to top-left of or bottom right of the actual edge. Idealy you would want the middle of an anti-aliased line to match the exact edge.
NOTE: drawn shapes does not draw edges exactly where specified, but at a point 1/2 pixel wider than it should be.
This means two shapes drawn using the same edge overlap by 1 pixel.
See Draw Fill Bounds
http://www.imagemagick.org/Usage/draw/#bounds
IM Examples, Transforms, Edge Outlines
http://www.imagemagick.org/Usage/transform/#edge_jitter
This looks at both anti-aliased shapes, and aliased bitmap shapes, as well as a vector approach.
NOTE drawing an edge is tricky as an edge has a 0 width, BUT lines have a a width of typically 1 pixel. This means a drawn edge may be inside, outside, to top-left of or bottom right of the actual edge. Idealy you would want the middle of an anti-aliased line to match the exact edge.
NOTE: drawn shapes does not draw edges exactly where specified, but at a point 1/2 pixel wider than it should be.
This means two shapes drawn using the same edge overlap by 1 pixel.
See Draw Fill Bounds
http://www.imagemagick.org/Usage/draw/#bounds
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- Draoidh
- Posts: 69
- Joined: 2012-07-03T11:29:44-07:00
- Authentication code: 13
- Location: soon to be independent Scotland
Re: mask - how to draw edge?
Fred, thanks for confirming that the mask -compose approach is the way forward, which is what I did last night.
Anthony, these seem to be endless ways to skin the cat but in my particular case -morphology edge produced good results.
I must say it's damned handy youse two being in different timezones at the furthest away corners of your continents - Fred 8 hrs behind and Anthony 10 ahead! - particularly with me being night-active! ImageMagick covered 24/7.
Anthony, these seem to be endless ways to skin the cat but in my particular case -morphology edge produced good results.
I must say it's damned handy youse two being in different timezones at the furthest away corners of your continents - Fred 8 hrs behind and Anthony 10 ahead! - particularly with me being night-active! ImageMagick covered 24/7.