On Nov 16, 10:58 pm, [EMAIL PROTECTED] wrote: > 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. >
What if you break up your sheet into zones of some arbitrary size (1/2" say), and compute a pixel density? (Density isn't really required, since all zones are the same size - raw pixel count per zone will do just as well.) Then locate the signature based on the zones with density above threshold X (determine X by trial and error). Lastly, clip within these zones if this is still necessary. -- Paul -- http://mail.python.org/mailman/listinfo/python-list