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:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user