Replace ALL colors except black-grey scales with white

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Locked
bodomalo
Posts: 6
Joined: 2016-08-15T10:32:47-07:00
Authentication code: 1151

Replace ALL colors except black-grey scales with white

Post by bodomalo »

Hello

I know that it is possible to replace a specific color (like RED) and similar colors (fuzzy:30%) with another color.
convert thing.jpg -fuzz 15% -fill white -opaque "rgb(143,141,250)" -opaque "rgb(216,217,62)" result.png

But:
What I would like to have as a result is, that ALL colors beside black and grey-tones are replaced with white "000000"

Can you give me a hint how to do that?

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Replace ALL colors except black-grey scales with white

Post by snibgo »

Code: Select all

magick in.png ( +clone -colorspace HSL -channel 1 -separate -threshold 0 ) -compose Lighten -composite out.png
snibgo's IM pages: im.snibgo.com

bodomalo
Posts: 6
Joined: 2016-08-15T10:32:47-07:00
Authentication code: 1151

Re: Replace ALL colors except black-grey scales with white

Post by bodomalo »

snibgo wrote:
2020-01-09T09:24:02-07:00

Code: Select all

magick in.png ( +clone -colorspace HSL -channel 1 -separate -threshold 0 ) -compose Lighten -composite out.png
It says syntax error, did not expect a ( sign on that place.....

bodomalo
Posts: 6
Joined: 2016-08-15T10:32:47-07:00
Authentication code: 1151

Re: Replace ALL colors except black-grey scales with white

Post by bodomalo »

magick in.png \( +clone -colorspace HSL -channel 1 -separate -threshold 0 \) -compose Lighten -composite out.png

that worked...looks great, thank you

Locked