Skip to content

Commit

Permalink
Make the overlay mask transparent in inm viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
gurayerus committed Sep 16, 2024
1 parent 8ca9e28 commit 7ec442e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/NiChart_Viewer/src/pages/view_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'):
'''
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand Down

0 comments on commit 7ec442e

Please sign in to comment.