Nodes/comfyui_cv/Preview CV Array
ComfyUI Node

Preview CV Array

Previews a raw ndarray directly - no manual conversion needed. 'image' renders uint8/float data as-is, 'normalize' min-max stretches it (gradients, disparity, score maps), 'heatmap' additionally applies a colormap. Multi-channel normalize/heatmap previews draw channels as a 2x2 quadrant view with one shared value scale, or set 'reduce_channels' to collapse them into a single map instead (the only way to preview more than 4 channels, e.g. a LATENT). Enable 'color_scale' to draw a labelled value bar beside the preview (the bar keeps a legible height even for tiny or 1-pixel arrays). A batched input previews EVERY frame; by default each frame stretches on its OWN value range, which makes frames incomparable - 'range_mode' switches to one shared range or a fixed vmin..vmax. The label column is sized to the widest labels in the batch so all frames come out the same width. NON-FINITE pixels (NaN/Inf, common in distanceTransform, optical-flow and score maps) are excluded from the value range and painted in a marker colour the active colormap cannot produce, so they cannot be mistaken for data: PURE RED (0, 0, 255) for viridis and for the grey ramp, magenta or cyan for maps that contain red (JET, HOT, AUTUMN). 'Inspect CV Data' reports how many there were. Also returns the rendering as IMAGE for further chaining.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
Preview CV Array
  • nparray
  • image
renderimage
color_scalefalse
reduce_channelsKEEP_ALL
colormapCOLORMAP_VIRIDIS
range_modeper frame (auto)
vmin0.00
vmax1.00
clip_percent0.0
Categoryimage/CV/low-level

Inputs (9)

NameTypeDefaultDescription
nparrayNPARRAY,IMAGE,MASK2-D or 3-D ndarray to render. image mode supports 1/3/4 channels; normalize/heatmap support 1/2/3/4 channels and draw multi-channel inputs as quadrants. More channels than that need 'reduce_channels'. A batched IMAGE/MASK/LATENT or a 4-D [B,H,W,C] array renders every frame. For other shapes use 'Inspect CV Data' instead.
renderCOMBOimageimage: show uint8/float values as-is. normalize: min-max stretch to 0-255 (for gradients/disparity/score maps). heatmap: normalize then apply the 'colormap' palette.
color_scaleoptBOOLEANfalseDraw a vertical colour/value scale bar with min..max labels next to the preview. The labels are the array's value range ('normalize'/'heatmap' map that range to the bar exactly). On a batch each frame gets its own range unless 'range_mode' says otherwise, and the label column is widened to the batch's widest labels so the frames stay the same width (the surplus is black).
reduce_channelsoptCOMBOKEEP_ALLCollapse a multi-channel array to ONE 2-D map before rendering, instead of drawing the channels as quadrants. KEEP_ALL leaves the array alone. REDUCE_SUM/AVG/MAX/MIN/SUM2 are cv2.reduce's reductions across the channel axis. MAGNITUDE_L2 is sqrt(sum of squares) - use it for SIGNED fields (optical flow, gradients), where AVG and SUM cancel to near zero. This is also the only way to preview an array with more than 4 channels, such as a LATENT. The reduction runs in float32, so SUM cannot wrap.
colormapoptCOMBOCOLORMAP_VIRIDISPalette for 'heatmap' (ignored by the other render modes). VIRIDIS/INFERNO are perceptually uniform and the right default for data; JET is the classic rainbow and misreads as structure. The colour bar and the NaN marker both follow this choice.
range_modeoptCOMBOper frame (auto)Which value range 'normalize'/'heatmap' stretch to 0-255 (ignored by 'image'). per frame: each frame uses its own min..max - the default, but it makes the frames of a batch incomparable and a near-static sequence flicker. batch: one min..max shared by every frame. manual: the fixed 'vmin'..'vmax' below, with out-of-range values clamped.
vminoptFLOAT0.00Bottom of the value range, used only when 'range_mode' is manual. If vmin >= vmax the node falls back to the automatic range rather than failing.
vmaxoptFLOAT1.00Top of the value range, used only when 'range_mode' is manual.
clip_percentoptFLOAT0.00–49Robust stretch for the automatic range modes: ignore this percentage of values at EACH end when picking min..max, so a single outlier (a hot pixel, a huge distanceTransform corner) cannot flatten the rest of the map to black. 2.0 is a good starting point. 0 = plain min..max. Ignored when 'range_mode' is manual.

Outputs (1)

NameTypeDescription
imageIMAGE