Page 1 of 1
Turning a black and white sketch into a red and white sketch
Posted: 2011-06-07T12:50:14-07:00
by whugemann
I often have to overlay different black and white line drawings in order to compare them. I have done this with Photoshop so far:
1) Turn the vector drawing into a grayscale pixel format.
2) Negate the drawing, such that I have white lines on black canvas.
3) Turn it into a RGB image.
4) Switch off, say, the red channel, such that I have cyan lines on black canvas.
5) Negate the result again, such that I have red lines on white canvas.
Analogously, I turn the other vector drawing into, say, green lines on white canvas and then superpose the two by multiplying them.
I tried to do this with ImageMagick by using -colorspace RGB, -channel ... and -combine, but didn't succeed. All I could make up were cyan, magenta or yellow lines on white canvas, that is a combination of two colour channels. Could someone help me out with the correct Convert command?
Re: Turning a black and white sketch into a red and white sk
Posted: 2011-06-07T13:15:21-07:00
by fmw42
Wolfgang,
If you have grayscale or white lines on a black background and you want to colorize the lines, you can do
convert grayscaleimage +levelcolors black,somecolor newimage
note the +level-colors not -level-colors
see
http://www.imagemagick.org/Usage/color_ ... vel-colors
Hope I understand your question? If not let me know further or provide a link to an example input and output image
If the line is pure white on a pure black background, then it is more direct to do:
convert bwimage -fuzz XX% -fill somecolor -opaque white newimage
the fuzz XX% permits the line to be anti-aliased and not get a halo. Generally a few percent should do, but vary it until you get the results desired. If the line is not anti-aliased, then you can leave off the -fuzz XX%.
see
http://www.imagemagick.org/Usage/color_basics/#replace
Fred
Re: Turning a black and white sketch into a red and white sk
Posted: 2011-06-07T14:04:31-07:00
by el_supremo
If you're starting with black lines on white and want to change the black to red you can use these two options:
-fill red -opaque black
Similarly black to green is:
-fill green -opaque black
Pete
Re: Turning a black and white sketch into a red and white sk
Posted: 2011-06-07T14:09:46-07:00
by fmw42
As el_supremo said, you can start with black lines on white and convert to color lines on black in one command, if you like.
convert image -fill somecolor -opaque black -fill black +opaque white resultimage
Re: Turning a black and white sketch into a red and white sk
Posted: 2011-06-07T23:27:53-07:00
by whugemann
Based on your instructions, I now used the +level-colors operator (which I didn't known so far) and succeeded. I turned black lines on white canvas into red ones on white canvas by:
convert grayscale.jpg -negate +level-colors ,cyan -negate red.png
I will have to look up what I am actually doing there sometimes, but I don't have the time at the moment. I went for the +level-colors option instead of using color substitutions, because in this case I have to deal with JPEG scans and I do not want to experiment with the -fuzz option. Thanks for your advice!
Re: Turning a black and white sketch into a red and white sk
Posted: 2011-06-08T06:23:09-07:00
by whugemann
I've just seen Anthony's solution for the cow picture at
http://www.imagemagick.org/Usage/color_ ... vel-colors. Thus the easiest solution is
convert %1 +level-colors red, %~n1.png
which spares the double-negation.
Re: Turning a black and white sketch into a red and white sk
Posted: 2011-06-08T10:33:23-07:00
by fmw42
Sorry, when I went looking for references for you I tried to find that one, but could not find it for some reason (probably scanned the pages too quickly). It was one I was trying to get for you. Glad you found it.
Fred