Thanks Jim. Comments below. > It is going to depend on (a) the format of the image file and (b) your > definition of what a "blank pixel" is. (Black? White? Something else?)
I'm testing RGBA png(s) for blank spots. Considering that each band except the Alpha band in my image has black and white min/max values, then I'm guessing that any minimum Alpha values of black (0) indicate a blank spot (this is only a guess and I'm always open to better educated guesses ;-) ). Here is the extrema min/max output for each band before editing a png: >>> import ImageStat >>> stat = ImageStat.Stat(img) >>> stat.extrema [(0, 255), (0, 255), (0, 255), (191, 255)] After using Gimp to erase cells from the png, the extrema min/max output looks like this: >>> stat.extrema [(0, 255), (0, 255), (0, 255), (0, 255)] So i guess I'll test for that > You could do a brute force check of each pixel's value, or depending on > your definition, you might be able to use something like the histogram > method to see if any pixels meet your criteria. On Sun, Aug 14, 2011 at 4:21 PM, Jim Tittsler <j...@onjapan.net> wrote: > On 2011-08-08 04:09, Greg Corradini wrote: > > I want to use PIL to scan a newly created image for possible corrupt > > (blank) pixels. > > > > The PIL documentation doesn't seem to mention what value a blank pixel > > might have (I assume it would come back as None). I'm not sure what to > > test for. > > It is going to depend on (a) the format of the image file and (b) your > definition of what a "blank pixel" is. (Black? White? Something else?) > > You could do a brute force check of each pixel's value, or depending on > your definition, you might be able to use something like the histogram > method to see if any pixels meet your criteria. > > > I see the Image module has a verify function > > <http://www.pythonware.com/library/pil/handbook/image.htm>, but I'm not > > sure if that covers validating that pixels are not blank. > > I believe it only detects if PIL will be able to load the specified > image file. > > > -- > Jim Tittsler http://www.OnJapan.net/ GPG: 0x01159DB6 > Python Starship http://Starship.Python.net/crew/jwt/ > Mailman IRC irc://irc.freenode.net/#mailman > _______________________________________________ > Image-SIG maillist - Image-SIG@python.org > http://mail.python.org/mailman/listinfo/image-sig > -- Greg
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig