Improved masking

This commit is contained in:
Maximilian Giller 2019-04-08 11:20:04 +02:00
parent e9a1142443
commit a7605e3473
2 changed files with 3 additions and 3 deletions

View file

@ -1,7 +1,7 @@
from PIL import Image, ImageOps, ImageDraw
from Assets import colors
masking_threshold = 100
masking_threshold = 200
class DesignEntity (object):
"""General entity that can be drawn on to a panel design or
@ -44,7 +44,7 @@ class DesignEntity (object):
def __get_mask__ (self, image, invert_mask, color_key):
mask = image.convert('L')
if color_key:
mask = mask.point(lambda p : 255 if p >= masking_threshold else 0)
mask = mask.point(lambda p : 0 if p < masking_threshold else 255, '1').convert('L')
if invert_mask:
mask = ImageOps.invert(mask)
return ImageOps.invert(mask)

View file

@ -27,7 +27,7 @@ class TextDesign (DesignEntity):
def __finish_image__ (self):
if self.color is "white":
self.invert_mask = True
if self.background_color not in ["white", "black"]:
if self.background_color not in ["white", "black"] or self.color in ["red"]:
self.color_key = True
self.__init_image__(self.background_color)