ComfyUI Node
CV Back Project
Scores every pixel by how common its color was in a reference histogram (cv2.calcBackProject): the output map is bright where the pixel's value fell in a well-filled bin and 0 elsewhere - a soft 'how much does this look like the reference?' segmentation. Compute the histogram with 'CV Histogram' (normalize 'peak = 255') over the SAME color space, and repeat its channels + ranges here. Chain the map into 'CV Track Window' (meanShift/CamShift), threshold it into a mask, or view it with 'Preview CV Array' (heatmap). An all-zero histogram simply yields an all-zero map.
CV Back Project
- image
- histogram
- backprojection
◄channels0►
◄ranges0, 256►
◄scale1.0►
Categoryimage/CV/segmentation
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | NPARRAY,IMAGE | Array to score, in the SAME color space the histogram was computed in (convert with cv2_cvtColor first). Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. | |
| histogram | NPARRAY | Reference histogram from 'CV Histogram' - use normalize 'peak = 255' there so the map spans the full 0..255 range. | |
| channels | STRING | 0 | Channel indices to histogram, comma-separated, e.g. '0' (hue of an HSV array) or '0, 1' (hue + saturation). Must exist in the image. |
| ranges | STRING | 0, 256 | Value range per channel as 'lo, hi' pairs, comma-separated and flattened, e.g. '0, 180' for 8-bit hue or '0, 180, 0, 256' for hue + saturation. A single pair broadcasts to every channel. 'hi' is EXCLUSIVE (8-bit full range = 0, 256). Must repeat the values the histogram was computed with. |
| scale | FLOAT | 1.00–1000000 | Multiplier on the output scores (uint8 output saturates at 255). 1 = use the histogram values as-is. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| backprojection | NPARRAY | Per-pixel likeness map, same height/width and dtype as the image (uint8 in, uint8 out; single channel). Bright = matches the reference colors. |