From 7ec442e37e6216567c75bd807afe208a6118c6a4 Mon Sep 17 00:00:00 2001 From: gurayerus Date: Mon, 16 Sep 2024 09:28:25 -0400 Subject: [PATCH] Make the overlay mask transparent in inm viewer --- src/NiChart_Viewer/src/pages/view_img.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/NiChart_Viewer/src/pages/view_img.py b/src/NiChart_Viewer/src/pages/view_img.py index 85dfac76..f57d411f 100644 --- a/src/NiChart_Viewer/src/pages/view_img.py +++ b/src/NiChart_Viewer/src/pages/view_img.py @@ -24,6 +24,9 @@ VIEW_AXES = [0, 2, 1] VIEW_OTHER_AXES = [(1,2), (0,1), (0,2)] MASK_COLOR = (0, 255, 0) # RGB format +MASK_COLOR = np.array([0.0, 1.0, 0.0]) # RGB format +OLAY_ALPHA = 0.2 + def reorient_nifti(nii_in, ref_orient = 'LPS'): ''' @@ -151,7 +154,7 @@ def prep_images(f_img, f_mask, sel_roi_ind, dict_derived): mask = nii_mask.get_fdata() # Convert image to uint - img = (img / img.max() * 255).astype(int) + img = (img.astype(float) / img.max()) # Crop image to ROIs and reshape img, mask = crop_image(img, mask) @@ -167,11 +170,8 @@ def prep_images(f_img, f_mask, sel_roi_ind, dict_derived): img = np.stack((img,)*3, axis=-1) img_masked = img.copy() - img_masked[mask == 1] = MASK_COLOR + img_masked[mask == 1] = (img_masked[mask == 1] * (1 - OLAY_ALPHA) + MASK_COLOR * OLAY_ALPHA) - # Scale values - img = img / img.max() - img_masked = img_masked / img_masked.max() return img, mask, img_masked