Showing a semi-transparent

I have an image stack with two channels containing the image and corresponding mask of the contained objects (which I extract using thresholding). Each slice is a time step. I generate the masks in Python an store them with the original image to TIFF in the two separate channels.

I would now like to semi-transparently overlay the object mask in the second channel over the image in the first channel from within the ImageJ GUI. That way I could easily browse through the time steps to check, if the masks are correct. See the Python code below to have a better idea of the results I am going for.

I did already try using the “glesbay inverted” LUT to color the mask-channel (which AFAIK should assign different colors independently of intensity), but for some reason only some of the objects are transparent (see the image below).

    import matplotlib.pyplot as plt
    from skimage.color import label2rgb
    from skimage.measure import label

    plt.imshow(objects_image, cmap='gray')
    plt.imshow(label2rgb(label(objects_mask, connectivity=1), bg_label=0), alpha=0.05)
    plt.show()

image

Hi,

first one question: why don’t you stay in python if the first part of your script is already written in python? If you just miss a slider to interactively browse through your frames/stack you can have a look at ipywidgets and the function interact:
https://ipywidgets.readthedocs.io/en/latest/examples/Using%20Interact.html

Or you could directly save the output of label2rgb instead of a two channel image. Then open this in Fiji to browse.

If you want to use ImageJ for the overlay creation yo can have a look Image > Overlay > Add Image... (split the channels beforehand). This creates a semi-transparent overlay of one image on top of the other. For stacks you might have to script a loop, I haven’t checked.
Example output of adding a glasbey LUT colored label image as overlay:

1 Like

In the end I went with your proposed solution of just doing it in python.
Thanks for your reply!

1 Like