OpenCV sort_1
Sort_1 — the pixel-sorter's duplicate overload
- src
- dst
- nparray
If you've spent any time in this pack you'll recognize the pattern immediately: sort_1 is sort_0 wearing a different suffix. cv2.sort's (src, flags, dst) signature is declared twice in OpenCV's type stubs (the MatLike and UMat forms), the pack's generator numbers both instead of deduplicating, and you get two nodes that call the same function the same way. No behavioral difference, no "better" one. The display name "OpenCV sort_1" is the whole story.
The substance - pixel sorting as a glitch effect, how the flags bitmask works, the Image2Nparray → sort → Nparrays2Image wiring - lives in the sort_0 article. This page is the duplicate's reference.
What it takes
- src (NPARRAY) - the array to sort; from an image via
Image2Nparray(batch size 1, BGR uint8). - flags (INT) - bitmask of direction and axis.
0= rows ascending,1= columns ascending,16= rows descending,17= columns descending. For the pixel-streak look,1or17. - dst (NPARRAY, optional) - out-parameter; the README says skip these, and you can - the output carries the result.
Output: one nparray, same shape as src.
Quick workflow
Image2Nparray → sort_1 (flags 1) → Nparrays2Image → preview. Both conversion nodes handle the BGR↔RGB round trip for you, so colors survive the sort. Plain sort_1 sorts the whole frame; for the mask-limited "pixel sorting" look you'll want to build a mask and apply it yourself, because this node has no region input.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python
or ComfyUI Manager → "opencv-comfyui". Restart. Deps: opencv-contrib-python, numpy, torch.
Troubleshooting
Only images with batch_size==1 are supported!- split your batch withImageFromBatch(length=1).- No visible change - try
flags1/17(columns) instead of0(rows). Cannot import name 'guidedFilter'at startup - conflicting OpenCV packages; README links the fix.
Same sort, second name. Pick either one and get the streaks.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| flags | INT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |