Page 1 of 1
Removing semi-transparent pixels on greyscale image
Posted: 2012-11-02T16:23:07-07:00
by HanFox
I'm trying to remove the semi-transparent pixels on a greyscale image (
http://i.imgur.com/cV08w.png).
However, whatever I try it just goes full black and white.
This is the line I normally use:
Code: Select all
convert inimage.png -channel A -threshold 60%% +channel outimage.png
If I recall correctly I've also tried -alpha off and all sorts just to
try and get something vaguely useful.
I have read the documentation and tried other things which I can't remember any more...
So is there a way for me to do this baring in mind I would like the exact same script to work on coloured images, too (but I can always just do them separately at a push).
Re: Removing semi-transparent pixels on greyscale image
Posted: 2012-11-02T17:04:31-07:00
by fmw42
Either of these work for me on IM 6.8.0.4 Q16 Mac OSX Snow Leopard, though I am not sure what effect you want as a result.
convert cV08w.png -alpha off cV08w_aoff.png
convert cV08w.png -background white -flatten cV08w_flatten_white.png
They are slightly different. So try both and see what you like.
Re: Removing semi-transparent pixels on greyscale image
Posted: 2012-11-02T17:20:01-07:00
by HanFox
Okay, I feel a bit dumb. Doing those commands directly on the images has achieved something close... before I was running them through a script with other commands which must have been messing with the channels.
The only thing is, with my original command and both of yours it's darkening the colours.
Original:
http://i.imgur.com/cV08w.png
-alpha off:
http://i.imgur.com/8Wa3a.png
-background white -flatten:
http://i.imgur.com/wVGtX.png
Re: Removing semi-transparent pixels on greyscale image
Posted: 2012-11-02T18:09:23-07:00
by fmw42
Your image is labeled as sRGB colorspace, but is really grayscale. In IM after 6.7.8.3 grayscale is treated as linear, which will be darker. To get around that so it looks as if sRGB as before, but will be labeled grayscale add -set colorspace RGB
convert cV08w.png -set colorspace RGB -alpha off cV08w_aoff2.png
That works for me to make it lighter again.
See
viewtopic.php?f=4&t=21269
Re: Removing semi-transparent pixels on greyscale image
Posted: 2012-11-02T18:26:37-07:00
by HanFox
Ah ha, awesome
In the end to get the correct finished product I used threshold instead of alpha off as I'm trying to clean up the edges:
convert cV08w.png -set colorspace RGB -channel A -threshold 60% -colorspace sRGB cV08w_off.png
Thank you very much for your help fmw42. Very much appreciated.