napari / napari

napari: a fast, interactive, multi-dimensional image viewer for python
https://napari.org
BSD 3-Clause "New" or "Revised" License
2.07k stars 410 forks source link

Window leveling and Opacity mapping #6879

Open shainatorumc opened 2 weeks ago

shainatorumc commented 2 weeks ago

🚀 Feature

In addition to contrast limits, it would be useful to have a window leveling adjuster for viewing 3D stacks.

Motivation

This tool would make the background disappear in 3D stacks and only show the structures of interest. This would allow for better viewing of the whole 3D structure.

Alternatives

I tried with only the adjustment of the contrast limits, but it is not sufficient.

Pitch

Similar to the Dragonfly software for 3D visualization, there would be a widget showing the histogram of the current image in view. Then the option to choose the opacity mapping to visualize the stack as desired.

Here is a screenshot of the Window leveling widget with the option to choose the Opacity mapping. Here the Bandpass Gaussian opacity mapping is chosen and the limits of the mapping were adjusted according to the image histogram (yellow lines on either side of the gaussian distribution overlayed on the image histogram)

Bandpass gaussian opacity mapping

Two images: Image above is the stack with the Bandpass Gaussian opacity mapping, while the image below is with the Left Gated Ramp opacity mapping. Scalebar

Here is a screenshot of the Window leveling widget with the Left Gated Ramp opacity mapping selected.

Left gated ramp opacity mapping
psobolewskiPhD commented 1 week ago

In case anyone else was confused like me, basically what this allows you to do is to control the opacity over pixel values. Right now in napari everything below the lower contrast limit is made transparent, but then everything above has opacity controlled by the slider. The feature requested lets you more precisely control what you want to visualize, particularly useful if you have just one channel, but different structures at different intensities.

shainatorumc commented 1 week ago

Thanks @psobolewskiPhD for clarifying the requested feature! Your explanation is exactly right.

Czaki commented 1 week ago

For me, it looks like something that should be implemented first using a plugin, that will generate a custom colormap. This will speed up validation and testing. Having validated the plugin, then we could think about including it by default.