Nodes/opencv-comfyui/OpenCV createHanningWindow_1
ComfyUI Node

OpenCV createHanningWindow_1

CreateHanningWindow_1 — the twin, and the anti-leakage habit

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV createHanningWindow_1
  • dst
  • nparray
winSize
type

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:

  1. Build the window: createHanningWindow_1 with winSize as "(w, h)" matching your image.
  2. Multiply the image array by the window.
  3. 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 literal Size: "(64, 64)". Square brackets also parse but the canonical form is the tuple; malformed text gives the pack's signature invalid syntax (<unknown>, line 0) error.
  • type - INT, the array type constant. 5 = CV_32F for float window math. If you don't want to memorize constants, the pack's CV_32FC_0 node (channels 1) outputs exactly 5 and can feed type directly.
  • 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 _1 suffix means nothing - same overload-twin story as the whole pack.
  • winSize string syntax errors are the #1 footgun here; check your parentheses.
  • Previewing the output as an image produces the NoneType shape 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.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
winSizeSTRING
typeINT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY