Nodes/opencv-comfyui/OpenCV dct_1
ComfyUI Node

OpenCV dct_1

The Identical Twin of the DCT Node (Frequency Work, Either Way)

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

OpenCV dct_1 is the overload twin of dct_0, and the two are functionally identical. Both call cv2.dct(src, dst, flags); both take the same inputs; both return a coefficient nparray. The _1 is a codegen artifact - geroldmeisinger/opencv-comfyui emits one node per overload found in cv2's type stubs (MatLike and UMat), and ComfyUI can't tell them apart. You lose nothing by grabbing whichever one your search surfaced.

What the DCT is for

It's the Discrete Cosine Transform - the frequency transform behind JPEG. You use it for frequency-domain work on an image: denoising by zeroing high-frequency coefficients, then inverse-transforming (flags=3, i.e. DCT_INVERSE | DCT_SCALE), or spectral analysis where you care about which frequencies carry energy. In a ComfyUI graph this is niche but real - it's the kind of deterministic pixel operation the KB's post-processing.md essay files under "no model runs, it's just math."

Inputs and outputs

  • src (NPARRAY) - input array; it must be float32/float64, not the uint8 that Image2Nparray hands you.
  • flags (INT) - 0 forward, 1 inverse, 3 inverse-with-scale, 4 row-wise.
  • dst (NPARRAY, optional) - out-parameter; leave it unconnected.
  • nparray (NPARRAY, output) - the coefficients. Not an image - normalize before you try to preview it.

Install and gotchas

ComfyUI Manager (search opencv-comfyui) or:

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

Restart ComfyUI. No model downloads. Mind the package name: opencv-contrib-python, not the README's swapped opencv-python-contrib. If Cannot import name 'guidedFilter' from 'cv2.ximgproc' shows up, you have conflicting OpenCV installs - the README links the known fix.

The failure modes worth remembering: DCT output fed straight into Nparrays2Image produces the 'NoneType' object has no attribute 'shape' error, because coefficients aren't pixels. And cv2.dct will reject a uint8 input, so convert to float first. The full walkthrough lives in the dct_0 article - this one's just its twin.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
srcNPARRAY
flagsINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY