Nodes/comfyui_cv/CV Take By Index
ComfyUI Node

CV Take By Index

Looks every element of an integer array up in a table and returns what it found: table row i replaces index value i. With the (K,C) palette of 'CV Reduce Array By Label' and the label map that produced it, this paints each region with its own colour; it equally maps a per-component area or score (from 'cv2.connectedComponentsWithStats') into a heat map. Unlike cv2.LUT it has no 256-entry limit and takes any integer dtype.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Take By Index
  • table
  • index
  • values
out_of_rangeclamp
fill_value0.00
Categoryimage/CV/low-level

Inputs (4)

NameTypeDefaultDescription
tableNPARRAYLookup table, (K,) or (K,C...): row i is the value that index i stands for. Its dtype is preserved.
indexNPARRAYInteger array of any shape - typically an [H,W] label map. Each element is replaced by the corresponding table row.
out_of_rangeCOMBOclampWhat to do with an index outside 0..K-1: clamp to the nearest row, wrap around (modulo K, for a repeating palette), or write 'fill_value'.
fill_valueoptFLOAT0.00-1000000000000–1000000000000Value written for out-of-range indices when out_of_range is 'fill' (cast to the table's dtype).

Outputs (1)

NameTypeDescription
valuesNPARRAYThe gathered array: the shape of 'index' plus the table's trailing axes, in the table's dtype. An [H,W] index over a (K,3) table gives [H,W,3] - cast it to uint8 with 'CV Cast Array' to preview it.