Saltar al contenido
Node packVerificadoExterno
Abrir fuente

ComfyUI-Spectral-Preprocessing-Nodes

FFT-based image preprocessing nodes for ComfyUI, designed to reduce latent instability in Flux image-to-image workflows.

Responsable@EdoardoGuerrieroD · adoptioncalidad

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

  1. Clone this repository into your ComfyUI custom_nodes folder:
cd ComfyUI/custom_nodes
git clone https://github.com/EdoardoGuerriero/ComfyUI-Spectral-Preprocessing-Nodes.git
  1. 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.

ParameterDefaultDescription
threshold_sigma3.0Z-score above which a coefficient is treated as a spike. Lower = more aggressive.
attenuation0.85Maximum fraction of spike energy removed. 1.0 = full suppression.
kernel_size15Median filter size for background estimation. Larger = more context.
preserve_dcTrueProtect the DC coefficient (mean brightness). Recommended: on.
tile_size0Tile size for large images. 0 = whole image at once.
tile_overlap64Overlap 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.

ParameterDefaultDescription
alpha2.0Exponent of target 1/f^alpha power law. Natural photos ≈ 2.0.
strength0.5Blend factor. 0 = no change, 1 = full correction. Start low.
preserve_low_freq0.1Normalised radius below which gain is frozen at 1.0.
smoothing0.05Gaussian smoothing of the radial gain curve. Higher = fewer ringing artifacts.
tile_size0

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
GitHubFuenteVersión 144774787ef96f95d0597413e260055dac49c43c
github.com/EdoardoGuerriero/ComfyUI-Spectral-Preprocessing-Nodes

Verificado 14 oct

Extractos de fuentes

1 extracto

Source context: Repo EdoardoGuerriero/ComfyUI-Spectral-Preprocessing-Nodes