Nodes/comfyui_cv/CV Slice Array
ComfyUI Node

CV Slice Array

Takes a range out of ONE axis of an array (numpy slicing). Crop a padded result back to its original size (axis 0 = rows, axis 1 = columns - one node each), pull a single column out of a detection table (start=2, stop=3 keeps the axis; see 'keep_axis'), subsample every n-th row with step, or reverse an axis with step=-1. Negative start/stop count from the end. Chain one node per axis. Out-of-range bounds CLAMP the numpy way rather than raising - an empty result is a valid outcome, not a wiring mistake.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Slice Array
  • nparray
  • nparray
axis0
start0
stop0
step1
keep_axistrue
Categoryimage/CV/low-level

Inputs (6)

NameTypeDefaultDescription
nparrayNPARRAYArray to slice. Any shape and dtype; values are not touched, only selected.
axisINT0-8–8Which axis to slice. 0 = rows (height of an image, detections of a table), 1 = columns (width), -1 = the last axis (channels). Negative counts from the end.
startINT0-2147483647–2147483647First index to keep, counting from 0. Negative counts from the end (-2 = the second-to-last).
stopINT0-2147483647–2147483647One PAST the last index to keep. 0 means 'to the end of the axis' - the common case when cropping a padded array back to a computed size, where the size arrives as a link. Negative counts from the end (-1 = drop the last element).
stepoptINT1-1024–1024Stride between kept indices. 2 = every other one. A NEGATIVE step walks backwards, and then 'start' is where it starts FROM: reversing a whole axis is start=-1, stop=0, step=-1 - with the default start=0 a backwards walk stops immediately and returns a single element. 0 is rejected (numpy does not define it).
keep_axisoptBOOLEANtrueWhen the slice keeps exactly ONE index, whether the axis survives with length 1 (True, e.g. (N,4) -> (N,1)) or is dropped (False, (N,4) -> (N,)). Off is what a downstream node wanting a flat vector of scores expects; on is what keeps a table a table.

Outputs (1)

NameTypeDescription
nparrayNPARRAYThe selected part of the input, same dtype. A view is never returned - the result is contiguous, so a later cv2 node cannot write into the original.