Kitware / itk-vtk-viewer

2D / 3D web image, mesh, and point set viewer using itk-wasm and vtk.js
https://kitware.github.io/itk-vtk-viewer/
BSD 3-Clause "New" or "Revised" License
210 stars 64 forks source link

feat(createLayersUIMachine): for 4 or more components colormap RGB+Gray #605

Closed PaulHax closed 2 years ago

PaulHax commented 2 years ago

Set first 4 component colormaps to red, green, blue, gray instead of CT-AAA when more than 4 components

http://localhost:8082/?image=https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.4/idr0101A/13457537.zarr

thewtex commented 2 years ago

Better default, but when enabling the non-default components, i.e., 4, 5, etc. they have CT-AAA, and the result is mush. :-$ :bowl_with_spoon:

->

Let's substitute 6 of the pastel color maps:

image

with the categorical color names / icons:

image

When a categorical color name is selected for one of the component color maps, we use a color map that is generated dynamically black -> ${color}, similar to the BkRd, BkGn, BkBu, i.e. something like:

import { CategoricalColors } from 'itk-viewer-color-maps'
// From selection
const colorMapName = "glasbey"
const indexedColors = CategoricalColors.get(colorMapName)
const currentComponent = getCurrentlySelectedImageActorComponent()
// We want an offset so there is contrast with label image colors
const colorOffset = 128 + currentComponent
const indexedColor = indexedColors.slice(3*colorOffset, 3*colorOffset + 3)
const cmap = {"ColorSpace":"RGB","Name":`Bk-${colorMapName}-${colorOffset}`,"NanColor":[1,1,0],"RGBPoints":[0,0,0,0,1,indexedColor[0],indexedColor[1],indexedColor[2]}

@PaulHax make sense?

thewtex commented 2 years ago

something like

This logic could go into a re-usable function(s) in itk-viewer-color-maps. A function that returns a color map for a color map name (internally it checks if the name is a categorical color and generates the cmap for the component), otherwise does the continuous color map Map lookup. And another function that generates the black -> indexedColor continuous colormap from the categorical color name and component.

PaulHax commented 2 years ago

Makes sense! Wonder if folks will make the leap that clicking "glasby/etc" will pick a color from it by component index. Perhaps another PR for this?

For quick fix for 5+ component case, loop over RGB+Gray for all higher components' default?

thewtex commented 2 years ago

Yes, we can make these improvements in the next iteration -- tracked in #607