Nodes/opencv-comfyui/OpenCV dft_1
ComfyUI Node

OpenCV dft_1

The second overload, same Fourier transform

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV dft_1
  • src
  • dst
  • nparray
flags
nonzeroRows

dft_1 is the duplicate half of the pack's discrete Fourier transform node, and it does exactly what dft_0 does. Same cv2.dft call, same inputs, same complex 2-channel output. The _1 exists because OpenCV's Python stubs declare the function twice - once for MatLike, once for UMat - and this pack's generator emits a node per overload. Since ComfyUI sees both as NPARRAY, you get two identical nodes. Pick whichever you grab from the search box; there's no version that's "more correct."

So the real content is the _0 article. What you need from it in a sentence: cv2.dft turns a single-channel float32 image into its frequency-domain representation, output as a 2-channel array where channel 0 is the real part and channel 1 is the imaginary part. That's the raw material for frequency-domain processing - and it's not viewable as a picture without extra math (magnitude + log scaling) that this pack doesn't include.

Inputs: src (NPARRAY - realistically needs to be single-channel and float32, so your usual uint8 image from Image2Nparray will need a grayscale conversion plus a numpy float cast before this node), flags (INT - use 16 for a forward complex transform; combine 1+2 for a scaled inverse; 32 for real output), nonzeroRows (INT, performance hint, leave 0). Skip the optional dst out-parameter. Output: one nparray, the complex spectrum.

The natural partners: divSpectrums_0 divides two spectra element-wise (deconvolution, phase correlation), and a second dft with inverse flags closes the transform loop. This is a genuinely advanced corner - the honest framing from the _0 article applies here too: most ComfyUI users will never touch the frequency domain, and if your goal is "image looks sharper," a spatial node like detailEnhance_0 is the pragmatic choice. Reach for dft when you're deliberately doing frequency-space work, not when you want a quick visual result.

Install: it's in geroldmeisinger/opencv-comfyui - ComfyUI Manager (search "OpenCV") or:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui

restart, and have opencv-contrib-python installed (pip install opencv-contrib-python). The pack-wide Cannot import name 'guidedFilter' from 'cv2.ximgproc' error from conflicting OpenCV wheels will prevent the whole pack from loading - fix the wheel conflict before troubleshooting anything else.

One thing to internalize across the pack: _0/_1 pairs like this one are always the same node here. It's the generator's numbering scheme for overloads, not a subtle behavioral difference. Once you know that, the pack gets a lot less confusing.

Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
srcNPARRAY
flagsINT
nonzeroRowsINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY