Incense

by Bart Arondson

submit your photo


Hall of Fame
View past winners from this year

Please participate in Meta
and help us grow.

Take the 2-minute tour ×
Photography Stack Exchange is a question and answer site for professional, enthusiast and amateur photographers. It's 100% free, no registration required.

I've taken some stock photography of lots of clear bottles, and now want to remove the background (which is white-ish, because at a pinch I could leave it...) so that the bottle becomes transparent with highlighting.

My bottles are clear with different colored liquids with multiple refraction and reflection surfaces. I am looking for a background color subtraction effect that will allow me to get to transparent (hopefully with some sort of effect/opacity slider).

Ideas that I can't pull off yet:

  • Combine layer with a color fill layer (keyed off the "transparent color") in some manner to produce some output that could be used as the starting point of a layer mask
  • Same layer combination as above, but somehow translating "pure white" to transparency.

Notes for what doesn't work (Photoshop terminology):

  • "Color Range" and delete (fuzzy select, but not graded/alpha) - results in harsh lines and only leaves the pure white and dark highlights and shadow refractions/reflections
  • Magic wand selections for the same reason
  • "Background Eraser" because although it is able to only subtract a certain color and leave "the rest", it (like all tolerance based tools) eventually hits a colour slightly outside of the range that it just won't touch.

I'll add more if I can remember what I've found

share|improve this question
5  
I think it would help if you could post an example image you want to make transparent. –  che Aug 11 '10 at 14:24

4 Answers 4

up vote 4 down vote accepted

Gimp has a really nice 'Color to Alpha' feature that sounds like it does exactly what you want. It doesn't just erase one color, but tries to make things that are almost white into almost transparent. It's not perfect, but comes pretty close. Here's an example from the docs: http://docs.gimp.org/en/plug-in-colortoalpha.html

share|improve this answer
    
That seems like it could be pretty good as a start, it might even be a better result than my steps 6-10... –  Stephen Aug 13 '10 at 12:34
    
That is so awesome! So much so I've asked a specific question about whether photoshop has any sort of equivalent: photo.stackexchange.com/questions/2834/… –  Stephen Aug 26 '10 at 4:38

I can't believe - I figured it out! (I am just a photoshop hacker)

So heres what will get you 80% of the way to a perfect transparency (higher numbers are on the top):

  1. Rename your bottle layer (1) to "Original" and hide it.
  2. Get a nice background (perhaps a fill color) and put it in a layer "Background" (2). This is for looking at how we're going along the way...
  3. Create a new copy of "Original" and call it "Alpha and Highlights" (3).
  4. Add a layer mask to "Alpha and Highlights"
  5. Take a copy of your "Original" and call it "Alpha Source" (4)
  6. Create a fill layer (5) with the color of your background called "Alpha Merge". My background is (214, 193, 188) - I believe a grey color close to (but not white) may actually yield the best results (as opposed to a chroma key) - this is because of step 6.
  7. Change the blend mode of "Alpha Merge" to Different. This shows us how much each part of the image matches the background. Perfect black (0,0,0) means that the bottle is 100% transparent at that point.
  8. Merge "Alpha Source" and "Alpha Merge" layers together. Rename this to "Alpha Mask" (4). At this point the goal needs to be considered: We know which part of the bottle is fully transparent, but there are also highlights and shadows we want to preserve. (Note at this point I have only achieved preserving the highlights - I'll update for shadows later). Now white is very close to my grey; it would show as (41, 62, 67) at the moment which is rather dark. For this reason...
  9. Add a curves adjustment to the "Alpha Mask" layer, and push the curve to the left so that it starts at 0 and gets to 100% about 10-20% in from the left. This will give us a transparency band of around 20-40% of the "sameness" of the background (before it becomes completely opaque - as said above, this works for highlights; shadows not so well...). You should now have an image that is basically white, but is black in the areas that match the background. You need to ensure that areas that should be white are completely white at this point.
  10. Copy the contents of "Alpha Mask", alt-click on the "Alpha and Highlights" mask layer and paste. At this point, if you have only got "Alpha and Highlights" and "Background" visible, you'll have a decent transparency, but all the highlights will be washed out...
  11. Select "Alpha and Highlights" and "Alpha Mask" and group them into a smart object. Open the smart object for editing...
  12. Duplicate your layer and hide it (so you have a reference point for when you stuff up :)). I won't detail the modifications you'll need, except to say that I needed to adjust certain portions of my image to make highlights brighter, and also more transparent (around the bottom of my bottle
  13. Add a "Curves" adjustment layer at the top. We're going to use this to make the highlights way brighter - they need to be, since most of them have a large amount of transparency now. Make the curve a bit like an 'S' - I have full white and full black for 25% from each end. (As stated, I haven't got shadows working quite yet, but this is what would be needed).
  14. Save and exit the smart object, and you should now have a really great start on a transparent bottle!

If someone would like to use this to make a tutorial (with images etc), feel free (I may even get to it one day) as long as you reference this answer in your tutorial and put a link in the comments below.

share|improve this answer

This is what it sounds like to me that you are trying to do: You have taken a picture of transparent objects and would like to remove the background and preserve the transparency of the foreground objects (so that perhaps you could replace the background with something else).

First thing is a choice you have to make: You can use built in tools to do the job as quickly as possible, but you sacrifice a lot of quality and realism. Or you can put in a little time and do it manually but with far better results. I would choose the latter ;)

If I had to pull that off I would probably shoot a white background to start with, then in Photoshop (or the equivalent):

  1. Cut out the negative space (the background that doesn't show through the bottles. Basically anything you can remove entirely from the image. Be careful to preserve hard edges so that the image looks realistic if you replace the background later.
  2. Make a new background layer that is black (you will delete it later to get your transparency back).
  3. Create a clipping mask for the bottles and whatever else is in the foreground. (After this all you should see is back because the clipping mask will be empty).
  4. Slowly brush in parts of the image by adding content to the clipping mask. Add opacity slowly. Make sure hard edges are completely opaque, areas where the color affects the background are semi-transparent, and areas where you could originally see the background are completely transparent.

That would be my workflow. I would also probably stick a semi-transparent copy of the original image between the background and the clipped image as a reference for the brush and then get rid of it later. If you want a perfect background replacement though, you are going to need to do a little touch up depending on what the background is to make reflections and diffractions look realistic. Best of luck!

share|improve this answer
    
Chroma Key might be even better than white, if background replacement is the goal; that's what it's designed for. –  Craig Walker Aug 11 '10 at 19:11
2  
Chroma Key won't work well with color transparency, or at least I have never gotten it to. White preserves the colors. - "My bottles are clear with different colored liquids with multiple refraction and reflection surfaces." –  jif Aug 11 '10 at 20:58

I have an idea

shoot the bottle once with a black background, exposing for the highlights, then with a white background, exposing for the shadows.

Pull the two images into a new document with a transparent background, applying the darken or multiply blend mode to the white background pic, and lighten or screen to the dark background pic.

Of course I haven't tried this in practice, but might have to after work!

share|improve this answer
1  
It sounds like it may just work. Though, sometimes even logical theories can turn out to be disasters :P –  Nick Bedford Aug 16 '10 at 3:20

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.