这里是将白色区域作为无效区域
无效区域大于0.9即为无效图片
from __future__ import division
from PIL import Image, TiffImagePlugin
import os
import numpy as np
from libtiff import TIFF,TIFFimage,TIFFfile
def getPix(filename):
img = Image.open(filename)
pixdata = img.load()
tsize=0
#'Look for the number of white lines'
for y in xrange(img.size[1]):
for x in xrange(img.size[0]):
if pixdata[x,y][0]>250 and pixdata[x,y][1]>250 and pixdata[x,y][2]>250 :
tsize+=1
allsize=img.size[0]*img.size[1]
percentage=tsize/allsize
size = os.path.getsize(filename)
print percentage
if(percentage>=0.9):
return -1
le=getPix('D:/image/png/1636-D758-347B-079D-20161104140003-00113239.tif');