Take the 2-minute tour ×
Graphic Design Stack Exchange is a question and answer site for Graphic Design professionals, students, and enthusiasts. It's 100% free, no registration required.

Consider the following graphic:

example

Note that the first image's background is transparent, and that the blue background in the second and third images is a subtle gradient - not solid color.

Basically, give the 2nd image and the 3rd one, how can I find the difference between the two to (roughly) generate the 1st image?

I'm open to any kind of answer, from "how to do it in %Program%" to "find the difference between both rgb values and multiply by..."

PS: I just realized I switched the first image with the second one in the graphic. Obviously, you start with the gradient and then put the overlay over it.

PS: GIMP has a feature called "Replace Colour with Alpha", basically, it does what I need, but it uses a specific color. In my case, the color would depend on the position.

share|improve this question
    
I think this might be easier to understand if you made the blue gradient more obvious? –  e100 Jul 19 '12 at 11:28
    
Also, I assume there is alpha transparency in the 1st image? –  e100 Jul 19 '12 at 11:41
    
@e100 Yes and yes. Actually, I believe the first two sentences explained the situation nicely? –  Christian Jul 19 '12 at 14:54
add comment

1 Answer 1

up vote 4 down vote accepted

If you have imagemagick installed (if you don't and are on a mac i'd recommend using homebrew) there is a super-easy way that will get you close...

see this article here : http://www.imagemagick.org/Usage/compose/#changemask

Basically from your two images you can call this command...

convert original.png background.png -compose ChangeMask -composite result.png

with the image with everything being original.png, the blue gradient background being background.png and the output (transparent) being result.png (or whatever you want it to be called).

enter image description here

You can see the result above... it successfully strips the background away, but the anti-aliasing of the items is still somewhat blue.

Maybe this is enough for you... if not things become much more difficult quickly.

The problem is that it isn't obvious with those edge pixels what colour/transparency combination they are.

There are techniques to help with this which you can read about in more details here:

But it is non-trivial to achieve as far as I know.

To get a really good result ideally you have two versions of the image sat on different backgrounds (white & black is classic) and then this technique works:

http://www.imagemagick.org/Usage/masking/#two_background

Anyway, fingers crossed the first option might be enough for your needs.

share|improve this answer
1  
Thanks for the (very) informative reply, highly appreciated! While at the moment I do not have a specific problem to tackle, I was curious as to what possible ways it can be achieved. Usually, I end up doing this kind of thing manually (replacing blue in the edges manually, for example). –  Christian Jul 19 '12 at 21:52
    
no problem! the first approach will definitely save you a bit of time getting rid of the main areas of background, in that case. –  Chris Jul 20 '12 at 10:49
    
"To get a really good result ideally you have two versions of the image sat on different backgrounds" - very interesting. Would be interesting to try this out for a physical semi-transparent object. –  e100 Jul 20 '12 at 11:47
add comment

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.