Nodes/MdColorMod/Primitive Color CIELAB (MD)
ComfyUI Node

Primitive Color CIELAB (MD)

L*a*b* to hex

By MdONeilsl·Created 2 months ago·Updated 2 months ago· 0
Primitive Color CIELAB (MD)
    • int
    • HEX
    L50.0
    A0.0
    B0.0

    CIELAB, or L*a*b*, is the color space designed to match how humans actually perceive color differences - which is why color scientists, paint brands and color-matching tools report colors in it. It's also cryptic if you've never met it. mdPrimitiveColorLAB is the bridge: feed it an L, an a and a b, and it gives you a packed RGB integer and a #RRGGBB hex string, so a measured LAB value can become a color in your workflow.

    How it works

    The three components mean:

    • L - lightness, 0 (black) to 100 (white). The only input that's intuitive at a glance.
    • a - the green–red axis. Negative is green, positive is red, 0 is neutral.
    • b - the blue–yellow axis. Negative is blue, positive is yellow, 0 is neutral.

    The node converts LAB back to XYZ against the D65 white point, then XYZ to sRGB with the standard matrix and gamma curve, then packs as (R << 16) | (G << 8) | B. Same output contract as the rest of the primitive color family.

    The inputs and outputs

    • L - 0 to 100, default 50.
    • A - −128 to 128, default 0. The green–red axis.
    • B - −128 to 128, default 0. The blue–yellow axis.
    • Output int - packed color integer (0–16777215).
    • Output HEX - hex string.

    The defaults - L 50, a 0, b 0 - give you a neutral mid-gray, which is a good first test: you should get a gray, not a colored surprise.

    Install

    Part of MdColorMod, zero dependencies, no models:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MdONeilsl/ComfyUI-MdColorMod
    

    Restart ComfyUI, or install via ComfyUI Manager by searching "MdColorMod".

    Where people get burned

    Two things. First, the a and b axes can genuinely surprise: positive a is red and positive b is yellow, and lots of people have them backwards for the first week. Second, like XYZ, LAB can express colors sRGB can't - a very saturated measured color will clip to the nearest displayable shade, and that's the conversion working as intended. If you're picking colors casually rather than translating measurements, the HSL or HSV primitives in this pack will be kinder.

    Categorymd/color

    Inputs (3)

    NameTypeDefaultDescription
    LFLOAT50.00–100Lightness component (0-100).
    AFLOAT0.0-128–128A component (green-red axis).
    BFLOAT0.0-128–128B component (blue-yellow axis).

    Outputs (2)

    NameTypeDescription
    intINTPacked 24-bit integer color value (0-16777215).
    HEXSTRINGHexadecimal color string (e.g., #FF0000).