Hi,
I got a 24bits png and I want to get a mask (1bit) for color X (say '#aabbcc')
I want output pixel to be black where input pixel was '#aabbcc'
and output pixel to be white for any other pixel input
I tweaked the exemple at viewtopic.php?t=13602
convert rmgcb.png \
\( -clone 0 \
-transparent '#aabbcc' \
-alpha extract \
-fill white -opaque white \
-transparent black \) \
-compose over -composite \
rmgcb_red_yellow_blue.png
but the outpixel are still colorfull
thank you
Create Mask for color X ?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Create Mask for color X ?
You make #aabbcc transparent, then "-alpha extract" makes black where the pixels were #aabbcc, and white otherwise.
That's what you want, isn't it?
Then you do other stuff.
That's what you want, isn't it?
Then you do other stuff.
Code: Select all
convert rmgcb.png \
-transparent '#aabbcc' \
-alpha extract \
rmgcb_red_yellow_blue.png
snibgo's IM pages: im.snibgo.com
Re: Create Mask for color X ?
exactly what I needed.
thank you snibgo.
thank you snibgo.
Re: Create Mask for color X ?
In my case, the original image (rmgcb.png) already has some transparency, and that is getting mixed with the color I want to extract the mask for. Is there any way to fix this? I tried turning off the transparency, but than this defaults to a black background, which is a problem in cases when I want to extract the black color to a mask.snibgo wrote: ↑2016-11-10T07:55:37-07:00 You make #aabbcc transparent, then "-alpha extract" makes black where the pixels were #aabbcc, and white otherwise.
That's what you want, isn't it?
Then you do other stuff.
Code: Select all
convert rmgcb.png \ -transparent '#aabbcc' \ -alpha extract \ rmgcb_red_yellow_blue.png
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Create Mask for color X ?
What do you want to happen to the pixels that are initially transparent?
snibgo's IM pages: im.snibgo.com
Re: Create Mask for color X ?
They shouldn't be included in the mask, i.e. the final mask should be black wherever the original was transparent.