Discussion:
Converting colored areas to b/w hatchings with outline
BPJ
2011-04-18 12:15:45 UTC
Permalink
I have a set of images using up to four different colors
contrastively in addition to a white/transparent background
and some black areas/text, and need to convert these to b/w
versions with each color replaced by a hatch/dot pattern,
and preferably with each hatched area outlined with a thin
black border. I know how to replace a color by another color
from the command line but not how to replace a color with a
pattern. However I'm totally at a loss on how to achieve a
black outline around a colored area. Additionally I'd like
to do this in a perl script.

TIA,

/bpj
Anthony Thyssen
2011-04-19 00:49:27 UTC
Permalink
On Mon, 18 Apr 2011 14:15:45 +0200
magick-users-***@imagemagick.org wrote:
|
| I have a set of images using up to four different colors
| contrastively in addition to a white/transparent background
| and some black areas/text, and need to convert these to b/w
| versions with each color replaced by a hatch/dot pattern,
| and preferably with each hatched area outlined with a thin
| black border. I know how to replace a color by another color
| from the command line but not how to replace a color with a
| pattern. However I'm totally at a loss on how to achieve a
| black outline around a colored area. Additionally I'd like
| to do this in a perl script.
|

Replace each color by a grayscale value, then use a DIY
script to map gray values to a image, as per...

Dithering with Symbol Patterns
http://www.imagemagick.org/Usage/quantize/#diy_symbols



Alternativally if the patterns are inclusive, then you can use a full
ordered-dither threshold pattern.

That is the pattern for 75% gray includes the pattern for 50% gray
with just a few more pixels.

Using ordered-dither threshold patterns is a built-in, and you can
define your own threshold patterns.

See the rest of Order-Dither Patterns
http://www.imagemagick.org/Usage/quantize/#thresholds_xml
and
http://www.imagemagick.org/Usage/quantize/#diy_dither

The later goes though the process of generating such patterns.

Note the patterns are stored in your HOME in the file
".magick/thresholds.xml" and as such are not effected by IM updates.
I use them for implementing special dithered effects (like shadows).



Anthony Thyssen ( System Programmer ) <***@griffith.edu.au>
--------------------------------------------------------------------------
Hmm.. Thursday TV viewing...
Golf Channel 2
Racing Channel 9
Footy Channel 10
Arrrrhhhhhh (Present the Sign of the Protection against evil!)
-- Anthony Thyssen
--------------------------------------------------------------------------
Anthony's Castle http://www.ict.griffith.edu.au/anthony/
Anthony Thyssen
2011-04-19 02:26:39 UTC
Permalink
On Mon, 18 Apr 2011 14:15:45 +0200
magick-users-***@imagemagick.org wrote:
|
| I have a set of images using up to four different colors
| contrastively in addition to a white/transparent background
| and some black areas/text, and need to convert these to b/w
| versions with each color replaced by a hatch/dot pattern,
| and preferably with each hatched area outlined with a thin
| black border. I know how to replace a color by another color
| from the command line but not how to replace a color with a
| pattern. However I'm totally at a loss on how to achieve a
| black outline around a colored area. Additionally I'd like
| to do this in a perl script.
|
Sorry for a black outline, run the image thru edge.


convert areas.gif -edge 1 -threshold 20% -negate cracks.gif


Anthony Thyssen ( System Programmer ) <***@griffith.edu.au>
--------------------------------------------------------------------------
" I think we should put some mountains here. Otherwise,
what are the characters going to fall off of? " -- Laurie Anderson
--------------------------------------------------------------------------
Anthony's Castle http://www.ict.griffith.edu.au/anthony/

Loading...