How to remove or make transparent all but one single color.
How to remove or make transparent all but one single color.
I'm attempting to save an alphabet of bmps (or any format) of some all gray text characters and numbers that I have to screen capture in front of various backgrounds. The characters are always the exact same shade of Gray (0xC0C0C0C). Is there a way to remove or make transparent all colors that don't match this shade of gray? This is for optical character recognition purposes.
Cliff Notes: I want pure gray solid characters and to remove all background colors.
Cliff Notes: I want pure gray solid characters and to remove all background colors.
Re: How to remove or make transparent all but one single color.
Try this:
Code: Select all
convert original_image.jpg -matte ( +clone -fuzz 20% -transparent rgb(38,134,71) ) -compose DstOut -composite output.png
Re: How to remove or make transparent all but one single color.
I appreciate the response. I'm unaware of where to download a compiled version of the beta (I no longer have the compiler to compile the beta on my own). I've searched the faq and googled, etc-- is there a location to download a compiled version of the betas that runs on XP?fmw42 wrote:see viewtopic.php?f=3&t=11298
Re: How to remove or make transparent all but one single color.
Thanks, I will try this tonight as well.Bonzo wrote:Try this:Code: Select all
convert original_image.jpg -matte ( +clone -fuzz 20% -transparent rgb(38,134,71) ) -compose DstOut -composite output.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to remove or make transparent all but one single color.
IM 6.4.1-4 is still not out yet. But you can get binary versions from http://www.imagemagick.org/script/binary-releases.php and source from http://www.imagemagick.org/download/www ... ource.html
Re: How to remove or make transparent all but one single color.
So there's no compiled beta to be downloaded from ftp://ftp.fifi.org/pub/ImageMagick/beta ?fmw42 wrote:IM 6.4.1-4 is still not out yet. But you can get binary versions from http://www.imagemagick.org/script/binary-releases.php and source from http://www.imagemagick.org/download/www ... ource.html
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to remove or make transparent all but one single color.
Not that I know of - only source beta that you need to compile.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: How to remove or make transparent all but one single color.
Use +opaque which inverts the meaning of the color selection. That is replace pixels which are NOT this color (or near this color according to the fuzz factor.
This was added to IM v6.3.7-10 see Replace a Specific Color
Those examples also gives the same solution as above for IM versions pre-dating this addition.
This was added to IM v6.3.7-10 see Replace a Specific Color
Those examples also gives the same solution as above for IM versions pre-dating this addition.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
in 2015 imagemagick on mac above didn't work but this did:
#To make all other colors in picture except red transparent:
convert input.png -transparent 'rgb(255,0,0)' matteInput.png
convert input.png -matte matteInput.png -compose DstOut -composite output.png
convert input.png -transparent 'rgb(255,0,0)' matteInput.png
convert input.png -matte matteInput.png -compose DstOut -composite output.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to remove or make transparent all but one single color.
try +transparent
This will make everything but pure red transparent
Code: Select all
convert input.png +transparent red result.png