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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HiLo colormap #6906

Closed
wants to merge 2 commits into from
Closed

Conversation

GenevieveBuckley
Copy link
Contributor

@GenevieveBuckley GenevieveBuckley commented May 10, 2024

References and relevant issues

Closes #6878
Reference: https://forum.image.sc/t/add-hilo-colormap-to-napari/95601

Description

Adds a HiLo colormap.
A HiLo colormap is a grayscale colormap, with the exception that the maximum pixel value is shown in red, and the minimum pixel value shown in blue.

This type of colormap is useful for quickly scanning images to see if there is unintended clipping of image values at the top and/or bottom of the intensity range.

@GenevieveBuckley
Copy link
Contributor Author

Questions/problems:
-[ ] Is this the right place in the code for this to live?
-[ ] Why doesn't this show up automatically in the GUI dropdown list of colormaps? Is there another place I need to update code?
-[ ] Why does the shade of blue or red seem to vary when applied to float data? (Maybe we leave this question for a future PR?)

Minimal reqproducible example:

from napari.utils.colormaps.colormap_utils import vispy_or_mpl_colormap

hilo_colormap = vispy_or_mpl_colormap('gray')
hilo_colormap.colors[0] = [0, 0, 1, 1]   # blue (lowest pixel values)
hilo_colormap.colors[-1] = [1, 0, 0, 1]  # red  (highest pixel values)

import napari
import skimage.data
viewer = napari.Viewer()
camera = skimage.data.camera()
viewer.add_image(camera, colormap=hilo_colormap)
# or if you have this PR branch checked out, you can do...
# viewer.add_image(camera, colormap='hilo')

Screenshot:
Screenshot 2024-05-10 at 6 38 14 pm

@GenevieveBuckley GenevieveBuckley marked this pull request as draft May 10, 2024 09:07
Copy link

codecov bot commented May 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.43%. Comparing base (f195690) to head (a9fbe3b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6906      +/-   ##
==========================================
- Coverage   92.45%   92.43%   -0.02%     
==========================================
  Files         614      614              
  Lines       55164    55169       +5     
==========================================
- Hits        51001    50998       -3     
- Misses       4163     4171       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@GenevieveBuckley
Copy link
Contributor Author

Closing, in favor of the approach suggested by melonora:

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

See #6878 (comment)

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

Successfully merging this pull request may close these issues.

HiLO LUT
1 participant