Nodes/opencv-comfyui/OpenCV broadcast_0
ComfyUI Node

OpenCV broadcast_0

Numpy-style array stretching, with the pack's rough edges showing

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV broadcast_0
  • src
  • shape
  • dst
  • nparray

Broadcasting is numpy's trick of taking a small array and expanding it to a bigger shape without copying data - think "repeat this gradient across the whole image" or "stretch this single-row tint across every row." OpenCV broadcast_0 wraps cv2.broadcast(src, shape, dst), which does the same thing on OpenCV's side. In image terms it's how you turn a small pattern, a 1-row color wash, or a single-channel weight into a full-size array that matches your image's shape for per-pixel math.

The honest part: this is one of the roughest nodes in the pack, because the auto-generator typed the shape parameter as an NPARRAY. cv2.broadcast expects a size - a (width, height) style descriptor - not an image, and the node hands whatever you wire in straight through as an array. So you can't just type "I want it 1024×1024" into a widget the way you'd like. You end up feeding the node an array whose shape you're willing to adopt, which is a genuinely awkward way to specify a target size. It works for a narrow pattern (wire in a tiny array, get it stretched to match a larger one), but it's a prime example of the README's warning that these nodes are "ugly and complex to use" and that "not every function is useful within ComfyUI without further processing."

Inputs

  • src - the NPARRAY to broadcast (the small thing).
  • shape - NPARRAY (the awkward one): the target shape, expressed as an array rather than a size widget.
  • dst (optional) - out-parameter; leave unwired.

Output: one nparray - src stretched to the target shape.

When would you actually reach for it?

Honestly, rarely, and you should know that before you sink time into it. If your real goal is "fill an image with a constant or a gradient," ComfyUI's own primitive and image-fill nodes, or a simple torch op in a utility pack, will get there with less friction. broadcast earns its place in a ComfyUI graph only when you're already deep in array-land - building per-pixel weight maps, doing manual channel math - and you specifically want the numpy-style expansion without leaving the graph. For that narrow lane it's the right primitive: deterministic, instant, no model involved.

Install

ComfyUI Manager → opencv-comfyui, or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, restart. Needs opencv-contrib-python. Batch size 1 only, NPARRAY in means you own the BGR/uint8 conventions - same pack-wide rules as every sibling. If the node errors with a type assertion, it's the shape slot doing what it does best: being an image socket where a size belongs. This is the pack's generation artifacts showing, and there's no pretty fix on your side.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
srcNPARRAY
shapeNPARRAY
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY