Page 1 of 1

Remove noise surrounded by transparency

Posted: 2018-09-08T20:53:49-07:00
by jiexi
I'm trying to remove the noise that runs around the border on these polaroid images

Image
Image
Image
Image

I think the correct approach is to separate out each part of the image that is completely surrounded by only transparent background, then discard the small pieces which should leave us with just the larger image?

Re: Remove noise surrounded by transparency

Posted: 2018-09-08T21:10:17-07:00
by fmw42
There are two ways to approach it. First is to use -morphology open on the alpha channel. The second is to use -connected-components to remove small regions.

These both work on your first image for me with IM 6.9.10.11 Q16 Mac OSX Sierra. But you will likely have to change the value for octagon:X or area-threshold=X


Code: Select all

convert wrnTV0w.png -channel a -morphology open octagon:5 +channel result.png

Code: Select all

convert wrnTV0w.png \
\( +clone -alpha extract -type bilevel \
-define connected-components:area-threshold=1000 \
-define connected-components:mean-color=true \
-connected-components 4 \) \
-alpha off -compose copy_opacity -composite \
result2.png

__________________________

Please, always provide your IM version and platform when asking questions, since syntax may differ. Also provide your exact command line and if possible your images.

See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620

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