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

Primitive Color YCbCr (MD)

Y′CbCr to hex — for the video people in the room

By MdONeilsl·Created 2 months ago·Updated 2 months ago· 0
Primitive Color YCbCr (MD)
    • int
    • HEX
    Luma0.000
    BlueDiff0.000
    RedDiff0.000

    Y′CbCr is the color space of video - luma plus two chroma-difference channels, the thing your camera and codecs work in before RGB ever enters the picture. If you've ever worked with broadcast specs, scopes, or a video color pipeline, you've seen values like these. mdPrimitiveColorYCbCr converts a Y′CbCr triple into a packed RGB integer and a #RRGGBB hex string, which is a niche but genuinely handy thing when a video spec hands you color values and you want them as a hex code in your ComfyUI graph.

    How it works

    The inputs are Luma plus the two chroma differences:

    • Luma - brightness, 0 to 1.
    • BlueDiff (Cb) - the blue minus luma difference, −0.5 to 0.5.
    • RedDiff (Cr) - the red minus luma difference, −0.5 to 0.5.

    The node applies the standard Y′CbCr→RGB matrix (R = Y + 1.402·Cr, and so on), clamps, and packs the result as (R << 16) | (G << 8) | B. All zeros gives you black; a Luma of 1 with both chroma differences at 0 gives white. Same int-and-hex output contract as the other primitive color nodes in the pack.

    The inputs and outputs

    • Luma - 0 to 1, default 0.
    • BlueDiff - −0.5 to 0.5, default 0.
    • RedDiff - −0.5 to 0.5, default 0.
    • Output int - packed color integer (0–16777215).
    • Output HEX - hex string.

    Install

    Part of the MdColorMod pack - no dependencies, no model files:

    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

    The main surprise is the ranges. Cb and Cr go negative, so don't expect the friendly 0–100 percentages of the HSL/HSV siblings - this is a 0-to-1 with signed chroma space, and a value that "looks like 0.5" is a huge chroma shift, not a mild one. Also, this is the standard SD/HD matrix, not the full-range Rec.709 variant some specs use, so a video spec's exact black and white points may not land exactly on 0 and 255. If you're just trying to pick a nice color, walk away from this node - the RGB or HSL primitives are the human-facing ones. This one is for when a spec tells you the numbers.

    Categorymd/color

    Inputs (3)

    NameTypeDefaultDescription
    LumaFLOAT0.0000–1Luma (brightness) component (0-1).
    BlueDiffFLOAT0.000-0.5–0.5Blue chroma difference component (-0.5 to 0.5).
    RedDiffFLOAT0.000-0.5–0.5Red chroma difference component (-0.5 to 0.5).

    Outputs (2)

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