Page 1 of 1

Background Removal

Posted: 2019-02-22T17:11:50-07:00
by Jadey
Yeah, I would love to use Imagemagick to do all of my processing, but I just haven't had much success.

My primary issue is that I'm taking pictures of coins, and I would like to bulk process them and select just the coin and eliminate the background. I have tried a number of examples I've found, but nothing is more reliable than about 90%.

I've tried convert with a variety of fuzz settings, but couldn't get a consistent result. Photoshop "Select Subject" is not perfect in the edge detection, but it is about 99% repeatable, so I use vbs scripts to use photoshop to crop and trim. Then, I use Imagemagick convert to create montages, labels, titles, etc.

I really wanted to try Fred's autotrim script, so I went so far as to configure a Ubuntu system on my windows machine, but I just couldn't get it to work, and I couldn't find a decent way to edit scripts. So, I gave up that avenue. I think I'm too old to learn Linux ;-)

I also have had trouble resizing images with Imagemagick. It adds green hues or pixellates the image.

Re: Background Removal

Posted: 2019-02-22T18:28:03-07:00
by fmw42
Please do not tack an unrelated post onto an existing topic. Please create a new topic. I have done so this time for you.

Please post some examples and perhaps someone can help you further.

Please, always provide your IM version and platform when asking questions, since syntax may differ.

If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli


For novices, see

http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli

My auto trim script is not what you want.

Perhaps a combination of fuzzy thresholding or flood fill in combination with connected components might do what you want.

Not exactly what you have, but the concepts are similar. See viewtopic.php?f=1&t=32126&p=146841&hili ... al#p146841

But your background color/texture will be very important. Also lighting is important. If you have reflections or flare or shadows that will make it harder.