Hi,
how can I use the convert tool to set the color of a pixel to a specific color if it fullfills certain conditions regarding it's RGB color values (e.g. R-value > 100 && G-value >80 && B-value >150) and set it to transparent if the condition is hurt?
Thanks a lot
Set color & transparency based on condition
-
- Posts: 2
- Joined: 2014-04-13T09:22:59-07:00
- Authentication code: 6789
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Set color & transparency based on condition
I don't understand exactly what you want, but "-fx" can probably help. See http://www.imagemagick.org/script/fx.php
For example:
Note that 100/255 = 0.3922 etc. Where the condition is true, that pixel becomes white. Otherwise it is unchanged.
For example:
Code: Select all
convert in.png -fx "r>0.3922&&g>0.3137&&b>0.5882?white:u" out.png
snibgo's IM pages: im.snibgo.com
-
- Posts: 2
- Joined: 2014-04-13T09:22:59-07:00
- Authentication code: 6789
Re: Set color & transparency based on condition
Hi snibgo,
great! Exactly what I was looking for. Works pretty well!
great! Exactly what I was looking for. Works pretty well!