Log Spectrum Peak Compressor
Compress spectral peaks in log space, where multiplicative grime turns additive
- image
- image
The Spectral Spike Suppressor in this pack kills isolated spikes in the FFT magnitude. But not all frequency-domain contamination comes as clean single peaks. Grid artifacts, repetitive texture overlays, and gain patterns can spread their energy into multiplicative distortions of the spectrum - and in the raw magnitude domain those are a pain to separate from real content. This node takes a different route: it moves the whole operation into log space first, where a multiplication becomes an addition, and compressing peaks becomes trivial.
That log-domain trick is the classic homomorphic / cepstral idea borrowed from signal processing. If a spectral distortion is multiplicative (say, a gain pattern from a grid that dims or brightens bands), then log(magnitude) turns it into an additive offset - something you can measure and subtract cleanly, exactly like removing a hum from an audio spectrogram. The README positions it as the more sophisticated cousin of Spike Suppressor, worth reaching for when the artifact is patterned and wide rather than a single needle.
How it works
The pipeline is short and the phase never gets touched: FFT → log(magnitude) → estimate a smooth background envelope → compute the residual (log value minus background) → compress any residual peaks above peak_threshold by ratio → exp back to magnitude → IFFT. Because everything happens in log space, a 4:1 ratio there means a residual of four log-units becomes one - the "compression" metaphor from audio carries straight across.
The inputs that matter
peak_threshold(default 1.0) - the log-domain residual above which values get compressed. The tooltip notes typical artifact peaks sit at 1–3 log units above background, so this default is deliberately low enough to catch them. Smaller = more aggressive.ratio(default 4.0) - compression ratio on the excess, 1–20. This is your aggressiveness control alongside the threshold.smoothing(default 0.05) - background blur strength as a fraction of image size. Larger values mean a broader envelope estimate, so only very narrow spikes count as "peaks" - useful when the artifact is thin.strength(default 0.8) - blend between original and fully compressed. Start around 0.5–0.8 and verify.background_mode-gaussian(default) gives a smoother envelope;uniformis faster and sharper-edged. If gaussian is smearing the peaks you're trying to find, try uniform.
Plus the pack-standard tile_size / tile_overlap for images over ~2048px (0 = whole image at once, which is right for most cases). One output, image, straight into the next node or VAE Encode.
Installing it
One of the sixteen nodes in ComfyUI-Spectral-Preprocessing-Nodes - one install, all nodes, under Spectral Preprocessing. ComfyUI Manager (search "ComfyUI-Spectral-Preprocessing-Nodes"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/EdoardoGuerriero/ComfyUI-Spectral-Preprocessing-Nodes
Restart. Only numpy and scipy, both already in a standard ComfyUI install. No models, no keys.
Where people get burned
The log domain makes this node harder to reason about by eye, so the failure mode is overshooting: crank strength and ratio and you'll compress the natural falloff of the spectrum too, leaving the image flat and lifeless rather than merely clean. Keep strength blended below 1 and check the pack's FFT Spectrum Visualizer before/after - the radial profile panel will show you whether the HF hump is being cut or the whole spectrum is being squashed. Also remember this one overlaps with Spike Suppressor: if your artifact is clearly isolated spikes, Spike Suppressor is simpler and more targeted. Reach for log-domain compression when the peaks are broad, patterned, or buried in a noisy background - that's where it genuinely wins.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| peak_threshold | FLOAT | 1.000.1–5 | Threshold for the log-domain residual. Values above this are compressed. Smaller = more aggressive. Typical artifact peaks sit at 1–3 log units above background. |
| ratio | FLOAT | 4.01–20 | Compression ratio applied to the log-domain excess above the threshold. 4.0 = a 4-unit excess becomes 1 unit. |
| smoothing | FLOAT | 0.0500.005–0.3 | Background blur strength as a fraction of image size. Larger values = broader envelope estimate = only very narrow spikes are treated as 'peaks'. |
| strength | FLOAT | 0.800–1 | Blend between original (0) and fully compressed (1). |
| background_mode | COMBO | gaussian | Background estimation method. Gaussian gives a smoother envelope; uniform is faster and sharper. |
| tile_size | INT | 00–2048 | Tile size for large images. 0 = process whole image. |
| tile_overlap | INT | 640–512 | Tile overlap in pixels (used only when tile_size > 0). |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |