Load LUT From Matplotlib
Grab a matplotlib colormap as a color LUT — viridis is right there
- lut
Load LUT From Matplotlib is the most convenient palette generator in the Mosaica pack, because it doesn't generate anything - it borrows. The matplotlib plotting library ships dozens of polished, pre-designed colormaps (viridis, plasma, turbo, magma, and friends), and this node just hands you any one of them as a lookup table. It's the "I want scientific-plot colors, not random noise" option, and it makes the pack worth installing on its own if you like that aesthetic.
This is a leaf node: one input, one output. You're never going to tune it into submission, you're just picking a color story.
How it works
The node pulls from matplotlib's registered colormaps and - here's a detail that matters - filters them down to ListedColormap instances only. The dropdown lists 46 of them: magma, inferno, plasma, viridis, cividis, twilight, turbo, and the rest. That filter is why a couple of colormaps you half-remember from matplotlib won't show up; if it's a LinearSegmentedColormap under the hood, it's excluded. The listed ones are the discrete, table-based colormaps, which is exactly what you want in a lookup table anyway.
The output lut is the colormap's colors as a 2D tensor - one RGB row per color stop. And that's the whole node. There's no range remapping here, no size control; matplotlib's colormaps are fixed-size tables, typically 256 rows.
Wiring it into a workflow
The lut output only does something once it's plugged into Apply LUT To Label Image, alongside a label_image from one of the Analyze nodes (KMeans, MeanShift, or Watershed):
MeanShift → label_image → ApplyLUTToLabelImage ← LoadLUTFromMatplotlib → lut → save.
Swap the colormap and re-run to compare palettes; the expensive clustering doesn't need to re-run for a new color choice, which is the whole reason this split-the-pipeline design exists.
The one thing to watch
Because a matplotlib colormap has a fixed number of rows, it won't always match your label count. The LUT has 256 rows and your label image has 40 labels - fine. Your label image has more distinct labels than the LUT has rows - indexing runs off the end. That's what the scale_labels_to_lut_range toggle on ApplyLUTToLabelImage is for: enable it and labels get stretched onto the LUT's range so everything resolves. If your output throws an indexing error or looks wrong, that toggle is the first thing to check.
Also remember the first row of the colormap colors your background label (label 0). Viridis starts deep purple, so a viridis-colored mosaic has a purple background unless you account for it.
Install
Same pack, same drill:
cd ComfyUI/custom_nodes
git clone https://github.com/Mason-McGough/ComfyUI-Mosaica
restart, or search "Mosaica" in ComfyUI Manager. It depends on matplotlib plus scikit-learn and opencv-python (the Analyze nodes need those); everything is CPU-side with no model downloads.
The honest pitch: if you already know the exact palette you want, this is the cleanest, most predictable LUT source in the pack - no seeds to fight, no rerolling, just a dropdown of colormaps that look like they were designed by people who care about color.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| colormap | COMBO | 46 options: magma, inferno, plasma, viridis, cividis, twilight, +40 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| lut | IMAGE | — |