Nodes/opencv-comfyui/OpenCV divSpectrums_1
ComfyUI Node

OpenCV divSpectrums_1

The frequency-domain division node almost nobody needs (but it's here)

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV divSpectrums_1
  • a
  • b
  • c
  • nparray
flags
conjB

divSpectrums_1 is one of those nodes that makes the "expect dragons" warning in the opencv-comfyui README feel earned. It's a thin wrapper over cv2.divSpectrums, which divides one Fourier spectrum by another, element by element. If that sentence means nothing to you, you don't need this node - and that's a perfectly fine outcome. This is frequency-domain plumbing, not a pixel effect.

What it actually does

In plain OpenCV terms: take the discrete Fourier transform of two images (via dft), and divSpectrums divides spectrum A by spectrum B. That's the reciprocal operation of mulSpectrums, and it's the step that makes Fourier-domain deconvolution and inverse filtering work - you divide the blurry signal's spectrum by the kernel's spectrum to (ideally) recover the original. Phase-correlation and template-matching pipelines use a variant of it too.

The inputs are all low-level: a and b are the two spectra as NPARRAYs, flags is an integer of DFT flags (the one you'll realistically see is 4 for cv2.DFT_ROWS, which processes each row independently), and conjB decides whether to conjugate B's spectrum before dividing - conjugate division is what turns this into a correlation-style operation instead of plain deconvolution. There's also an optional c, which is an out-parameter; the pack's author says to skip those, and you should.

The single output, nparray, is the divided spectrum - still in the frequency domain. To actually see anything you'd feed it into an inverse dft/idft node from the same pack, then convert back with Nparrays2Image. None of that is beginner territory, and that's okay.

The _1, and what to install

The _1 suffix is just OpenCV declaring the same function twice - once for MatLike, once for UMat - and the generator emitting a node per overload. divSpectrums_0 and divSpectrums_1 are functionally identical. Pick one.

This ships in the opencv-comfyui pack. Install via ComfyUI Manager (search OpenCV, pack title opencv-comfyui) or:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib

Restart ComfyUI after. The requirements.txt is opencv-contrib-python, numpy, torch.

The ritual you can't skip

Like every node here, this one eats and spits NPARRAY, not a Comfy IMAGE. So before it sits Image2Nparray (RGB 0..1 tensor → BGR 0..255 numpy), and after it sits Nparrays2Image. Only batch_size==1 is supported - if Image2Nparray complains, drop an ImageFromBatch (length=1) in front.

Honest verdict: unless you're deliberately doing Fourier-domain image processing inside ComfyUI, divSpectrums_1 is a curiosity. It works as advertised, which is more than some generated nodes manage - but it's a math primitive, not an effect you'll reach for on a Sunday.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
aNPARRAY
bNPARRAY
flagsINT
conjBBOOLEAN
coptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY