Nodes/Masquerade Nodes/Unary Image Op
ComfyUI Node Runs on cloud

Unary Image Op

Per-channel invert, round, clamp on a whole image

By BadCafeCode·Created 3 years ago·Updated 2 years ago· 480
Unary Image Op
  • image
  • IMAGE
op

Unary Image Op is Unary Mask Op's sibling, and the pack's own README is upfront about the relationship: same five operations, same one-node simplicity, except this one runs on every channel of a full image independently instead of a single-channel mask. That "independently" is the whole reason it exists - you don't always want a global transform, you want each color channel doing its own thing, and that's most useful once you've converted the image into a color space where the channels actually mean something separate, like HSV.

Where it fits

Masquerade Nodes leans dependency-free and mask-arithmetic-focused rather than model-driven - its own author now points people toward Impact Pack for detection-and-refinement work, and reaches for this pack specifically when you need small, deterministic tensor operations with nothing to download. Unary Image Op is that philosophy applied to full images: no inference, just per-pixel, per-channel math, dropped into a graph wherever core ComfyUI doesn't give you a button for it.

The obvious pairing is with the pack's Convert Color Space node (RGB/HSV/HSL). Do that conversion first and Unary Image Op's per-channel behavior stops being a curiosity and becomes the actual point: invert just the Hue channel to shift colors around the wheel without touching saturation or brightness, or clamp just the Value channel to tame blown highlights - things a single global operation on RGB can't express cleanly, because in RGB, "brightness" and "color" are smeared across all three channels at once.

How it works

Same dispatch as Unary Mask Op, just vectorized across channels instead of collapsed to one. Feed it a standard image tensor and it applies the chosen operation to every channel separately rather than averaging or thresholding across the whole image as one blob. If you fed it a single-channel mask, it would behave identically to Unary Mask Op - the split into two nodes exists for clarity in the graph, not because the underlying math differs.

Inputs and outputs that matter

  • image - the image to operate on.
  • op - one of five operations, same list as Unary Mask Op:
    • invert - inverts every channel. On plain RGB this is a photo-negative. On a single converted channel (say, Hue) it's a targeted color flip instead.
    • average - every pixel in each channel gets set to that channel's average value. Applied per-channel, this collapses spatial detail while keeping each channel's overall tone - a blunt tool, but occasionally what you want for a flat reference swatch.
    • round - rounds every pixel to the nearest integer. On a normal photographic image this will look like posterization to pure black/white per channel; it's a lot more useful on channels that are meant to be near-binary already.
    • clamp - forces values back into 0–1 per channel. The safety net after any math node that can overshoot.
    • abs - absolute value per channel, for cleaning up after subtraction-style operations.

Output is a single image, ready to feed onward in your graph - into a save node, a color-space conversion back to RGB, or the next processing step.

How to install it

Via ComfyUI Manager: search "Masquerade Nodes," install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/BadCafeCode/masquerade-nodes-comfyui

then restart. Unary Image Op has no model downloads and no extra dependencies of its own - the only heavier dependency anywhere in this pack is ClipSeg, and that's specific to the Mask By Text node, loaded only when that node actually runs. Installing the pack just for this utility node won't pull it in.

Common issues & troubleshooting

invert on a normal photo looks like a negative, not a color grade. That's correct behavior for RGB - a true per-channel invert on RGB is a photographic negative by definition. If you wanted a color-wheel shift instead, convert to HSV first with Convert Color Space and invert Hue specifically, then convert back.

round turns your image into flat color blocks. Also expected - round is a hard threshold toward the nearest integer, which on 0–1 float image data means pushing every pixel toward pure 0 or pure 1 per channel. It's a niche op for near-binary data, not a general-purpose photo filter; if that's not what you wanted, you probably meant clamp.

Colors look broken after converting color spaces and back. Make sure you're converting back to RGB with Convert Color Space before saving or passing the image to anything downstream that expects standard RGB - most of the rest of ComfyUI, and most save/preview nodes, assume RGB.

The node is missing after install. That's a pack-level load failure rather than anything specific to this node - check the ComfyUI startup console for an import error under masquerade-nodes-comfyui. A fresh clone and restart is the usual fix.

CategoryMasquerade Nodes

Inputs (2)

NameTypeDefaultDescription
imageIMAGE
opCOMBO5 options: invert, average, round, clamp, abs

Outputs (1)

NameTypeDescription
IMAGEIMAGE