def apply_thresholds()

in scripts/ui/foreground_mask.py [0:0]


    def apply_thresholds(self, blur=-1, closing=-1, thresh=-1):
        """Displays colored visualization of the foreground masking.

        Args:
            blur (int, optional): Gaussian blur radius.
            closing (int, optional): Closure (for sealing holes).
            thresh (int, optional): Threshold applied to segment foreground and background

        Returns:
            np.array[uint8, uint8, uint8]: Colored image where green represents the foreground.
        """
        if (
            type(self.image_8bit_fg) is not np.ndarray
            or type(self.image_8bit_bg) is not np.ndarray
        ):
            return None

        if blur >= 0:
            self.blur = int(blur)
        if closing >= 0:
            self.closing = int(closing)
        if thresh >= 0:
            self.thresh = thresh

        # Ignore if we don't have values for all the parameters we need
        if self.blur < 0 or self.closing < 0 or self.thresh < 0:
            return None

        if not self.ready:
            return None

        mask = self.generate_fg_mask(
            self.image_float_bg,
            self.image_float_fg,
            self.blur,
            self.closing,
            self.thresh,
        )

        mask_rgb = np.stack((mask,) * 3, axis=-1)
        mask_rgb[mask > 0] = [0, 255, 0]  # green

        # Overlay mask on top of color for visualization purposes
        return cv2.addWeighted(self.image_8bit_fg, 1, mask_rgb, 0.5, 0)