OpenCV createHanningWindow_1
CreateHanningWindow_1 — the twin, and the anti-leakage habit
- dst
- nparray
createHanningWindow_1 is the auto-generated twin of createHanningWindow_0 - same cv2.createHanningWindow call, same STRING winSize, same INT type, same window-matrix output. The _1 suffix is the overload name tag, nothing more. So the useful thing to add here is the habit that makes this node worth having: window before you transform.
The habit
If your pipeline does a DFT, phase correlation, or spectral analysis on image data, the textbook failure is spectral leakage - frame edges masquerading as high-frequency content because the signal doesn't return to zero at the boundary. The fix is universal and boring: multiply the image by a smooth window first. That's this node's entire job, and the discipline is:
- Build the window:
createHanningWindow_1withwinSizeas"(w, h)"matching your image. - Multiply the image array by the window.
- Feed the result to the transform (the pack's
dft_0/ phase-correlation nodes).
Do this before every frequency-domain step, not just when results look bad. "It worked without it once" is exactly how leakage sneaks into a pipeline and produces shifts or peaks that aren't real.
The two inputs
winSize- STRING, a Python literalSize:"(64, 64)". Square brackets also parse but the canonical form is the tuple; malformed text gives the pack's signatureinvalid syntax (<unknown>, line 0)error.type- INT, the array type constant.5=CV_32Ffor float window math. If you don't want to memorize constants, the pack'sCV_32FC_0node (channels 1) outputs exactly5and can feedtypedirectly.dst- optional out-parameter; leave it unconnected (README's standing advice).
Output: one nparray - a weighting matrix, not a viewable image.
Install
ComfyUI Manager → search opencv-comfyui → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
Restart. Needs opencv-contrib-python, numpy, torch. No models.
Gotchas
- The
_1suffix means nothing - same overload-twin story as the whole pack. winSizestring syntax errors are the #1 footgun here; check your parentheses.- Previewing the output as an image produces the
NoneTypeshape error - it's a matrix, not a picture.
This is a tiny specialist node in an already-niche pack. If frequency-domain work isn't in your graph, you can scroll past it guilt-free. If it is, this is the three-minute step that keeps your spectra honest.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| winSize | STRING | — | |
| type | INT | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |