Page 1 of 1

identify+remove background

Posted: 2011-10-21T02:17:59-07:00
by sdf
I tried to write a command line to remove the background of this old phototype.

I tried to identify the background and convert it to transparent. Though none of the command-line scripts worked. The image remained the same as in the input-image. I tried to get my way through these scripts:

Code: Select all

convert input_image.jpg -bordercolor black -border 1x1 -alpha set -channel RGBA -fuzz 20% -fill none -floodfill +0+0 white -shave 1x1 output_image
Worked my way through these turorials:
http://www.imagemagick.org/Usage/color_basics/#replace
http://www.imagemagick.org/Usage/color_basics/#opaque
http://www.imagemagick.org/Usage/masking/#bg_remove

Re: identify+remove background

Posted: 2011-10-21T05:32:27-07:00
by anthony
flood fill will not do anything unless the 'seed' point is also within the 'fuzz' distance of the color you are searching for (white). as you added a black border that seed pixel is black, so floodfill does nothing (seed fails to match).

See Floodfill operator
http://www.imagemagick.org/Usage/color_ ... #floodfill

I would recommend the more complex method of attempting to extract the semi-transparent 'anti-aliasing' pixels from the resulting image.

Ideally you would need to know the original background of the image to do this. but in this case your background is not very uniform. Their is however solutions for recovering the background, at least around the edges of the foreground object, to let you use those more complex methods.