Tips on Background Removal

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
dognose
Posts: 265
Joined: 2005-03-08T22:16:37-07:00

Tips on Background Removal

Post by dognose »

I've been looking at removing backgrounds in images. Of course, this is a difficult process, and more that just a
simple setting.

Some of the pro style tools work like this:

Image

by either marking the background or the foreground or both.

I've tried the -draw floodfill with a fuzz factor, and that works pretty good.

Are there anyways I could improve that?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Tips on Background Removal

Post by anthony »

It is hard to see exactly just what that tool is doing without getting a closeup of the pixels along the edge before and after the background has been removed.

However roughly what it is doing is some type of fuzz threshold removal of colors that was near the center of the circle in the original image.

A GUI type tool like this however is not well suited to a cbatch tool like ImageMagick. But there are ways to even do that.

On of the tools I am currently programming is a tool to take a set of random points and attempt to generate a smooth gradient between them. This can be used re-create the background that is under the edge of the original image, allowing you to subtract the background from the image, using the various background removal techniques.

All that would then be required is to specify enough points that are close to the edge but which you definably class as being background, and some appropriate 'fuzz' factors (for either threshold, or better still a double masking method, for an anti-aliased background removal.

As a start point read the techniques in the link I gave above.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply