11

Are there any Ubuntu alternatives to photoscissors, which makes it easy to remove the background of an image?

I'm currently using GIMP in different ways to do the same but for some images it takes a long time.

1
  • I just tried PhotoScissors with about half a dozen pics, and I honestly haven't found it works very well. When I searched online for tips, I just found videos for the old version of PhotoScissors, which seems to work just like GIMP. So I'm not sure if the technology is really there yet, even with everyone currently jumping up and down about AI. If you've found otherwise, please do let us know. May 2, 2023 at 19:37

3 Answers 3

23

The imagemagick package includes a convert command.

Example commands:

convert image1.jpg -fuzz 20%% -transparent White image2.png
convert image1.png -threshold 10%% image2.png

Both are simple versions of removing a background and might make all other none-background white in the image transparent (the fuzzy/threshold options can adjust that).

But Imagemagick has examples on removing backgrounds using masks.

What works best depends on the original. JPG tend to be fuzzy (what looks like the same color often are slightly different colors) so they will have mixed results.

2
  • This only works if the background is white, right?
    – Flimm
    May 25, 2022 at 12:56
  • apparently only works for flat backgrounds Jun 4, 2022 at 8:26
7
pip install --upgrade pip
pip install backgroundremover

Then simply

backgroundremover -i "/path/to/file.jpg" -o "out.png"

and if you want for video

backgroundremover -i "/path/to/video.mp4" -tg -o "output.gif"

source: https://github.com/nadermx/backgroundremover

Example before and after:

Example photo

4
  • 2
    Comment to people: This is a machine-learning-based tool that seems very cool for real photographs, but I think it leaves small artifacts in artificial images like some with the logo-white-background combination I tried.
    – kyriakosSt
    Oct 18, 2021 at 9:09
  • This wouldn't run on my Focal machine, unfortunately; it had trouble with a library called numba.np.ufunc. pip by itself isn't very good at untangling conflicting dependencies, so it'd be nice if there was an apt package for this. If anybody finds one, please comment here. May 2, 2023 at 19:08
  • @MichaelScheper did you upgrade pip before trying to install it?
    – nadermx
    May 2, 2023 at 20:33
  • This tool removes everything but the face. Also the persons clothes are gone! Jan 4 at 22:16
-2

It depends on what part of the image you want to keep. It's tricky with photographs of landscape/objects etc. with many things in the background and is much easier with text.

Apart from what others have mentioned another method for simple removal of background is to import the image into Inkscape and use the trace bitmap map tool.

Fiddle around with the settings and so on and you should be able to get the part of the image you want without the background. In fact, you should check the remove background option

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .