Nodes/comfyui_cv/CV Disparity Interpolate (Edge-Aware)
ComfyUI Node

CV Disparity Interpolate (Edge-Aware)

Turns a HOLEY disparity map into a dense one by interpolating its trustworthy pixels with a local PLANE model (cv2.ximgproc RICInterpolator / EdgeAwareInterpolator), guided by the rectified left image. Use it instead of 'cv2.inpaint' (image-blind: smears disparity across object silhouettes) and instead of relying on the WLS filter to fill: WLS assumes locally CONSTANT disparity, so it bends a textureless slanted surface like a road into a ridge - measured on the shipped driving pair, a plane fit through the road band degrades from 0.06 m RMS to 0.36 m, while this node keeps 0.06 m at ~100% coverage. Feed it the RAW matcher output (plus the WLS 'confidence' map if you have one, to drop unreliable seeds). The pair must be RECTIFIED. Failure-tolerant: with too few seeds it returns the input disparity unchanged and found=false.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Disparity Interpolate (Edge-Aware)
  • left
  • right
  • disparity
  • confidence
  • disparity
  • valid
  • seeds
  • found
methodRIC (superpixel plane fit)
min_disparity0.05
confidence_threshold128
k32
superpixel_size15
post_smoothingglobal smoother (recommended)
max_seeds30000
Categoryimage/CV/contrib

Inputs (11)

NameTypeDefaultDescription
leftNPARRAY,IMAGERectified LEFT frame - the guide whose edges and superpixels the interpolation follows. 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.
rightNPARRAY,IMAGERectified RIGHT frame. Same size as 'left'; the interpolators take both views of the match set. 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.
disparityNPARRAYHxW float disparity in PIXELS with holes (negative / zero where the matcher failed), e.g. 'CV Stereo Disparity (SGBM)' or the 'disparity_raw' output of the WLS node.
methodCOMBORIC (superpixel plane fit)RIC fits a plane per SLIC superpixel and keeps silhouettes best (~0.2 s at 640x480); EPIC (EpicFlow) is ~2x faster and slightly smoother on flat ground but blurrier at depth edges. RIC randomizes its model fitting, so its output varies slightly run to run; EPIC is deterministic.
min_disparityFLOAT0.05-256–256Disparity above which an input pixel counts as a seed. The SGBM nodes mark invalid pixels below min_disparity, so the default keeps everything positive.
confidenceoptNPARRAYOptional HxW confidence map (0-255), e.g. the 'confidence' output of 'CV Stereo Disparity (WLS filtered)'. Seeds below the threshold are dropped, which is how occlusions and failed left-right checks stay out of the fit.
confidence_thresholdoptFLOAT1280–255Minimum confidence for a seed (ignored when no confidence map is connected).
koptINT324–256Neighbouring seeds used to fit each local model. Larger = smoother and slower.
superpixel_sizeoptINT154–64RIC only: average SLIC superpixel side in pixels. Smaller follows finer structure at more cost.
post_smoothingoptCOMBOglobal smoother (recommended)Run the edge-aware global smoother over the interpolated result. 'none' leaves the raw per-superpixel planes visible as blocky steps (measured: edge alignment 89% -> 53%).
max_seedsoptINT3000064–32000Seeds are subsampled to at most this many. cv2 ASSERTS on 32767 or more (match_num < SHRT_MAX), and a full 640x480 map has ~180k valid pixels, so this cap is not optional.

Outputs (4)

NameTypeDescription
disparityNPARRAYHxW float32 dense disparity in pixels.
validNPARRAYuint8 0/255 mask of pixels with a disparity above min_disparity (near-complete after a successful interpolation).
seedsNPARRAYuint8 0/255 mask of the input pixels actually used as seeds - preview it to see what the fit was given.
foundBOOLEANFalse when there were too few seeds to interpolate; the input disparity is passed through unchanged.