SMC Affine Compand
Measure the drift, then pull it back.
- anchor_image
- target_image
- mask
- original_image
- profile
- corrected
- warped_target
- diagnostics
- stats_json
SMC Affine Compand (class SMCAffineCompand) is the correction engine of the pack's affine path - the older, more explicit sibling of SMC Anchor-Guided Compand. Where the anchor-guided node derives a radial inward flow from a mask and estimates expansion, this one fits an actual affine transform (scale + translation) between your anchor and your drifted target, warps the target inward along it, restores low-frequency color toward the anchor, re-adds detail, and hands you the corrected image plus a diagnostics panel.
It's the node to reach for when you want to understand the correction, not just apply it - the README frames the affine path as the diagnostic/interpretable route, and the pack's Impact Pack hook also runs this path internally. If you're correcting FLUX.2 Klein detail-crop drift - the outward zoom, the washout, the chroma flattening - and you want to see the estimated scale/translation that drove the fix, this is the workflow.
How it works, briefly
- Blur anchor and target with
stable_sigma; compute a mask-weighted interior weight. - Estimate an affine that maps the target's structure onto the anchor's (the same math as SMC Affine Estimate Drift), clamped by
max_shrink/max_expandso it shrinks but never blows up. - Warp the target along that transform with
grid_sample(warped_target), smoothed bytranslate_strengthand the interior weight so the edges stay put. - Restore color in Oklab: pull luminance/chroma means and standard deviations toward the anchor, with
anchor_pullblending in the anchor's actual colors andcompaction_to_chromamapping measured compaction to a chroma boost. - Re-add detail (
detail_retain), tether the boundary to the original (boundary_tether), and paste back inside the mask (blend_back_to_target).
Inputs that matter
anchor_image,target_image- required. The stable low-res reference and the drifted high-res result.mask(optional) - where the correction applies; no mask = whole frame.original_image(optional) - if supplied, the boundary ring is tethered to its low-frequency content, which helps when you're pasting back into a larger frame.profile(optional) - anSMC_PROFILEfrom SMC Affine Profile. Skip it and the node uses the profile defaults.
Outputs
corrected- wire to Save/Preview.warped_target- the warped intermediate, for inspection.diagnostics- a side-by-side panel: anchor | target | corrected | heatmap+mask. Genuinely useful; the heatmap shows where pixels moved most.stats_json- the full drift stats (scale, compaction, translation, chroma ratios) as JSON.
Install & gotchas
Same pack, trivial install:
cd ComfyUI/custom_nodes
git clone https://github.com/xmarre/ComfyUI-StableManifoldCompander
or ComfyUI Manager (search "Stable Manifold Compander"). No extra dependencies, no model downloads. Watch the defaults: max_expand is 0, so this node will never grow content - if your correction is making things look tight or shrunken, that's expected at full geometry_strength; dial geometry_strength down or nudge max_shrink. And remember it's a heuristic affine fit, not optical flow - it fixes global scale/translation drift, not per-region warping. For localized radial drift, the anchor-guided SMC Compand is the better tool.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| anchor_image | IMAGE | — | |
| target_image | IMAGE | — | |
| maskopt | MASK | — | |
| original_imageopt | IMAGE | — | |
| profileopt | SMC_PROFILE | — |
Outputs (4)
| Name | Type | Description |
|---|---|---|
| corrected | IMAGE | — |
| warped_target | IMAGE | — |
| diagnostics | IMAGE | — |
| stats_json | STRING | — |