5

This may be trivial, but I cannot figure out how to do it: I'm looking for a way (preferably in gimp or another open source application / plugin - I also have a rather old photoshop version) to remove the background of an image when you have the full original image, so i.e if I have this composition:

enter image description here

and also this image

enter image description here

How can I remove the background and leave the objects alone like this, without having to trace the borders using selection tools / magic wand? that is, like using the background as a green screen

enter image description here

Just to clarify: the images will always be composed digital lossless files, so no difference on ilumination, compression artifacts, focus etc.

Also I'm looking for a solution that works whith complex objects like the feather, hair, a grid, etc... not easily traceable with selection tools. Already tried the method of substracting one image from another, but doesn't give very good results.

enter image description here

6
  • 2
    Does this answer your question? How to remove backgrond using a photo with only the background? (GIMP/others)
    – Billy Kerr
    Mar 11, 2021 at 12:08
  • Already tried it. it somehow works with simple well defined objects but not. ie. with the feather. Also it's dependent on the color behind the object, if it's similar to the resulting grey (like the flowers and the ashtray it gives it a hard time for the color selection, even with the lowest threshold
    – Borgtex
    Mar 11, 2021 at 12:38
  • What you're asking is impossible with pixel manipulation. Basically software can't know if a grey pixel is a half-transparent black or a full-opaque grey. Mar 11, 2021 at 14:27
  • @Borgtex - yes, it will only work with very specific images, and isn't really useful in real-world situations. But I addressed that issue in the answer I already gave in the duplicate question. What you want to do isn't really practical unfortunately, and not how background removal is usually done. Removing complex backgrounds from images is not "trivial".
    – Billy Kerr
    Mar 11, 2021 at 16:19
  • @Billy Kerr I see, not so trivial after all. I thought that as there are some solutions that already do automatic background removal with a single image (like i.e. www.remove.bg or some ps plugins), having a perfect matched background would make things simpler, more nearer to chroma key method, or greatly improve the automatic results (i.e. for the feather) if implemented in a plugin or something like that. But I suppose this is more complex than I suspected and would probably go in the realm of AI processing
    – Borgtex
    Mar 12, 2021 at 12:30

2 Answers 2

1

The theory is:

  1. Put one image over the other as layers.

  2. Blend mode diference on the top one.

  3. Export the resulting image, and convert to grayscale.

  4. Adjust levels or curves. Clean the white with a brush.

  5. Use the grayscale image as a mask on your original image.

enter image description here

But probably newer AI algorithms will do a better job guessing the boundary of some objects.

0

If anyone wonders, it's mathematically impossible to perfectly restore the second transparent layer if alpha channel of the top layer has any values other than strictly 1 and strictly 0 (and it isn't 100% reliable even then).

Let's assume the background layer is dark gray (RGBA=100,100,100,1.0) and the top layer has three pixels, one gray (RGBA=150,150,150,1.0), one half-transparent light gray (RGBA=200,200,200,0.5), one fully transparent (RGBA=0,0,0,0.0). Both not fully-transparent pixels would become RGB=150,150,150, with no way to distinguish them. Furthermore, we wouldn't even know whether the fully transparent pixel is transparent or just happens to have the same color as the background.

Solutions with neural networks that try to guess the top layer even with a colored background exist, but they won't give you perfect results, just a guess which can be better or worse depending on your luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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