cv2.ft.FT02D_process
A smoother that fits windows instead of averaging them (fuzzy transform, one step)
- matrix
- kernel
- mask
- nparray
cv2.ft.FT02D_process is OpenCV's one-call fuzzy transform: it computes the F⁰ components of an image and immediately rebuilds the image from them. Practically speaking it's a smoother, and it's the entry point to a corner of opencv_contrib that almost nobody has used - the ft module, built on Irina Perfilieva's fuzzy transform from fuzzy mathematics.
What it actually does
The F-transform isn't a convolution with one kernel; it's a two-stage fit. Stage one slides a window across the image and, for each position, computes a weighted average of the pixels under it - one number per window. Stage two rebuilds each pixel from the overlapping window values. The weights are the "basic function", which in OpenCV is the kernel you get from cv2.ft.createKernel: a (2r+1)² square whose values fall off from the centre, where r is the radius.
The net effect of the round trip is smoothing - but the reason it exists is that the intermediate representation is a model of the image rather than a blurred copy of it. Components are the thing you can mask, edit, or reconstruct from later, which is how the same machinery becomes an inpainter (see cv2.ft.inpaint, and its per-iteration sibling in this pack).
Inputs
matrix- the socket takes IMAGE, MASK or NPARRAY. An IMAGE arrives as a single uint8 BGR frame (frame 0 of a batch only - theftfunctions aren't on the pack's frame-batch list, so a 200-frame batch gives you one blurred frame back, not 200).kernel- required, and it wants a kernel fromcv2.ft.createKernel(also in this pack). Its channel count must match the image: 3 for BGR, 1 for greyscale. A mismatch is a hard cv2 error, not a soft one.mask- optional, and it means the opposite of what you might expect elsewhere in this pack: non-zero = known, zero = excluded. Masked-out pixels get reconstructed from their neighbours, which is how the transform behaves as a fill.radiuslives on the kernel, and remember it's2r+1square: radius 1 is a 3×3, radius 10 is a 21×21 and 400+ multiplies per pixel. A freshcreateKernelopens with radius 0 - a 1×1 kernel, i.e. an expensive no-op.
One output: nparray, a 32-bit float array in the same numeric range as your input (0–255 if you fed an IMAGE). It's an NPARRAY, not a picture - wire it to Preview CV Array or CV Array → Image to look at it.
If you only want the smoothing
The pack also exposes FT02D_FL_process and FT02D_FL_process_float, and OpenCV's own docs are refreshingly direct about the trade: the first is roughly 10× faster than this node using only the linear basic function, and the float variant is about 9× faster and more accurate, at the cost of requiring a 3-channel input. So FT02D_process is the general, correct, slow one; the FL pair is the "I just want it filtered" path. Reach for this one when you actually want the components pipeline, or when you're matching someone else's parameters.
Install
Manager → search ComfyUI CV, or:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
pip install "opencv-contrib-python-headless~=5.0.0.93"
Restart. ft is a contrib module, so this node only exists when your cv2 came from a contrib wheel - and the four OpenCV distributions share one site-packages/cv2, so installing plain opencv-python at any point can silently empty the contrib submodules and make every node in this family disappear. tools/repair_opencv_contrib.py --check diagnoses that; --apply repairs it.
Where people get burned
- Radius 0. Nothing errors, nothing changes, and you conclude the node is broken.
- Channel-mismatched kernels. A greyscale image with a 3-channel kernel throws deep inside cv2 with a message that doesn't mention channels.
- Mask direction. Non-zero is known here. If you feed it a hole mask expecting a repair, you get the opposite of what you asked for.
- Expecting it to batch. One frame in, one frame out.
- Honesty about trust level: this pack is explicitly AI-assisted and its own README says the raw low-level wrappers are uncurated and shouldn't go into production without your own review. The
ftmodule is the deepest, least-travelled corner of it. Verify against the OpenCV docs before you build anything load-bearing on it.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| matrix | NPARRAY,IMAGE,MASK | Input matrix. 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. | |
| kernel | NPARRAY,IMAGE,MASK | Kernel 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. | |
| maskopt | NPARRAY,IMAGE,MASK | Mask used for unwanted area marking. This function computes F-transfrom and inverse F-transfotm in one step. It is fully sufficient and optimized for `cv::Mat`. 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. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |