Nodes/opencv-comfyui/OpenCV stylization_0
ComfyUI Node

OpenCV stylization_0

Painterly stylization that's actually deterministic

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV stylization_0
  • src
  • dst
  • nparray
sigma_s
sigma_r

If you want the "painted oil look" without re-rolling a generation or training anything, stylization is the cheap, deterministic way to get it. It's OpenCV's edge-aware stylization filter - the same family as the watercolor/cartoon effects in photo apps. No model, no seed, no lottery: you run it, you get the same smoothed, brushy result every time. That's a feature. The post-processing layer of ComfyUI is full of old deterministic pixel math, and this is one of the more fun entries in it.

Mechanically it's two operations stacked: a strong bilateral filter to flatten the image into big smooth regions while keeping edges crisp, plus a difference-of-Gaussians edge boost that darkens the boundaries. The two knobs control exactly that. sigma_s is the spatial sigma - how large a neighborhood gets flattened, i.e. your brush size; crank it up for a more painterly, smeared look. sigma_r is the range sigma - how different two pixel colors have to be before the filter refuses to merge them, i.e. how much edge detail survives. OpenCV's own examples tend to sit around sigma_s=60, sigma_r=0.4 for a strong effect; start conservative and push.

Where it shines: turning a photoreal render into a stylized illustration pass, softening a noisy/artifacting image into something that reads as intentional, or giving a base for compositing that doesn't scream "AI". Where it disappoints: it's a real filter and it's slow on big images - this is not a real-time effect. Downscale if it crawls. Also note the result is a smoothed version of what you give it, so garbage in, smeared garbage out.

Inputs and output. src (NPARRAY), sigma_s (FLOAT), sigma_r (FLOAT), and an optional dst you should leave disconnected. Output is a single nparray. This function comes from OpenCV's photo/contrib module, so the pack needs the contrib wheel installed - opencv-contrib-python, not plain opencv-python. If you see Cannot import name 'guidedFilter' from 'cv2.ximgproc' at startup, that's the duplicate-packages conflict and it blocks everything until fixed.

Install. ComfyUI Manager → search "opencv-comfyui", or:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui

restart. Remember the type contract: NPARRAY means BGR uint8 0–255 numpy - run Image2Nparray on the way in (batch_size 1 only; ImageFromBatch(length=1) for batches) and Nparrays2Image on the way out. stylization_1 is the identical twin node, so the suffix is cosmetic; you're not missing a mode.

Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
srcNPARRAY
sigma_sFLOAT
sigma_rFLOAT
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY