CV Constant Like
The all-white mask you warp alongside the image
- nparray
- nparray
What this is for
When you warp, rotate or remap an image you are also warping the canvas - parts of the output may have no source at all. Fill those with black and you get the classic black wedges in the corner of a rotated frame. The usual fix is a second pass: build an all-white mask of the same size, warp it with the identical matrix, and then each output pixel knows whether anything covered it. Composite with that coverage mask and seams behave.
CV Constant Like is the "build the mask" step: a uint8 array of a constant value, the same width and height as some input you already have. One input for shape, one fill value, and you're done.
How it works
Only the input's width and height are used - its pixel content is ignored entirely, which makes it a shape-querying node more than a data node. It returns np.full of that shape, filled with value (0–255, default 255) in uint8.
channels is the one decision: grayscale (single channel) for masks and coverage maps, same as input to replicate the input's channel count when what you actually want is a flat colour image rather than a mask.
The pack's own framing of the use case is the one to remember, because it contains the trap: warp the coverage mask with the exact same matrix as its image, and use borderMode=BORDER_CONSTANT. Leave the border mode at the default reflection and the warp reflects the white canvas back over itself, so the output is white everywhere and the mask tells you nothing. Feeding those warped masks to CV Feather Blend is what turns a hard-warp composite into a soft one - each canvas pixel then knows which sources actually cover it, and the blend weights can be zero where there's nothing to blend.
This is plumbing in the sense the KB means for value nodes: one authoritative artefact derived from a fact about the graph (the frame size), reused in several places, instead of three nodes improvising their own idea of how big the canvas is.
Inputs and outputs
nparray- only its width/height (and, withsame as input, its channel count) are used. A ComfyUI IMAGE or MASK can plug in directly; frame 0 of a batch is what's measured.value- the fill, 0–255.channels- single-channel or matching the input.
One output: nparray, a uint8 constant array. It's an NPARRAY, so it plugs into anything in the pack's array world, and CV Array -> Mask converts it to a core mask when you're heading back into normal ComfyUI nodes.
The neighbour worth knowing about
The same module ships a deliberately dangerous sibling, ⚠️ CV ZeroStride Like - a broadcast view that allocates almost nothing and writes a single backing value everywhere. It's only safe as the in-place dst of a cv2 call that's about to fill it anyway (cv2.randu, cv2.accumulate, the drawing primitives) and is explicitly documented as never to be used as a source image, mask, or preview. If you don't know you need it, you need CV Constant Like.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
# restart ComfyUI
Or search ComfyUI CV in ComfyUI Manager (publisher bmad4ever). Needs Python ≥ 3.12, a V3-node-API ComfyUI, and opencv-contrib-python-headless~=5.0.0.93 from the pack requirements. No models, no downloads.
Common issues
- The warped coverage mask is white everywhere. Your warp's border mode isn't
BORDER_CONSTANT. Reflection turns a fully white source into a fully white destination, silently. - The mask doesn't line up with the image. It's built from the frame size of whatever you connected; if that's a crop rather than the canvas you're compositing onto, the sizes differ. Sizes are copied, not compared - nothing will complain.
CV Feather Blendis a missing node. It's in this pack, but its input nodes in the shipped examples may come from other packs (ComfyUI-Inspire-Pack,ComfyUI-Custom-Scripts,ComfyUI-basic_data_handling) - install those if a bundled workflow opens red.- Contrib nodes vanished pack-wide. A non-contrib OpenCV wheel emptied the contrib submodules in the shared
site-packages/cv2;tools/repair_opencv_contrib.py --check, then--apply.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| nparray | NPARRAY,IMAGE,MASK | Only its width/height are used. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. | |
| value | INT | 2550–255 | Fill value 0-255 (255 = white coverage mask). |
| channels | COMBO | grayscale (single channel) | Masks are single-channel; 'same as input' replicates the input's channel count for image-typed uses. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |