PIL - "despeckle" image ?

shearichard at gmail.com shearichard at gmail.com
Thu Nov 16 23:58:29 EST 2006


Hi - I have some images which I would like to remove specks from using
the PIL. I would like to be able to say that if a pixel is in a blob of
less than n contiguous pixels then all pixels in that blob should be
removed.

The images are 8 bit images with only 0 and 255 values.

I can think of quite crude ways of doing this but I'm sure there are
some smart ways of doing it - would anyone be able to point me in the
right direction ?

Lastly in case it matters the reason I'm doing this is that the images
are scanned images of sheets of papers on which sample signatures have
been placed. Typically the signatures are much smaller than the sheets
of paper so I would like to 'autocrop' the images to remove the white
space around the signature. At some point in the process the images
having picked up small islands of pixels (dust on scanner or paper ?)
which are nowhere near the signature but which are causing my autocrop
efforts to go awry.

Thanks

Richard.




More information about the Python-list mailing list