To steal, ups, sorry - "extract" object
I assume the "backgrounds" you meant are just solid colors, right? (otherwise B1 = B2 at some pixel and it won't work
).
I used following technique, commonly it gives very good results:
First - transparency:
Open both images. Look at the background colors, there RGB specs. Find the channel with the biggest difference. Let's say it's a Green channel. Now go to Image->Calculations. For Source 1 select the image with lesser Green value in background color, for Source2 select another image, For channel select Green in both sources. For Blending select Subtract. Target - New channel. Click OK. You got your channel.
Now let's refine it. Select Image->Adjustments->Curves and add two points: (0,0) and (d,255), where d - Green value difference between your background colors. Click OK. That's your mask. Load it as a selection, duplicate the source layer, press delete. Turn off source layer.
Allmost there. The only problem: we've got that ugly background color matte left in semitransparent areas. If your background color happened to be just pure black or white - you are lucky, just go to Layer->Matting ->Remove Black Matte. Or white one.
In other case you've got to make some arithmetics over chanells. I did it in Filter Factory. Just put these numbers in the dialog:
R: (r - Br)*255/a + Br
G: (g - Bg)*255/a + Bg
B: (b - Bb)*255/a + Bb
a:a
, where (Br,Bg,Bb) - background color RGB vals.
This way you can get rid of any color matte. Why on earth Adobe didn't do it?! Search me.
You can try and use Filter Factory to solve your formulas. But that would be tricky one
Filter Factory does not work with several images - only with the current one. But you can compose all your images into one - side by side, and use various Filter Factory functions(src function) to get there values into formulas. That might work, even for image backgrounds. But check your formulas again, make sure they are right...
Or, really, try to find special software...