Page 1 of 1
Convert gray content of gray/white image to black ?
Posted: 2013-10-20T14:56:29-07:00
by Rye
Well, let's say I have this picture:
Let's assume I want to change all the gray color in this picture to plain black.
Is there a command to have imagemagick change all grey of this image (preferableby using grey [Hex: C8C8C8] to black [Hex: 000000] ?
I ask for a way to use the color value itself so I could use this code on more complicated examples in future.
[spoiler]
For example changing a certain yellow tone in this image to a special orange or something[/spoiler]
Re: Convert gray content of gray/white image to black ?
Posted: 2013-10-20T15:30:50-07:00
by snibgo
For that image:
Code: Select all
convert Clipboard01.png -auto-level p.png
Sometimes contrast-stretch works better, or level, or level-colors.
See
http://www.imagemagick.org/script/comma ... ptions.php
Re: Convert gray content of gray/white image to black ?
Posted: 2013-10-20T15:51:40-07:00
by Rye
Is this also possible by using the HexCodes I mentioned
Re: Convert gray content of gray/white image to black ?
Posted: 2013-10-20T16:28:17-07:00
by snibgo
Code: Select all
convert Clipboard01.png -level-colors #c8c8c8,white p.png
Re: Convert gray content of gray/white image to black ?
Posted: 2013-10-20T17:55:11-07:00
by fmw42
Code: Select all
convert Clipboard01.png -fuzz 10% -fill black -opaque "#c8c8c8" result.png
change the fuzz value to whatever works best
Re: Convert gray content of gray/white image to black ?
Posted: 2013-10-21T22:11:50-07:00
by anthony
That latter (using -opaque) is probably not good as the image is full of shades of gray, and -opqaue is a boolean (all or nothing) type operator.
-level-colors will give ber find control over the transformation. -level will give grayscale control -normalize and -auto-level will automatically maximise contrast (though with different 'level' selection)
Re: Convert gray content of gray/white image to black ?
Posted: 2013-10-22T11:33:12-07:00
by Rye
Ok, this works really well. Thanks.
Another question:
If I wanted to change from one hex code to a specific other one.
What woudl I have to change in that code of yours ?
Re: Convert gray content of gray/white image to black ?
Posted: 2013-10-22T11:41:08-07:00
by fmw42
Code: Select all
convert image -fuzz XX% -fill "newhexcode" -opaque "oldhexcode" result
Re: Convert gray content of gray/white image to black ?
Posted: 2013-10-22T12:12:54-07:00
by Rye
Thanks ! Just what I was looking for!
Re: Convert gray content of gray/white image to black ?
Posted: 2013-10-22T12:38:56-07:00
by fmw42