Convert gray content of gray/white image to black ?
Convert gray content of gray/white image to black ?
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]
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]
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert gray content of gray/white image to black ?
For that image:
Sometimes contrast-stretch works better, or level, or level-colors.
See http://www.imagemagick.org/script/comma ... ptions.php
Code: Select all
convert Clipboard01.png -auto-level p.png
See http://www.imagemagick.org/script/comma ... ptions.php
snibgo's IM pages: im.snibgo.com
Re: Convert gray content of gray/white image to black ?
Is this also possible by using the HexCodes I mentioned
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Convert gray content of gray/white image to black ?
Code: Select all
convert Clipboard01.png -level-colors #c8c8c8,white p.png
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert gray content of gray/white image to black ?
Code: Select all
convert Clipboard01.png -fuzz 10% -fill black -opaque "#c8c8c8" result.png
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Convert gray content of gray/white image to black ?
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)
-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)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: Convert gray content of gray/white image to black ?
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 ?
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 ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Convert gray content of gray/white image to black ?
Code: Select all
convert image -fuzz XX% -fill "newhexcode" -opaque "oldhexcode" result
Re: Convert gray content of gray/white image to black ?
Thanks ! Just what I was looking for!
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC