Nodes/ComfyUI CV/cv2.ft.FT02D_inverseFT
ComfyUI Node

cv2.ft.FT02D_inverseFT

Rebuild a picture from fuzzy coefficients

By bmad4ever·Created 4 months ago·Updated 15 days ago· 1
cv2.ft.FT02D_inverseFT
  • components
  • kernel
  • nparray
◄width0►
◄height0►

cv2.ft.FT02D_inverseFT is the defuzzification step: it takes the component coefficients of a fuzzy transform and rebuilds an image from them. On its own it does nothing interesting - the interesting part is that it's the second half of a pair, which means you can hold the coefficient set as data, do something to it, and then reconstruct. In a ComfyUI graph that's unusually direct: the fuzzy transform's compressed representation of your image is a socket you can wire through other nodes.

It's a raw wrapper in ComfyUI CV (bmad4ever), the pack that exposes OpenCV 5.0 to ComfyUI - around 470 auto-generated cv2.* wrappers plus curated high-level nodes, GPL-3.0, written against the V3 node API. The ft module is a contrib corner of OpenCV and the pack exposes it raw: parameters, NPARRAY sockets, no hand-holding.

The inputs

Four, and they're all load-bearing:

  • components - the coefficients, described as a 32-bit float single-channel array. Straight from cv2.ft.FT02D_components.
  • kernel - the fuzzy kernel that defines the partition. Use the same kernel that produced the components. The inverse has no way to detect that you've swapped it for one with a different radius or channel count; you get a plausible-looking wrong reconstruction rather than an error. Build it once with cv2.ft.createKernel and wire it to both sides of the pair.
  • width / height - the size of the image you want out, as two INTs. Note these describe the output, not the components: the coefficient array is a coarse grid, and the inverse needs to be told the resolution to lay the reconstruction down at.

One output: nparray, the reconstructed image. It's a raw array, not a format-echoing socket, so viewing it means CV Array → Image or Preview CV Array (the preview node can normalise floats or render a heatmap, which is often more readable for a reconstruction you're debugging).

How to use it as a tool rather than a curiosity

The useful pattern is a round trip with an edit in the middle:

  1. cv2.ft.FT02D_components on your image, with a kernel at some radius.
  2. Do something to the coefficients - threshold them, zero the small ones (that's compression), clamp them, scale them, or inspect them with Inspect CV Data / CV Array To Text / CV Array Statistic.
  3. FT02D_inverseFT with the same kernel and the original width/height.

Compare the result against the input and you're looking at exactly what your edit did in the partition domain. Start with a pass-through: components straight into the inverse, no edit, and check you get something close to the original. That's your baseline, and having it makes every later experiment interpretable instead of mysterious. It's also the fastest way to internalise what the radius is doing - raise the radius, watch how much structure survives the round trip.

Two caveats. First, the transform is lossy by construction; do not expect file-perfect reconstruction, especially at large radii - the fuzzy transform is an approximation. Second, if you only want the smoothing effect, don't build this chain at all: cv2.ft.filter does forward and inverse in one node, and cv2.ft.FT02D_FL_process / FT02D_FL_process_float do it in one step with no kernel at all.

Install

ComfyUI Manager → search ComfyUI CV, or:

cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
pip install -r comfyui_cv/requirements.txt

Python ≥3.12 and a current ComfyUI built on the V3 node API; restart ComfyUI when it finishes. The single dependency is opencv-contrib-python-headless~=5.0.0.93. Contrib is not optional for this node family - cv2.ft doesn't exist in a plain opencv-python wheel, and because all four OpenCV distributions share one site-packages/cv2, installing the non-contrib wheel over the contrib one empties the contrib submodules without any error. The symptom is whole categories missing from your node search:

python ComfyUI/custom_nodes/comfyui_cv/tools/repair_opencv_contrib.py --check

Common issues

Nonsense reconstruction. You changed the kernel between the forward and inverse step, or you're feeding components from a different image. Both fail silently - that's the nature of a coefficient array; nothing in it says which image it came from.

cv2 complaining about width/height. They must be positive, and they describe the output image. Zero here means a zero-sized output, not "reuse the input size".

A flat grey result. The components were destroyed on the way in - an edit that zeroed them, or a CV Cast Array that truncated a float array to integers. Check the array's statistics before the inverse rather than after.

Missing node. Contrib wheel overwritten; run the check above, then --apply with ComfyUI stopped.

Categoryimage/CV/low-level/ft

Inputs (4)

NameTypeDefaultDescription
componentsNPARRAY,IMAGE,MASKInput 32-bit float single channel array for the components. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size.
kernelNPARRAY,IMAGE,MASKKernel used for processing. Function `ft::createKernel` can be used. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size.
widthINT0-2147483648–2147483647Width of the output array.
heightINT0-2147483648–2147483647Height of the output array. Computation of inverse F-transform.

Outputs (1)

NameTypeDescription
nparrayNPARRAY—