Page 1 of 2
Background Removal
Posted: 2011-07-19T21:59:15-07:00
by madhu
Hi,
I am trying to remove the background of an semi-transparent object.
I am attaching the link.
http://imageshack.us/photo/my-images/135/73869723.png/
I want to remove the green background and make the object look clear.
Thanks,
Madhu.
Re: Background Removal
Posted: 2011-07-19T22:06:15-07:00
by anthony
Semi-transparency removes of a single background color is actually not simple, and there is incomplete information.
For Perfect recovery you need teh same image on at least two different backgrounds
Background Removal using Two Backgrounds
http://www.imagemagick.org/Usage/maskin ... background
You can easily determine what is full transparency, but restoring the semi-transparent edges is something else.
The fact you have a border helps. and with that you may be able to use the following method
Recovering Semi-Transparent Edges
http://www.imagemagick.org/Usage/masking/#semi-trans
The technique you are refering too however is known as Chroma-Key Masking. And while I have not set up a speicific example of this (yet) it is very similar it what is shown in
Chroma Key Masking
http://www.imagemagick.org/Usage/photos/#chroma_key
More information on restoring semi-transparency effects (known as 'color spill') can be found on Wikipedia
http://en.wikipedia.org/wiki/Chroma_key
I would however like others to try and see what they can do, and hopefully from it we can create a full 'Green Screen Transparency' example.
Re: Background Removal
Posted: 2011-07-19T22:21:54-07:00
by madhu
Hi,
Thanks for the reply.
But I have one more doubt.I took the same pic in two different complement backgrounds but from some distance variation.
That is the distance from the camera and object is differing.
So, can I do the background subtraction of those two images. I am not sure,so can U make it clear.
That is the reason why I posted only one background link......
Thanks,
Madhu.
Re: Background Removal
Posted: 2011-07-19T22:24:21-07:00
by fmw42
If the scale of the two images are different, i.e. the distance to the objects from the camera, then you would have to register (warp) the images so that there was a perfect 1:1 match of the two image geometries before you can do background subtraction. Such a perfect registration may be impossible to make.
Re: Background Removal
Posted: 2011-07-19T22:34:37-07:00
by madhu
fmw42 wrote:If the scale of the two images are different, i.e. the distance to the objects from the camera, then you would have to register (warp) the images so that there was a perfect 1:1 match of the two image geometries before you can do background subtraction. Such a perfect registration may be impossible to make.
Can you please guide me to any tutorial about "warp" and the 1:1 perfect match
Thanks,
Madhu.
Re: Background Removal
Posted: 2011-07-19T22:55:59-07:00
by anthony
For background removal that would probably fail even with warping as the individual pixels must line up perfectly. Near enough is not good enough for this type of thing.
Re: Background Removal
Posted: 2011-07-19T23:22:28-07:00
by madhu
Thanks for the reply....
Is there any alternative for this?
Thanks,
Madhu.
Re: Background Removal
Posted: 2011-07-19T23:55:06-07:00
by anthony
The alturnatives is as I have listed above.
There are techniques I have pointed to for recovering semi-transparent pixels.
Re: Background Removal
Posted: 2011-07-21T00:18:28-07:00
by madhu
Hi,
I have a doubt that is it possible to retain the fabric transparency only one background?
If possible please reply me ....
Thanks,
Madhu.
Re: Background Removal
Posted: 2011-07-25T01:53:24-07:00
by madhu
Hi,
Is it possible to remove the background for this image.
http://imageshack.us/photo/my-images/35/matchnavy.gif/
The output should be
http://imageshack.us/photo/my-images/40 ... vered.gif/
This output must be obtained from only single background removal.
Madhu.
Re: Background Removal
Posted: 2011-07-25T10:01:12-07:00
by fmw42
that result is shown at
http://www.imagemagick.org/Usage/maskin ... background for one background color and is not as good a result as when two complementary background colors are use in the subsequent example.
Re: Background Removal
Posted: 2011-07-25T17:55:32-07:00
by anthony
That is the real problem. and it is the correct determination of the alpha channel value this is needed, to fully remove color spill.
One method that I detailed in teh raw notes of
http://www.imagemagick.org/Usage/photos/#green_screen was to subtract the screen from either green or blue channel. using the formula...
a(r,b,g) => K0 * b − K1 * g + K2
modified for blue screen...
a(r,b,g) => K0 * g − K1 * b + K2
and constants (for darker blue)
a(r,b,g) => g − 2 * b + 1
Here is the result
Code: Select all
convert match_navy.gif -fx 'g-2*b+1' match_one_remove_alpha.png
It is not great, but did work to some extent!
Now applying it to remove the background color (as per two background color removal)
Code: Select all
convert match_navy.gif match_one_remove_alpha.png -alpha Off \
-fx "v==0 ? 0 : u/v - u.p{0,0}/v + u.p{0,0}" \
match_one_remove_alpha.png -compose Copy_Opacity -composite \
match_one_remove.png
The result is not perfect, as the dark blue seems to have caused yellows (negated blue) to become much more enhanced than they should have, but its is not too bad. more work is needed, probably works better with a bright green screen!
Re: Background Removal
Posted: 2011-07-25T23:28:14-07:00
by madhu
Hi!
Thanks for the reply...
It is working fine with the example what you have shown.
But it is not working with the other example.
I am posting the link for the other example
http://imageshack.us/photo/my-images/811/62025428.png/
Is it possible to remove the background which is in green color and to get only the pink color object with out any background...
Thanks
Madhu
Re: Background Removal
Posted: 2011-07-25T23:34:56-07:00
by anthony
For this I would use the technique in....
Recovering semi-transparent edges
http://www.imagemagick.org/Usage/masking/#semi-trans
because there is a good thick well defined border between the background and the foreground.
Re: Background Removal
Posted: 2011-07-25T23:51:54-07:00
by madhu
Code: Select all
convert match_navy.gif -fx 'g-2*b+1' match_one_remove_alpha.png
It is not great, but did work to some extent!
Now applying it to remove the background color (as per two background color removal)
Code: Select all
convert match_navy.gif match_one_remove_alpha.png -alpha Off \
-fx "v==0 ? 0 : u/v - u.p{0,0}/v + u.p{0,0}" \
match_one_remove_alpha.png -compose Copy_Opacity -composite \
match_one_remove.png
From where this match_alpha.png has come from
When I am executing this command it is showing error "match_alpha.png No such file exists"