Despeckling B&W 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?".
Post Reply
smegmar
Posts: 2
Joined: 2015-10-08T18:41:31-07:00
Authentication code: 1151

Despeckling B&W Image?

Post by smegmar »

Hello, I have scans from several books that are 600ppi B&W images. Sometimes the scanner picks up 1x1 pixels of black on the pages, and also 1x1 pixels of white within printed letters.

I would like to "despeckle" the images so the 1x1 pixels are filled to the color of their surrounding pixels. I have tried using the -despeckle operation with "convert," but it seems that this operation was meant for low-contrast spots rather than isolated black and white images.

Any ideas about how this could be done with convert? I still need to keep the shape of the letters in good order, so I don't want to distort them in the process with any radical changes...

And thank you for any replies, in advance.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Despeckling B&W Image?

Post by snibgo »

A sample image would be helpful. The solution is probably "-morphology erode" to remove the white pixels, and "-morphology dilate" to remove the black pixels.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Despeckling B&W Image?

Post by fmw42 »

There is also a morphology smooth that does both and open and a close
Post Reply