CV Chromatic Aberration Correction
Real lateral-CA fixes need a calibration file, and it has to exist
- image
- IMAGE
What this is for
Lateral chromatic aberration - colour fringing that grows towards the corners - is a lens defect, not a vibe. It's also, in the AI-image world, something people add on purpose to make renders look photographed; WAS Node Suite has had a chromatic aberration effect forever, and "add CA" is a normal finishing move. This node does the opposite, correctly: it removes the real, measured fringing of a specific camera using a polynomial per-channel distortion model, the same way a raw developer does.
That makes it a niche node with a clear use: footage or photos from one camera that you're processing in ComfyUI and want to be geometrically clean before something downstream (stitching, stereo, calibration, a big upscale) amplifies the fringes.
How it works
It calls cv2.correctChromaticAberration with coefficients loaded by cv2.loadChromaticAberrationParams from a .yaml/.xml file. Calibration is per-camera - a different lens or focal length is a different file. For a 3-channel image the correction is applied directly; for single-channel raw Bayer input, bayer_pattern tells OpenCV's demosaic step how to unpack it, which happens inside the same call.
One detail worth knowing: if your frame doesn't match the calibration's recorded size, the node resizes to the calibrated size, corrects, and resizes back. So it won't silently refuse, but you're correcting at a scale the coefficients were fitted for, which is the honest thing to do.
Inputs and outputs
Two required, one optional:
image- the frame to correct; batches are processed frame by frame.calibration_file- a dropdown listing.yaml/.xmlfiles frominput/calib/. Files added while a session is running need a page reload before they show up, because node definitions are fetched at load time (same trap as theLoad Imagedropdowns).bayer_pattern- only matters for single-channel raw input; ignored when the image already has 3 channels. Leave the default unless you know your CFA layout.
One output: IMAGE, corrected.
Getting a calibration file - read this before you plan around it
The node's own description points at apps/chromatic-aberration-calibration/ca_calibration.py, a script that photographs a black-disc-on-white target and writes the parameters. That apps/ directory is not in the shipped repository - I checked the clone, and it isn't there. So the workflow is real and the file format is real (cv2.loadChromaticAberrationParams reads it), but you are currently on your own for producing the calibration, using OpenCV's own CA calibration sample. Without a file, the node raises a message telling you to drop one in input/calib/ - which is at least a clear failure rather than a black frame.
If you only want fringing added rather than removed, that's the sibling node CV Apply Chromatic Aberration, which is fed by CV Create CA Calibration and needs no external script.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
# restart ComfyUI
Manager users: search ComfyUI CV (bmad4ever). Needs Python ≥ 3.12, a V3-node-API ComfyUI, and opencv-contrib-python-headless~=5.0.0.93. cv2.correctChromaticAberration is recent OpenCV API, so a very old cv2 in your environment is a real possibility to check for - python -c "import cv2; print(cv2.__version__)" should read 5.x-ish.
Common issues
- "No calibration file selected". The dropdown was left on the empty entry. Drop a file in
ComfyUI/input/calib/and reload the page. - Your new calibration file isn't in the dropdown. Reload; the list is built when node definitions are fetched.
- Node missing, or
AttributeErroroncorrectChromaticAberration. You're on an OpenCV build that predates the function. The pack is curated againstopencv-contrib-python-headless 5.0.0.93. - Contrib nodes disappeared after installing another pack. All the OpenCV wheel distributions share one
site-packages/cv2, so a non-contrib install quietly empties the contrib submodules.python tools/repair_opencv_contrib.py --check, then--apply.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Input image to correct. A batch is processed frame by frame. | |
| calibration_file | COMBO | Calibration file from input/calib/ (.yaml/.xml). Refresh node definitions (reload the page) to pick up files added during the same session. | |
| bayer_patternopt | COMBO | COLOR_BayerRGGB2BGR | Bayer CFA layout for single-channel raw input. Ignored when the image already has 3 channels. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |