Nodes/OpenCV/OpenCV randShuffle_0
ComfyUI Node

OpenCV randShuffle_0

Scramble a picture into static with OpenCV randShuffle

By geroldmeisinger·Created 2 years ago·Updated 2 years ago· 35
OpenCV randShuffle_0
  • dst
  • nparray
◄iterFactor—►

randShuffle scrambles the pixels of an image. OpenCV's version picks random pairs of elements and swaps them, over and over, so after enough swaps the picture is unrecognizable static - the histogram survives (same pixels, new positions) but the image is gone. It's a randomness primitive more than an image filter, and honestly it's one of the more "why does this exist in a ComfyUI graph?" nodes in this pack. If you've ever wanted a fully scrambled version of a reference image to use as a texture, an augmentation, or a visual "obfuscated this" joke in a workflow, this is the node. That's a short list, and it's the honest one.

The mechanism: cv2.randShuffle(dst, iterFactor) swaps random element pairs in place. iterFactor multiplies the array element count to decide how many swaps happen - higher iterFactor, more scrambled. At 1 you get moderate scrambling; crank it up and it's pure static. As with the other random-fill nodes here, dst is the template and the victim: the array you pass in defines the canvas and then gets destroyed.

Inputs

  • dst - NPARRAY. Its contents get shuffled in place; its shape defines the output. Pass whatever image (BGR, post-Image2Nparray) you want destroyed.
  • iterFactor - a float. Roughly "how many times over" the element count to run swaps. 1.0 is a decent start; 10.0 is fully scrambled.

Output is a single nparray of the same shape, same pixel values, new arrangement. Route through Nparrays2Image to get back a Comfy IMAGE.

A couple of things to set expectations: this shuffles at the element level across the whole array, not per-image-region, so you won't get a blocky mosaic - you get fine-grained static. And there's no seed input, so results aren't reproducible per run (OpenCV's global RNG is at play; if you need determinism you'd have to seed it elsewhere). randShuffle_1 in the menu is a byte-identical duplicate, since the generator couldn't distinguish the two overload stubs - either works.

Install

Same as the rest of the pack - no models, OpenCV is the only real dependency:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python

Or search "OpenCV" in ComfyUI Manager, restart, and it's under image/OpenCV. Only batch_size==1 is supported, and if you see Cannot import name 'guidedFilter' from 'cv2.ximgproc' on load, you have conflicting OpenCV packages - known problem, fix documented in the README.

Verdict: fun, occasionally useful, never essential. If your actual goal is noise for a pipeline, randn or randu are usually the better fit. randShuffle is for when "same colors, no structure" is literally what you want.

Categoryimage/OpenCV

Inputs (2)

NameTypeDefaultDescription
dstNPARRAY—
iterFactorFLOAT—

Outputs (1)

NameTypeDescription
nparrayNPARRAY—