Open melonora opened 2 weeks ago
This seems pretty easy to do:
from napari.utils.colormaps import AVAILABLE_COLORMAPS
hilo = AVAILABLE_COLORMAPS['gray']
hilo.colors[0] = [0, 0, 1, 1] # blue (lowest pixel values)
hilo.colors[-1] = [1, 0, 0, 1] # red (highest pixel values)
And checking that it works:
# check with uint8 data
import napari
import skimage.data
viewer = napari.Viewer()
camera = skimage.data.camera()
viewer.add_image(camera, colormap=hilo)
# check with float data
import napari
import numpy as np
viewer = napari.Viewer()
data = np.random.random((20, 20))
viewer.add_image(data, colormap=hilo)
Thought so too but @Czaki and I checked this and this does not seem to be correct. We had the same approach, but due to conversion to uint8 in vispy for a 16 bit image for example the intensity values are binned. This means that if you have intensity values of both 0 and 1 in your 16 bit image, both will be blue, which should not be the case.
A shader is required
We also tried with by adjusting the controls of a custom color map, but same issue.
import napari
from skimage.data import cells3d
data=cells3d()
viewer = napari.Viewer()
data[:,1, 90:110, 90:110] = 65535
data[:,1, 110:130, 110:130] = 65534
data[:,1, 140:160, 140:160] = 0
data[:,1, 170:190, 170:190] = 1
viewer.add_image(data, channel_axis=1)
napari.run()
If you run this you will see that when switching to HiLo LUT that values 1 are blue and 65534 are red which should not happen. The image itself is 16bit
🚀 Feature
Implement the HiLo LUT that is also present in FIJI for the purpose of intensity clipping as shown below:
Motivation
(https://forum.image.sc/t/add-hilo-colormap-to-napari/95601/4)