Nodes/comfyui_cv/CV Stitch Canvas
ComfyUI Node

CV Stitch Canvas

Computes the output canvas for stitching two images: given the homography that maps image_warp into image_ref's frame (from 'CV Find Homography'), it projects image_warp's corners, takes the union with image_ref's rectangle, and outputs the canvas size plus the matrices that place each image on that canvas: warp_matrix (= translation x homography) for image_warp and ref_matrix (a pure translation) for image_ref. Feed both into cv2.warpPerspective with the dsize output and borderMode=BORDER_CONSTANT (the default BORDER_DEFAULT reflects the image into the empty canvas area, which breaks the coverage masks), then combine with 'OpenCV Feather Blend'. Robust: a degenerate homography (non-finite projection) is treated as identity, and the canvas is capped at max_size per axis - the reference frame always stays fully contained, so a bad estimate can never allocate a huge image.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Stitch Canvas
  • image_warp
  • image_ref
  • homography
  • warp_matrix
  • ref_matrix
  • dsize
  • width
  • height
  • size
max_size8192
Categoryimage/CV/features

Inputs (4)

NameTypeDefaultDescription
image_warpNPARRAY,IMAGE,MASKImage that the homography maps into the reference frame (only its size is used here). 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.
image_refNPARRAY,IMAGE,MASKReference image; stays axis-aligned on the canvas (only its size is used here). 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.
homographyNPARRAY3x3 matrix mapping image_warp coordinates to image_ref coordinates.
max_sizeINT8192256–32768Canvas width/height cap in pixels - protects against degenerate homographies that would project corners kilometers away.

Outputs (6)

NameTypeDescription
warp_matrixNPARRAY3x3 matrix that places image_warp on the canvas (translation x homography).
ref_matrixNPARRAY3x3 translation that places image_ref on the canvas.
dsizeSTRING'(width, height)' canvas size literal, for the composite params that are still free-text.
widthINT
heightINT
sizeCV_TUPLEThe canvas (width, height) as ONE composite value - wire it into cv2.warpPerspective's dsize.