Page 1 of 1
how im do a color blending?
Posted: 2008-12-19T09:31:56-07:00
by haibara
here i have a icon in a green background without alpha and another background
i want to do a color blending to produce the icon in the background
like this:
a icon in a green background(no alpha)
another white background(in fact i want any background)
the icon in the white background
which command can i use?
regards
Re: how im do a color blending?
Posted: 2008-12-19T12:19:42-07:00
by fmw42
one way is to translate the green into white
convert green.jpg -fuzz XX -fill white -opaque green1 white.jpg
you need to know the exact or near green color components as rgb values or color name or hexcolor
see color definitions at
http://imagemagick.org/script/color.php
the -fuzz XX where XX is some percent say 40% allows other colors near green to be converted to white.
You can also try floodfilling:
convert green.jpg -fill white -fuzz 40% -floodfill +0+0 "rgb(0,255,2)" green_white40.jpg
Alternately, you may need to use some masking technique to extract the face from the green background and then composite it back onto a white background.
Re: how im do a color blending?
Posted: 2008-12-20T05:37:48-07:00
by haibara
daer fmw42, thx for your reply
but point of my question is that i want any background
your method is suitable for background created by myself or manipulated by IM
in my requirement, background should be freewill, from real photo or computer graphics, not only described by IM
in fact, i try use ChangeMask mode in composite to get 32-bit image with alpha, then composite with any background
---i thinks it's alternate way mentioned by you
but i worried about this method whether is exact. i heard about color blending which is technically for my demand, but i don't know this operation whether has same effect as color blending
Re: how im do a color blending?
Posted: 2008-12-20T13:19:25-07:00
by fmw42
I don't know what you mean by color blending. IM can blend two images, but that won't change one background to another. The only way I know to change the background to another picture is to make the green background transparent and compose that image over a new background image. Or make a binary mask image and use that to control the overlay of the one image with a new background.
You can try:
convert newbackgroundimage \( green.jpg -fuzz 40% -transparent green1 \) -compose over -composite image_on_newbackground
Otherwise you need to make a binary mask image (white for the face and black for the background), then
convert newbackgroundimage green.jpg maskimage -compose multiply -composite image_on_newbackground
But since your face has both black and white areas, it may not be easy to process the mask. I tried doing so from one of the red, or green or blue channels of the image, but with no good results. You may have to trace the outline manually in some other program to make the mask.
Re: how im do a color blending?
Posted: 2008-12-23T23:32:56-07:00
by anthony
Instead of replacing the color with white replace it with transparency.
See IM exmaples, Color replacement
http://www.imagemagick.org/Usage/color/#replace
However if you want to try to present any anti-aliased or 'blended' pixels (is this what you mean by blending?) Then you may have to do some more advanced color replacements, involving splitting the image into 'definate foreground' 'definate background' and 'blended or anti-aliased pixels'.
With that tree image separation you can do any special handling needed for the blended pixels.
One such example of a VERY complex problem is given in IM examples,
Masking with Anti-Aliased Edges
http://www.imagemagick.org/Usage/channe ... antialised