def thres(pil_Image):
""" Thresholding the image
"""
w, h = pil_Image.size
thim = Image.new("RGB", (w, h))
thdr = ImageDraw.Draw(thim)
PX = pil_Image.load()
# make threshold image
for x in range(0, w):
for y in range(0, h):
r, g, b = PX[x, y][:3]
hsv = rgb2hsv(r, g, b)
if hsv[2] > 0.9 and hsv[1] < 0.1:
thdr.point([x, y], fill=(0, 0, 0))
else:
thdr.point([x, y], fill=(255, 255, 255))
thim.show()
return thim
评论列表
文章目录