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

Photometric PALETTE tiff colormap bug #32

Closed
GenevieveBuckley opened this issue Jul 9, 2024 · 0 comments · Fixed by #33
Closed

Photometric PALETTE tiff colormap bug #32

GenevieveBuckley opened this issue Jul 9, 2024 · 0 comments · Fixed by #33
Labels
bug Something isn't working

Comments

@GenevieveBuckley
Copy link
Collaborator

Problem

Opening tiff files with the photometric PALETTE value results in a new custom colormap being added to the napari colormap dropdown list. And if you open multiple images like this, you get multiple custom colormaps (one for each tiff image opened).

How to reproduce

  1. Download the "bali.tif" image from https://github.com/tlnagy/exampletiffs and check it uses the PHOTOMETRIC.PALETTE
from tifffile import TiffFile, PHOTOMETRIC

tif = TiffFile("bali.tif")
assert tif.series[0].pages[0].photometric == PHOTOMETRIC.PALETTE
  1. Drag and drop the "bali.tif" image onto an open napari viewer (with the napari-tiff plugin installed in your napari environment). Observe that the image opens, and a new colormap called [unnamed colormap: 0] has appeared in the list of colormaps.

  2. Again, drag and drop the "bali.tif" image onto the napari viewer a second time. Observe that a second copy of the image opens, and the colormap associated with it is called [unnamed colormap: 1]

Extra details

This is the relevant section of code:

if page.photometric == PHOTOMETRIC.PALETTE and page.colormap is not None:
# PALETTE
colormap = page.colormap
if numpy.max(colormap) > 255:
colormap = colormap / 65535.0
else:
colormap = colormap / 255.0
colormap = colormap.astype("float32").T

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant