Nodes/opencv-comfyui/OpenCV randn_1
ComfyUI Node

OpenCV randn_1

The Gaussian-noise node's identical twin

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV randn_1
  • dst
  • mean
  • stddev
  • nparray

randn_1 is randn_0 wearing a different name tag. Same cv2.randn call, same three inputs, same noisy output. The _0/_1 split is a side effect of this pack auto-generating one node per OpenCV overload stub - and here the two stubs were indistinguishable, so you get two copies of the same thing. Pick randn_0 or randn_1; nothing about your workflow changes.

What the node does, for anyone who landed here first: fills an image with Gaussian noise. You hand it a target array, a mean, and a standard deviation, and every pixel gets overwritten with a sample from that normal distribution. The shape and dtype of the dst input define the output - this is an in-place fill, not an array factory, which is the part that trips people up.

Inputs

  • dst - an NPARRAY used as a template. Its dimensions decide the noise canvas; its contents get destroyed.
  • mean - an NPARRAY with a single scalar: the distribution's center.
  • stddev - an NPARRAY with a single scalar: the spread. Bigger = noisier.

The output nparray is the noisy image, BGR, so it needs Nparrays2Image to become a Comfy IMAGE again.

The friction, honestly

The mean and stddev being arrays rather than widgets is the whole usability problem. There's no scalar widget anywhere in this node - you must source one-element NPARRAYs from elsewhere in the graph. If that sounds like more plumbing than the feature is worth, you're not wrong. For plain random noise in a generation pipeline, ComfyUI's own noise nodes (noise_seed and friends) are less ceremony. randn earns its keep in the niche cases: augmentation, denoiser benchmarking, or any place you need Gaussian specifically with a fixed canvas shape.

Install

Nothing special - this pack is just wrappers over OpenCV, no models:

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

Or find "OpenCV" in ComfyUI Manager, restart, and browse image/OpenCV. Remember batch_size==1 only, and if OpenCV itself throws the guidedFilter import error at load, that's conflicting packages with a fix linked in the README.

Short version: randn_1 is a duplicate, both copies have the same scalar-as-array quirk, and you should only bother when Gaussian fill is exactly the primitive you need.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
dstNPARRAY
meanNPARRAY
stddevNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY