From 0660e44d6852cb5b639e61be059ee349456cea8e Mon Sep 17 00:00:00 2001 From: Bo Shang Date: Fri, 28 Jun 2024 08:11:15 -0400 Subject: [PATCH] solid red mask for stains --- opendm/staindetection.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/opendm/staindetection.py b/opendm/staindetection.py index ed2c07982..e503969a3 100644 --- a/opendm/staindetection.py +++ b/opendm/staindetection.py @@ -54,14 +54,15 @@ def create_overlay(self, original_image, segm_mask): interpolation=cv2.INTER_NEAREST, ) - num_classes = segm_mask.max() + 1 - colormap = cm.get_cmap("viridis", num_classes) - segm_mask_color = colormap(resized_segm_mask)[:, :, :3] - segm_mask_color = (segm_mask_color * 255).astype(np.uint8) + # Create a red color mask for stains + stain_mask = np.zeros_like(original_image) + stain_mask[resized_segm_mask > 0] = [0, 0, 255] # Set red color for stains - alpha = 0.5 + # Combine the original image with the stain mask using alpha blending + alpha = 0 # Transparency level (0.5 for 50% transparency) overlay_image = cv2.addWeighted( - original_image, 1 - alpha, segm_mask_color, alpha, 0 + original_image, 1 - alpha, stain_mask, alpha, 0 ) + return overlay_image