Added colour-improvement for bw display

The function display_corrected_image also improves the image for the 2-colour E-Paper Display.
This commit is contained in:
Ace 2019-03-04 21:46:44 +01:00 committed by GitHub
parent 8b03dae42a
commit 3d0a7dca9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -306,18 +306,29 @@ def main():
# image.save(path+'before.bmp')
width, height = image.size
pixels = image.load()
# To-Do: Use lambda instead of double-loop
for x in range(width):
for y in range(height):
pixel = image.getpixel((x, y))
red = pixel[0]
green = pixel[1]
if red > 240 and green > 240: #white
pixels[x, y] = (255, 255, 255)
elif red > 250 and green < 180: #red
pixels[x, y] = (255, 0, 0)
else:
pixels[x, y] = (0, 0, 0)
if display_colours == "bwr":
for x in range(width):
for y in range(height):
pixel = image.getpixel((x, y))
red = pixel[0]
green = pixel[1]
if red > 240 and green > 240: #white
pixels[x, y] = (255, 255, 255)
elif red > 250 and green < 180: #red
pixels[x, y] = (255, 0, 0)
else:
pixels[x, y] = (0, 0, 0)
if display_colours == "bw":
for x in range(width):
for y in range(height):
pixel = image.getpixel((x, y))
red = pixel[0]
green = pixel[1]
if red > 240 and green > 240: #white
pixels[x, y] = (255, 255, 255)
else:
pixels[x, y] = (0, 0, 0)
print('Conversion finished. Enjoy a crisp image on the E-Paper')
# Uncomment following line to save the processed image