Subtracting one image (background) from another

MT
Posted By
Michael_Tuvim
May 30, 2007
Views
11278
Replies
14
Status
Closed
I am taking pictures of some microscopic specimens and have some issues with the background. Basically, those issues are color and brightness gradients and hot-spots.

For each picture of a specimen I take one of a background (empty spot on the same microscope slide). I need now to somehow subtract that background image from my picture of a specimen to obtain its true representation.

My attempts to make two layers and subtract one from another didn’t work.

I would greatly appreciate an advice.
MT

Master Retouching Hair

Learn how to rescue details, remove flyaways, add volume, and enhance the definition of hair in any photo. We break down every tool and technique in Photoshop to get picture-perfect hair, every time.

EH
Ed_Hannigan
May 30, 2007
If your background is truly the same for both images, set the one with the objects on it in a layer above the one without. Set the Blend Mode to Difference. The non-object area should turn black. Select the black area with the Magic Wand set to Use All Layers. Inverse the selection (Shift-Ctrl-I), and hit the Layer Mask icon. Turn off visibility on (or trash) the non-object layer.
MT
Michael_Tuvim
May 31, 2007
Thank you, Ed, for reply.
If I could bother you with the request for additional coaching please?..

It didn’t quite work for me.
I wonder if something else is important or if I followed your instructions correctly: I am using CS2.
My images are in RGB mode, tiffs, 8-bit/channel
"object" is top layer, "background image" being a background layer. Style > Blending Options > Blend Mode = Difference, 100% Opacity
I got black.
Working in top layer: Magic Wand set 36% tolerance, Sample All Layers checked. Select Inverse, Layer Mask – Reveal Selection.

I get the crudely cut image floating in the air. Accidentally, the hot color spot from a background is still present.
B
Bernie
May 31, 2007
Can you post to sample images for us to look at? (and try stuff with)

<http://www.pixentral.com>
EH
Ed_Hannigan
Jun 1, 2007
The two backgrounds may not be identical or perfectly aligned. Also I would try a lower Tolerance. Try 10 or even 1.

The mask may need a little tweaking. Try Filter>Other>Minimum.

By the way, the dropdown on the Layers palette is adequate for this. No need to go to the Styles dialog.
EH
Ed_Hannigan
Jun 1, 2007
I agree with CN. A screenshot (or two) might be helpful here.
MT
Michael_Tuvim
Jun 1, 2007
Folks, I cannot find any instructions on uploading images. Please excuse my ignorance and advise on how to do that.
B
Bernie
Jun 1, 2007
Click on the link I provided. It’s a free image hosting site. Once your image is uploaded, you will see some code at the bottom, copy the HTML in this forum
MD
Michael_D_Sullivan
Jun 2, 2007
Go to <http://www.pixentral.com>. Click on the button to browse your system for the file to upload, then click on the button to send it. After a few seconds, you will see the photo, and under it will be two boxes of code. Copy all of the code from the box labeled HTML. Paste that code in your message post. It will look something like this:

<a href=" http://www.pixentral.com/show.php?picture=1itqg8lObK4gKN0ISM exnd9rA7kiUL0"/><img alt="Picture hosted by Pixentral" src=" http://www.pixentral.com/hosted/1itqg8lObK4gKN0ISMexnd9rA7ki UL0_thumb.gif" border="0"/></a>

and will end up looking like this when your message is posted (except that your image will be used for the clickable thumbnail, instead of mine):

< http://www.pixentral.com/show.php?picture=1itqg8lObK4gKN0ISM exnd9rA7kiUL0>
MT
Michael_Tuvim
Jun 4, 2007
Got it.
Here are HTML codes from an uploaded image of a mouse airway wall struck by fungal disease and its background:

< http://www.pixentral.com/show.php?picture=1C9yYmxWXcgD6Hf22d cnI5oOUemss1>

< http://www.pixentral.com/show.php?picture=1h22CHjBGaFppk3hfc 2YIu6k6AWWg>
MD
Michael_D_Sullivan
Jun 5, 2007
Is this what you are trying to do?
< http://www.pixentral.com/show.php?picture=12fnWepWZ76CaMvZRD NfrvIcoQ6ke>

As you can see from the layer palette, I put the background image in a layer named "Bkgnd" and the object in a layer named "Object". I set the blending mode of Object to "Difference." This made the area not overlapped by the background appear blackish. I then used Select > Color Range with fuzziness set to 31, sampled the blackish area, and used that as my selection. Turned the blending mode of Object back to Normal. Created a new layer, which I named "Masking," and used the paint bucket (fill tool) to fill the selected area with black. You could go a step further and copy this layer to a mask on the Object layer, then turn off the visibility of Bkgnd and Background, and your object will now have a transparent background. You could put whatever you want on a layer underneath it, such as a solid color, a grid, a cute fuzzy mouse face, etc.
WE
Wolf_Eilers
Jun 5, 2007
Michael, try the following (I use Windows shortcuts):

1. Load both images into Photoshop.

2. Copy the slide image to the fungal image to create two layers with the slide image named Layer 1. (Ctrl+Shift+click slide image and drag to fungal image.)

3. Apply a Difference blend to layer 1.

4. Merge the visible layers (Ctrl+Shift+E) to create Layer 2.

5. Invert Layer 2 (Ctrl+I)

6. Add a Level adjustment layer and adjust the midtone slider to the right to sufficiently darken the image.
WE
Wolf_Eilers
Jun 5, 2007
To Michael D: I did not read your solution when I provided mine, but clearly they are similar. I just do an invert to bring the image back to it’s normal state.
MT
Michael_Tuvim
Jun 6, 2007
I need a bright white background, just as we see the sample on a transilluminated microscope slide. I am trying to get this (or something close to that):

< http://www.pixentral.com/show.php?picture=1gWpbNqsMKGM1YPV4P RHF07YcCDHa>

That was done in ImageReady – software package we use to operate the microscope. After it’s done I still have to get it into Photoshop and play a bit with levels to get to a finished image like that:

< http://www.pixentral.com/show.php?picture=13BeLBavlyF8HDhf74 dxg7cAXAxCXF>
MD
Michael_D_Sullivan
Jun 6, 2007
In that case, instead of the black fill in my example, use a white fill.

How to Improve Photoshop Performance

Learn how to optimize Photoshop for maximum speed, troubleshoot common issues, and keep your projects organized so that you can work faster than ever before!

Related Discussion Topics

Nice and short text about related topics in discussion sections