Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

HiLO LUT #6878

Open
melonora opened this issue May 1, 2024 · 4 comments
Open

HiLO LUT #6878

melonora opened this issue May 1, 2024 · 4 comments
Labels
feature New feature or request

Comments

@melonora
Copy link
Contributor

melonora commented May 1, 2024

馃殌 Feature

Implement the HiLo LUT that is also present in FIJI for the purpose of intensity clipping as shown below:

m51-histogram-hilo

Motivation

(https://forum.image.sc/t/add-hilo-colormap-to-napari/95601/4)

@melonora melonora added the feature New feature or request label May 1, 2024
@GenevieveBuckley
Copy link
Contributor

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)

@melonora
Copy link
Contributor Author

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

@melonora
Copy link
Contributor Author

We also tried with by adjusting the controls of a custom color map, but same issue.

@melonora
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants