ComfyUI-Spectral-Preprocessing-Nodes
FFT-based image preprocessing nodes for ComfyUI, designed to reduce latent instability in Flux image-to-image workflows.
Perfil del paquete
- Estado
- Verificado
- Publicador
- @EdoardoGuerriero
- Fuente
- GitHub
Léeme
ComfyUI Spectral Preprocessing Nodes
FFT-based image preprocessing nodes for ComfyUI, designed to reduce latent instability in Flux image-to-image workflows.
These nodes operate entirely in the frequency domain. Their goal is not perceptual image quality — it is to suppress synthetic frequency artifacts that are nearly invisible to humans but destabilise the VAE encoder and diffusion model, causing:
- Sparkle / salt-and-pepper noise in output
- Coloured artifacts and chromatic fringing
- Grainy or noisy silhouettes
- Broken textures
- Failure to reconstruct coherent structure
The Problem
A fixed set of img2img parameters can work perfectly for some source images while completely failing on others. The culprit is often frequency-domain contamination — periodic artifacts introduced by JPEG compression, AI upscaling, checkerboard patterns from transposed convolutions, or the generative model itself. These artifacts appear as isolated spikes or structured bands in the FFT magnitude spectrum.
Left: original image. Centre: image with injected checkerboard artifact (visible as a cross-shaped spike pattern in the FFT spectrum). Right: after Spectral Spike Suppressor — the spike is removed from the spectrum, the spatial image looks virtually identical.
Installation
- Clone this repository into your ComfyUI
custom_nodesfolder:
cd ComfyUI/custom_nodes
git clone https://github.com/EdoardoGuerriero/ComfyUI-Spectral-Preprocessing-Nodes.git
- Restart ComfyUI.
Dependencies: numpy, scipy — both are included with a standard ComfyUI installation.
Nodes
All nodes appear under Spectral Preprocessing in the node browser.
Spectral Spike Suppressor
Detects and attenuates isolated peaks in the FFT magnitude spectrum. Targets periodic artifacts that produce narrow spikes in frequency space: JPEG ringing, checkerboard patterns from transposed convolutions, Moiré fringes, CNN grid artifacts.
How it works: FFT → median-filter background → MAD-based z-score map → smooth sigmoid attenuation mask → reconstruct using original phase → IFFT. Phase is never modified, so edges are preserved exactly.
| Parameter | Default | Description |
|---|---|---|
threshold_sigma | 3.0 | Z-score above which a coefficient is treated as a spike. Lower = more aggressive. |
attenuation | 0.85 | Maximum fraction of spike energy removed. 1.0 = full suppression. |
kernel_size | 15 | Median filter size for background estimation. Larger = more context. |
preserve_dc | True | Protect the DC coefficient (mean brightness). Recommended: on. |
tile_size | 0 | Tile size for large images. 0 = whole image at once. |
tile_overlap | 64 | Overlap between tiles in pixels. |
Radial Spectrum Normalizer
Natural photographs follow a power law: Power(f) ∝ 1/f^α with α ≈ 2. AI-generated images often carry excess high-frequency energy. This node estimates the current radial power spectrum, builds a smooth correction gain curve toward the target law, and blends it in.
Left: source with injected high-frequency noise (excess HF visible as a bright haze at the edges of the FFT spectrum). Right: after Radial Spectrum Normalizer — HF energy reduced, spectrum closer to the natural 1/f² slope.
| Parameter | Default | Description |
|---|---|---|
alpha | 2.0 | Exponent of target 1/f^alpha power law. Natural photos ≈ 2.0. |
strength | 0.5 | Blend factor. 0 = no change, 1 = full correction. Start low. |
preserve_low_freq | 0.1 | Normalised radius below which gain is frozen at 1.0. |
smoothing | 0.05 | Gaussian smoothing of the radial gain curve. Higher = fewer ringing artifacts. |
tile_size | 0 |
Nodos de este paquete
16 nodos
Nodos de este paquete
16 nodos- AdaptiveHFCompressor
- DirectionalArtifactSuppressor
- FFTSpectrumVisualizer
- HermitianSymmetryEnforcer
- LogSpectrumPeakCompressor
- MoisanDecomposition
- NoiseFloorLifter
- RadialSpectrumNormalizer
- RadialStratifiedHistogramMatch
- SpectralAngularEqualizer
- SpectralChannelEqualizer
- SpectralHistogramMatch
- SpectralMagnitudeBlend
- SpectralPhaseBlend
- SpectralSpikeSuppressor
- SpectralWhitening
Fuentes
3 fuentes
Fuentes
3 fuentesVerificado 14 oct
Verificado 14 oct
Extractos de fuentes
1 extracto
Extractos de fuentes
1 extractoSource context: Repo EdoardoGuerriero/ComfyUI-Spectral-Preprocessing-Nodes
