ComfyUI Node

🎈LG_FFT

The node that turns your image into pure math (and yes, this is the moiré killer's first half)

By LAOGOU-666·Created 2 years ago·Updated 2 years ago· 8
🎈LG_FFT
  • image
  • image
  • FFTData

You know those rainbow web patterns that appear when you scan a magazine cover or photograph a screen? That's moiré, and it lives at specific frequencies in the image. This node is half of the ComfyUI answer to killing it - without a model, without a prompt, without any of the "it changed my grandmother's face" risk that AI restorers bring.

🎈LG_FFT is the forward transform. It takes one image, runs a 2D Fast Fourier Transform on it, and hands you two things: a picture of the image's frequency spectrum, and the raw spectral data your next node needs. By itself it does nothing visible - it's the setup for 🎈LG_IFFT, the matching node in the same pack that filters the spectrum and converts back. Think of them as one tool with a door in the middle: image → frequency space → (you edit here) → image again.

How it works

Under the hood it's textbook signal processing, courtesy of NumPy. The code splits your image into R, G and B channels, converts each to a 0–255 byte plane, then applies np.fft.fft2 followed by np.fft.fftshift per channel. fftshift moves the DC (zero-frequency) component to the center of the plane, which is why the spectrum picture looks like a bright blob in the middle with stuff radiating outward - that's the whole point, because the IFFT node's filters are built as radial distances from that center.

The image output is that spectrum, rendered as per-channel log(|F|) magnitude normalized to 0–1. It's a diagnostic view. Neat to look at, useful for seeing where a moiré spike sits, but it's not a filtered image and it's not what you feed back in.

The one input and the two outputs

There's exactly one input: image (IMAGE). No knobs, no settings - this node has nothing to tune, which is refreshing.

  • image output - the log-magnitude spectrum, for eyeballing. Wire it to a PreviewImage if you want to see what you're working with.
  • FFTData output - a custom type holding the complex frequency data per channel plus the channel and batch counts. This is the real output. 🎈LG_IFFT's ff input accepts nothing else. If you try to skip this and feed the spectrum image in, the IFFT node won't even connect.

It handles batches too - each image in a batch gets its own transform, so you can push a whole strip of scans through at once.

Install

It's a tiny pack with no model files to download. Install via ComfyUI Manager (search ComfyUI_LG_FFT), or:

cd ComfyUI/custom_nodes
git clone https://github.com/LAOGOU-666/ComfyUI_LG_FFT

Restart ComfyUI, and both 🎈LG_FFT and 🎈LG_IFFT appear under the 🎈LAOGOU category. The declared dependencies are just torch, torchvision and numpy - all of which ComfyUI already ships. Worth knowing: the code also imports cv2 without listing it in requirements, but that works out of the box because ComfyUI bundles opencv. No heavy models, no keys, no extra runtime. The name is a lie, it's pure math.

Where people get burned

  • It's half a tool. You cloned the pack, you see the FFT node, and you expect a clean image out of it. The output is an image - but it's the spectrum, not a result. Finish the pair with 🎈LG_IFFT (or the compatible nodes from the original fssorc/ComfyUI_FFT pack, which this one is explicitly drop-in compatible with).
  • Feeding the wrong output. The spectrum preview and the FFTData are both "outputs," and only one is edible by the IFFT node. The author's workflow image shows it plainly: LoadImage → LG_FFT → LG_IFFT → Save.
  • Expecting AI. If you're used to the SeedVR2/SUPIR restoration ladder the community defaults to for dirty scans, this is the opposite philosophy: deterministic, lossless-ish, and it cannot invent detail. That's a feature when you must not alter the source.

Is this the node you'd reach for on every image? No. But for periodic pattern removal - moiré, scan texture, fabric weave - it's one of the only ways to do it in ComfyUI without a model, and it's the honest, fidelity-preserving way.

Category🎈LAOGOU

Inputs (1)

NameTypeDefaultDescription
imageIMAGE

Outputs (2)

NameTypeDescription
imageIMAGE
FFTDataFFTData