pierogis.ingredients.seasonings.threshold module

threshold ingredient(s)

class pierogis.ingredients.seasonings.threshold.Threshold(opacity: int = 100, mask: Optional[numpy.ndarray] = None, **kwargs)[source]

Bases: pierogis.ingredients.seasonings.seasoning.Seasoning

a seasoning that compares the brightness value of each pixel in the :param target pixel array and sets corresponding colors based on if it is “included” or not

brightness = r * 0.299 + g * 0.587 + b * 0.114

LOWER_THRESHOLD = 60
UPPER_THRESHOLD = 190
cook(pixels: numpy.ndarray)[source]

parallel computation in rust is 10x speedup

cook_np(pixels: numpy.ndarray)[source]
cook_rs(pixels: numpy.ndarray)[source]
inner: bool

if True, pixels between lower and upper are included

lower_threshold: int
prep(lower_threshold: Optional[int] = None, upper_threshold: Optional[int] = None, inner: bool = False, **kwargs)[source]

set the threshold intensity levels

calls Seasoning.prep with leftover kwargs

pixels lower than lower_threshold or higher that upper_threshold are true (include_pixel)

pixels with brightness >= upper_threshold

or <= lower_threshold are replaced by include pixel (white)

upper_threshold: int