Skip to content

Commit 7ec442e

Browse files
committed
Make the overlay mask transparent in inm viewer
1 parent 8ca9e28 commit 7ec442e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/NiChart_Viewer/src/pages/view_img.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
VIEW_AXES = [0, 2, 1]
2525
VIEW_OTHER_AXES = [(1,2), (0,1), (0,2)]
2626
MASK_COLOR = (0, 255, 0) # RGB format
27+
MASK_COLOR = np.array([0.0, 1.0, 0.0]) # RGB format
28+
OLAY_ALPHA = 0.2
29+
2730

2831
def reorient_nifti(nii_in, ref_orient = 'LPS'):
2932
'''
@@ -151,7 +154,7 @@ def prep_images(f_img, f_mask, sel_roi_ind, dict_derived):
151154
mask = nii_mask.get_fdata()
152155

153156
# Convert image to uint
154-
img = (img / img.max() * 255).astype(int)
157+
img = (img.astype(float) / img.max())
155158

156159
# Crop image to ROIs and reshape
157160
img, mask = crop_image(img, mask)
@@ -167,11 +170,8 @@ def prep_images(f_img, f_mask, sel_roi_ind, dict_derived):
167170
img = np.stack((img,)*3, axis=-1)
168171

169172
img_masked = img.copy()
170-
img_masked[mask == 1] = MASK_COLOR
173+
img_masked[mask == 1] = (img_masked[mask == 1] * (1 - OLAY_ALPHA) + MASK_COLOR * OLAY_ALPHA)
171174

172-
# Scale values
173-
img = img / img.max()
174-
img_masked = img_masked / img_masked.max()
175175

176176
return img, mask, img_masked
177177

0 commit comments

Comments
 (0)