Nodes/opencv-comfyui/OpenCV randu_0
ComfyUI Node

OpenCV randu_0

Uniform random noise over a canvas, the raw OpenCV way

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV randu_0
  • dst
  • low
  • high
  • nparray

randu fills an image with uniform random noise. "Uniform" is the operative word: every value between a low and high bound is equally likely, so you get flat, salt-and-pepper-style noise across the full range - unlike randn's Gaussian bell, which clusters around a mean. If you need a full-range random canvas - a noise floor, a randomized mask, an augmentation - this is the primitive. If you just want generation noise, ComfyUI's own noise nodes are closer to what the sampler actually consumes, so don't reach for this first.

Mechanically it's OpenCV's cv2.randu(dst, low, high): writes uniformly-distributed values into dst in place. The shape and dtype of dst define the output; low and high are the inclusive bounds of the range.

Inputs

  • dst - NPARRAY, the template and the victim. Its dimensions decide the canvas; its contents are overwritten with noise.
  • low - NPARRAY holding a single scalar: the minimum value.
  • high - NPARRAY holding a single scalar: the maximum value.

Output is a single nparray of noise over your canvas, BGR, ready for Nparrays2Image.

The friction

Same pattern as the sibling random nodes: there are no scalar widgets. low and high have to be numpy arrays (one element each), so you need to source 1×1 NPARRAYs from elsewhere in the graph just to say "0" and "255". That's the auto-generated-pack tax the README warns about - raw OpenCV signatures, no ergonomics. It's workable but clunky, and if the plumbing annoys you, that's a fair reason to skip this node for a purpose-built noise generator.

Also note: there's no seed input here, so two consecutive runs won't match. For an 8-bit uint8 canvas, low=(0,) and high=(255,) gives you full-range noise; to get a dimmer grain, narrow the range instead. randu_1 in the menu is a byte-identical duplicate - the generator made two nodes from two indistinguishable overload stubs, so either one is fine.

Install

No models, no downloads - just OpenCV, like every node in this pack:

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. batch_size==1 only, and a Cannot import name 'guidedFilter' from 'cv2.ximgproc' load error points at conflicting OpenCV packages - the README links the fix.

Use randu when you want flat, uniformly-distributed noise on a fixed canvas and don't mind the scalar-as-array ceremony. For bell-curve noise, randn is the sibling that does that.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
dstNPARRAY
lowNPARRAY
highNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY