How to remove black pixel noise based on the surrounding area.

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
sizlinspirit
Posts: 1
Joined: 2014-12-09T23:59:03-07:00
Authentication code: 6789

How to remove black pixel noise based on the surrounding area.

Post by sizlinspirit » 2014-12-10T00:11:15-07:00

I have an image to which I've applied threshold ( so all pixels below a threshold limit have been converted to 100% black).

As a result of applying threshold, there are some stray black pixels, i.e. ones that have no other black pixel in their neighbourhood.
I was looking to eliminate such such pixels, and retain only contagious areas of black in the image.

So say any black pixel ( or a small group of black pixels, say 3x3) that do not have any other black pixel (or a 3x3 black pixel group) in its immediate neighbourhood should be turned white. How do i do this with imagemagick?

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

Re: How to remove black pixel noise based on the surrounding area.

Post by fmw42 » 2014-12-10T10:16:13-07:00


Post Reply