12

I have seen how to convert a picture from color to grayscale in this Super User question and answer thread. However, grayscale is not black and white.

Simply put, if a field has color, I want to convert it to black. All other areas should be white. So, if a line 6 pixels thick is orange, the other thread's answer will turn the line gray. The line should be turned solid black.

However, is there a way to convert anything of any color at all (not white) to black?

I am working with Engineering prints, and it simply needs to be black or white. Gray does not work, because certain color lines become “gray” lines.

Sablefoste
  • 301
  • 1
  • 3
  • 8
  • 2
    I am not sure I understand what your question is. – Ramhound Mar 24 '15 at 17:46
  • 1
    Why does the answer in the linked question not work for you? – DavidPostill Mar 24 '15 at 17:49
  • @DavidPostill, please see my updated question. How to convert a solid orange line to a solid black line (not a solid gray line). I know gray is just black pixels mixed with white pixels, but this is not where I want it to go... – Sablefoste Mar 24 '15 at 21:54

1 Answers1

13

How do I convert from color to true black and white?

If a field has color, I want to convert it to black.

Use the following command:

convert <input> -negate -threshold 0 -negate <output>

Threshold Dithering Methods

Threshold Images

The simplest method of converting an image into black and white bitmap (to color) image is to use -threshold. This is actually a simple mathematical operator that just provides a cut-off value. Anything equal to or below that value becomes black, while anything larger becomes white.

...

If you actually want to convert all non-pure white colors to black, then I recommend that you threshold the negated image instead of trying to work out the right threshold value to use (one less than IM's current 'MaxRGB'), a value that is dependant on your specific IM's compile time in Quality, or 'Q' setting.

convert logo.png -negate -threshold 0 -negate threshold_white.gif

Source Threshold Dithering Methods

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
  • 2
    It does work! Now, I have to figure out how to remove the pixelation noise of the "close to white". Thank you for your response. – Sablefoste Mar 25 '15 at 12:51