Nodes/Photography Nodes/Contrast Adaptive Sharpening
ComfyUI Node

Contrast Adaptive Sharpening

AMD's game sharpener, ported to your stills

By TrophiHunter·Created about a year ago·Updated about a year ago· 5
Contrast Adaptive Sharpening
  • image
  • IMAGE
contrast0.00
sharpening0.50

Contrast Adaptive Sharpening is AMD's spatial sharpening filter - the one built into Radeon drivers and a bunch of game upscalers - and this node is a direct port of the algorithm to torch. The pitch, translated to stills: most sharpeners hit every edge equally and end up ringing halos around anything high-contrast. CAS is adaptive - it measures local contrast and sharpens less where contrast is already high, so you get detail without the halo. If the pack's Sharpen Unsharp Mask is the "classic darkroom" sharpen, this is the "modern, less-burny" one, and it's the better default when you're sharpening a final output you actually like.

How it works

CAS works on a 3x3 neighborhood. For each pixel it computes the local min/max of its eight neighbors and the center, derives a contrast-based amplitude factor, and uses that to weight the edge-sharpening term - the ampRGB = clamp(min, 2 - max) / max and wRGB = -1 / (amp * peak) arithmetic is the heart of the AMD algorithm, computing how much amplification each region can tolerate before it would clip. High-contrast edges get barely any boost; low-contrast detail gets the full treatment. That's the "contrast adaptive" part.

The two knobs map straight onto AMD's UI: sharpening (default 0.5) is the strength of the effect, and contrast (default 0) trades edge contrast recovery. The result is lerped between the original and the sharpened output by sharpening, so 0 = no change, 1 = full CAS.

Inputs that matter

Just two:

  • sharpening - 0–1, default 0.5. The amount of CAS applied. This is the dial
  • contrast - 0–1, default 0. Adds contrast recovery on top; leave it at 0 unless the image looks flat after sharpening

One IMAGE in, one IMAGE out.

Install

Part of Photography Nodes:

cd ComfyUI/custom_nodes
git clone https://github.com/TrophiHunter/ComfyUI_Photography_Nodes

Restart, find it under TrophiHunter/Photography (ComfyUI Manager: "Photography Nodes"). No requirements, no models.

Where people get burned

The trap is expecting CAS to add detail - it doesn't, no sharpener does. It amplifies existing edge information, so a genuinely soft render stays soft (that's a model/upscale problem, not a sharpen problem; see the KB's upscaling notes on why upscaling out-of-focus sources just makes blur bigger). Also, sharpening at 1.0 is aggressive - CAS is designed to be subtle in games, and on a still the same restraint applies; 0.3–0.6 reads as clean, 1.0 can start to look crunchy. And unlike unsharp mask, CAS has no radius control - it's a fixed 3x3 kernel - so it's a finishing pass, not a rescue tool. Run it last, after any upscale.

CategoryTrophiHunter/Photography

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
contrastFLOAT0.000–1
sharpeningFLOAT0.500–1

Outputs (1)

NameTypeDescription
IMAGEIMAGE