DCT Spectrum Mask Editor
Paint Directly on Your Image's Frequency Spectrum
- dct_spectrum
- masked_spectrum
- mask_preview
DCT Spectrum Mask Editor is the main event of the ComfyUI_DCT pack. Feed it the spectrum from DCT 2D Transform and it gives you a paint canvas laid directly over that spectrum: black paint zeroes out frequency coefficients, white paint restores them. Because low frequencies sit in the top-left corner and high frequencies in the bottom-right, a few brushstrokes are effectively a high-pass or low-pass filter drawn by hand.
Why you'd reach for it
Frequency-domain filtering is the technique every serious image editor hides from you. It's how you remove a checkerboard, moiré, or sensor-noise pattern that pixel-space tools can't touch, because they can't tell "real detail" from "artifact" - both live at the same scale. Working on the coefficients instead means you can delete a whole band of frequencies and leave everything else alone. This node makes that visible and interactive instead of a blind parameter tweak. You can see exactly what you're killing, which is genuinely rare in this ecosystem.
How it works
The node takes one required input, dct_spectrum (DCT_SPECTRUM), plus an optional mask_data (STRING) that the frontend manages for you. When you install the pack, a small bit of JavaScript replaces that string widget with an "Edit Mask" button on the node. Clicking it opens a modal canvas where:
- Left-click / drag paints black → zeroes those coefficients (removes those frequencies)
- Right-click / drag paints white → restores them
- Scroll wheel resizes the brush (2–120 px)
- Double-click clears the mask (fills white = keep everything)
- There are also Clear All and Invert buttons in the modal
When you hit Apply, the mask is saved as a base64-encoded PNG into the mask_data widget - that's why it travels inside the workflow JSON if you share the workflow. On execution, the mask is decoded, resampled to the spectrum's actual dimensions, and multiplied against the coefficients: 0 removes, 1 keeps. You get two outputs: masked_spectrum (DCT_SPECTRUM), which feeds straight into Inverse DCT 2D, and mask_preview (IMAGE), a greyscale rendering of the mask so you can see what you painted.
Where to paint for what
- Top-left region → high-pass: sharpens edges, drops flat background
- Outer / bottom-right → low-pass: blurs, removes noise and fine detail
- A custom shape → an arbitrary frequency-domain filter, which is the fun one
Installation
Same as the rest of the pack: ComfyUI Manager → search "ComfyUI_DCT" → install, or git clone https://github.com/bemoregt/ComfyUI_DCT into ComfyUI/custom_nodes, then pip install scipy and restart. The frontend button appears once the server comes back up.
Common issues
- Blank canvas when you open the editor - the canvas background is the upstream node's
spectrum_preview, and it only exists after DCT 2D Transform has actually run. Execute upstream first, then open the editor. - Mask seems to do nothing - check whether you're painting black (removes) or white (keeps). It's easy to paint white everywhere and wonder why nothing changed.
- Reconstruction looks holey or broken - that's usually the mask being too aggressive, not a bug in the pipeline. Back the brush off, or double-click to clear and start over.
- You're tempted to wire the masked output into some other pack's filter - don't. DCT_SPECTRUM is private to this pack; only Inverse DCT 2D can consume it.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| dct_spectrum | DCT_SPECTRUM | — | |
| mask_dataopt | STRING | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| masked_spectrum | DCT_SPECTRUM | — |
| mask_preview | IMAGE | — |