Inverse DCT 2D
Putting the Picture Back Together After You Messed With Its Frequencies
- dct_spectrum
- reconstructed_image
Inverse DCT 2D is the least glamorous node in the ComfyUI_DCT pack and arguably the most important. It's the "Apply" button: it takes a DCT spectrum - masked or not - and runs the inverse transform to hand you back a normal image. Without it, all the frequency painting in the world stays a tensor nobody can look at.
Why you'd reach for it
Because a frequency-domain edit is only useful if you can get back to pixels. This is the final node in the pack's recommended chain: DCT 2D Transform → DCT Spectrum Mask Editor → this. It's also the fastest way to sanity-check the whole setup: wire DCT2D straight into IDCT2D with no mask in between and you should get your image back essentially untouched, which proves the pipeline is working before you add any filtering.
How it works
The node calls scipy.fft.idctn with norm='ortho' - the exact inverse of the forward node's transform, which uses the same orthonormal normalization. That pairing is why the round trip is so clean: with no mask, the error sits at machine-epsilon level, under 4e-16 per the README. No accumulated float drift, no surprise color shifts. That also means any difference between input and output once you add a mask is genuinely the mask's doing, not the transform's. The result is clipped to [0,1] and returned as a plain IMAGE tensor.
Honest caveat, same as its siblings: it runs on CPU in float64 via scipy. One image is nothing; a big batch will feel slow.
The input and output that matter
- dct_spectrum (DCT_SPECTRUM) - the only input. Feed it
masked_spectrumfrom DCT Spectrum Mask Editor, or the raw spectrum from DCT 2D Transform if you're testing. - reconstructed_image (IMAGE) - a normal image tensor. Wire it to a Preview Image or Save Image node and you're done.
Installation
It's the same pack, so the same drill. ComfyUI Manager → search "ComfyUI_DCT" → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/bemoregt/ComfyUI_DCT
pip install scipy
then restart. The only real dependencies beyond ComfyUI's own torch/numpy are scipy (≥1.4.0) and Pillow. All three nodes land under the DCT category in the node search.
Common issues
- Reconstructed image looks wrong - it's almost always the mask, not this node. Black removes frequencies, white keeps them; if your result has holes or ghosting where you wanted flatness, the mask is painted on the wrong side or too aggressively.
- "scipy is required for DCT nodes" - missing dependency.
pip install scipyfixes it. - You can't wire an arbitrary image into this node - it only accepts DCT_SPECTRUM, which only the other two nodes in this pack produce. The chain is closed by design.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| dct_spectrum | DCT_SPECTRUM | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| reconstructed_image | IMAGE | — |