Nodes/comfyui_cv/CV Find Transform (ECC)
ComfyUI Node

CV Find Transform (ECC)

Direct (intensity-based) image registration: estimates the geometric transform that aligns 'image' onto 'template' by maximizing the ECC correlation (cv2.findTransformECC) - no keypoints needed, ideal for small shifts/rotations between frames of a burst or a golden template. Color inputs are converted to grayscale internally. Apply the result with cv2.warpAffine (or warpPerspective for MOTION_HOMOGRAPHY), dsize = the template's size, flags = 'INTER_LINEAR | WARP_INVERSE_MAP' to pull the image into the template's frame. Robust by design: raw cv2 RAISES when the iteration does not converge (e.g. featureless or unrelated images) - this node instead returns found=false with an identity matrix that warps to a no-op, so the workflow keeps running; branch on 'found' with a control-flow node (e.g. Basic data handling's 'if/else').

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Find Transform (ECC)
  • template
  • image
  • mask
  • warp_matrix
  • correlation
  • found
motion_typeMOTION_EUCLIDEAN
iterations100
epsilon0.0000
gauss_filt_size5
min_correlation0.00
Categoryimage/CV/features

Inputs (8)

NameTypeDefaultDescription
templateNPARRAY,IMAGEReference image the other one is aligned TO. 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.
imageNPARRAY,IMAGEImage to align onto the template. 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.
motion_typeCOMBOMOTION_EUCLIDEANTransform model to estimate: TRANSLATION (2 dof), EUCLIDEAN (shift + rotation, 3 dof), AFFINE (6 dof) or HOMOGRAPHY (8 dof, 3x3). Fewer degrees of freedom converge more reliably.
iterationsINT1001–5000Maximum ECC refinement iterations.
epsilonFLOAT0.00000–1Stop when the correlation improves by less than this between iterations (smaller = more precise, slower).
gauss_filt_sizeINT51–101Odd size of the Gaussian blur applied internally before matching - smooths noise so the optimization does not chase it. 1 = no smoothing.
min_correlationFLOAT0.00-1–1Minimum final ECC correlation for 'found' to be true (1 = perfect). 0 accepts any converged estimate; raise it to reject dubious alignments.
maskoptNPARRAY,MASKOptional mask on the IMAGE being aligned: non-zero pixels participate in the alignment. 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.

Outputs (3)

NameTypeDescription
warp_matrixNPARRAY2x3 float32 transform (3x3 for MOTION_HOMOGRAPHY) mapping template coordinates into the image - use WARP_INVERSE_MAP when warping the image back. Identity if not found.
correlationFLOATFinal ECC correlation coefficient (1 = perfect alignment; 0.0 when not found).
foundBOOLEAN