lo(image_01).rgb
๐จ color mapping
1], cmap="twilight", vmin=-1); # One single channel. plt.imshow(image_11[:,:,
This works, but now this would be interpreted as a 1960 196x3 RGBA images.
What I had in ming was more like 30 196x196 RGBA images (3 channels for each of the 10 images).
Keep this in mind when using cmap.
= image_01.transpose(2,0,1)[None].repeat(10, axis=0)
image_batch print(lo(image_batch))
= (image_batch + 1)/2
vals = (vals * cmap.N).astype(np.int64)
lut_idxs
= lut.take(lut_idxs, axis=0, mode="clip")
mapped
print(lo(mapped))
2]).rgb # First 2 of the images, each as 3 channels. lo(mapped[:
array[10, 3, 196, 196] n=1152480 xโ[-4.053e-09, 1.000] ฮผ=0.361 ฯ=0.248
array[10, 3, 196, 196, 4] n=4609920 xโ[0.067, 1.000] ฮผ=0.534 ฯ=0.334
Extend the lut to cover +/-inf too.
InfCmap
InfCmap (cmap:matplotlib.colors.Colormap, below:Optional[str]=None, above:Optional[str]=None, nan:Optional[str]=None, ninf:Optional[str]=None, pinf:Optional[str]=None)
*Matplotlib colormap extended to have colors for +/-inf
Parameters extept cmap
are matplotlib color strings.*
Type | Default | Details | |
---|---|---|---|
cmap | Colormap | Base matplotlib colormap | |
below | Optional | None | Values below 0 |
above | Optional | None | Values above 1 |
nan | Optional | None | NaNs |
ninf | Optional | None | -inf |
pinf | Optional | None | +inf |
= InfCmap(get_cmap("twilight"),
tcmap ="blue", above="red", nan="yellow")
below0])) # Note: Mapped only first channel rgb(tcmap(bad_image[:,:,
= InfCmap(get_cmap("twilight"),
tcmap ="blue", above="red",
below="yellow", ninf="cyan", pinf="fuchsia")
nan0]) # Note: Mapped all channels, show only the mapping for the first. rgb(tcmap(bad_image)[:,:,
= InfCmap(get_cmap("bwr"),
tcmap ="blue", above="red",
below="yellow", ninf="cyan", pinf="fuchsia")
nan2,0,1))) rgb(tcmap(bad_image.transpose(