Option to directly invert the grayscale heatmap - fix

This commit is contained in:
spezialspezial 2022-11-02 00:21:27 +01:00 committed by Lincoln Stein
parent 3e7a459990
commit 5e87062cf8

View File

@ -44,7 +44,7 @@ class SegmentedGrayscale(object):
self.image = image self.image = image
def to_grayscale(self,invert:bool=False)->Image: def to_grayscale(self,invert:bool=False)->Image:
return self._rescale(Image.fromarray(np.uint8((255 if invert else 0) - self.heatmap * 255))) return self._rescale(Image.fromarray(np.uint8(255 - self.heatmap * 255 if invert else self.heatmap * 255)))
def to_mask(self,threshold:float=0.5)->Image: def to_mask(self,threshold:float=0.5)->Image:
discrete_heatmap = self.heatmap.lt(threshold).int() discrete_heatmap = self.heatmap.lt(threshold).int()