OpenCV dct_1
The Identical Twin of the DCT Node (Frequency Work, Either Way)
- src
- dst
- nparray
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 befloat32/float64, not theuint8thatImage2Nparrayhands you.flags(INT) -0forward,1inverse,3inverse-with-scale,4row-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.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| flags | INT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |