ComfyUI Node

Dot

The dot-product node most people misread

By CoiiChan·Created about a year ago·Updated about a year ago· 2
Dot
  • imga
  • imgb
  • IMAGE
formularesult = np.sum((imga * imgb), axis=-1)

Don't be scared off by the name - this isn't linear algebra homework. Dot computes, for every pixel, the sum of the three channel products: result = np.sum(imga * imgb, axis=-1). In plain language: it measures how much the colors at each pixel agree, weighted by how strong both are.

Two things the formula makes obvious if you read it closely. First, axis=-1 collapses the three color channels, so the output is grayscale - one value per pixel, which the node then expands back to RGB so ComfyUI is happy. Second, this is the classic channel-matching / luminance overlay operation. Where both images are bright in the same channel, the value is high; where one is dark, the product dies. It's the mathematical core of overlay-style effects, and it's a great similarity measure: two identical images give you the squared brightness everywhere, while two different images give you a map of where they agree.

Why you'd use it

  • Agreement maps. Dot two passes together and the bright areas are where they correlate. Feed that into a threshold (the pack's ifFunction or a np.where in CustomScript-NumPy) and you've built a feature mask.
  • Channel-weight tricks. Because it's per-channel multiplication before the sum, weighting one channel to zero effectively ignores it - handy for isolating a hue's contribution.
  • Squaring/brightness math. As imga * imga summed, it's a cheap way to get a brightness-weighted response curve.

Inputs and outputs

  • formula - result = np.sum((imga * imgb), axis=-1), pre-filled and editable.
  • imga - reference image, defines output resolution.
  • imgb - second image. Unconnected means zeros → output is all black. No crash, but also nothing useful; connect both.

One IMAGE output.

Install

ComfyUI Manager → search "FuncAsTexture", or:

cd ComfyUI/custom_nodes
git clone https://github.com/CoiiChan/ComfyUI-FuncAsTexture-CoiiNode
# restart ComfyUI

No models, no requirements.txt. Category: FunctionAsTexture.

Gotchas

  • The output is grayscale data wearing an RGB costume. The value is computed on the channel axis, then repeated to three channels. If you feed it somewhere expecting real color, you'll get gray - that's correct, not a bug.
  • Values can exceed 1. Three channels each up to 1.0 sum to up to 3.0 in the brightest pixels. It's a similarity score, not a display image; clamp before previewing.
  • Same-resolution rule as all the pack's two-image nodes - mismatched imga/imgb throw a shape error.

The pack's Distance node is the sibling here (Euclidean distance instead of dot product) - Dot measures agreement, Distance measures difference. Grab whichever matches the question you're actually asking.

CategoryFunctionAsTexture

Inputs (3)

NameTypeDefaultDescription
formulaSTRINGresult = np.sum((imga * imgb), axis=-1)
imgaoptIMAGEOptional ,Reference size ,Default =(1,512,512,3)
imgboptIMAGEOptional

Outputs (1)

NameTypeDescription
IMAGEIMAGE