class Combine: def __init__(self, path_first, path_second): self.first = Image(path_first) self.second = Image(path_second) def result(self): return self.first def combine(self, percentage_first, percentage_second): self.first.apply_to_all_pixels(self.apply_percentage(percentage_first)) self.second.apply_to_all_pixels( self.apply_percentage(percentage_second)) self.first.apply_to_all_pixels(self.apply_combine(self.second.get())) self.first.astype(numpy.uint8) @staticmethod def apply_combine(img_second): def f(img_first): return img_first + img_second return f @staticmethod def apply_percentage(p): def f(pixel): return pixel * p return f
def expandMask(img, shrink=False, step=1): """Grow or shrink a mask by a pixel.""" if shrink: img = invert(img) img = jitterSum(img.data, step) > 0 img = Image(data=img.astype(numpy.uint8) * 255) if shrink: img = invert(img) return img
def expandMask(img, shrink = False, step = 1): """Grow or shrink a mask by a pixel.""" if shrink: img = invert(img) img = jitterSum(img.data, step) > 0 img = Image(data = img.astype(numpy.uint8)*255) if shrink: img = invert(img) return img