builtree/handwrite

pngtosvg: Merge thresholding part in pngToBmp to sheettopng.py code to accommodate variable lighting in inputs

Opened this issue · 0 comments

Related: #3

We should do this thresholding in sheettopng during the cropping process.

# Threshold image to convert each pixel to either black or white
threshold = 200
data = []
for pix in list(img.getdata()):
if pix[0] >= threshold and pix[1] >= threshold and pix[3] >= threshold:
data.append((255, 255, 255, 0))
else:
data.append((0, 0, 0, 1))