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.
CV Slice Array
- nparray
- nparray
◄axis0►
◄start0►
◄stop0►
◄step1►
◄keep_axistrue►
Categoryimage/CV/low-level
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| nparray | NPARRAY | Array to slice. Any shape and dtype; values are not touched, only selected. | |
| axis | INT | 0-8–8 | Which 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. |
| start | INT | 0-2147483647–2147483647 | First index to keep, counting from 0. Negative counts from the end (-2 = the second-to-last). |
| stop | INT | 0-2147483647–2147483647 | One 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). |
| stepopt | INT | 1-1024–1024 | Stride 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_axisopt | BOOLEAN | true | When 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)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | The 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. |