Removing spots below certain dimension in BW image

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?".
Locked
Erik
Posts: 12
Joined: 2016-04-30T00:18:15-07:00
Authentication code: 1151

Removing spots below certain dimension in BW image

Post by Erik »

Version: ImageMagick 6.9.4-1 Q8 x86_64 2016-05-11 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2016 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib freetype jng jp2 jpeg lcms ltdl lzma png webp wmf xml zlib
I am new to IM.

I have BW image of a scanned text. There are remaining black spots, much smaller than the text.

Is there a way to remove a cluster of black pixels, surrounded by white pixels? I looked at morphology, but I have trouble achieving the effect. With cluster, I mean a connected area of black pixels.

Something to the effect of:

Code: Select all

-fill white -cluster 10x10 -opaque black


Where cluster contains at least one black pixel, has a maximum dimension of 10x10 (thus may hold up to 10x10 black pixels), and the outer edge of the cluster is white.

User avatar
fmw42
Posts: 26383
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Removing spots below certain dimension in BW image

Post by fmw42 »

What platform?

Best if you post an example image to some free hosting service such as dropbox.com and put the URL here, so we can see what you are describing and test with your image.

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Removing spots below certain dimension in BW image

Post by snibgo »

I would refer you to a recent thread with a similar problem: viewtopic.php?f=1&t=29571

But it's a near-identical problem. And you, Erik, started it, apparently satisfied with the answer.

What's going on?
snibgo's IM pages: im.snibgo.com

Locked