Nodes/opencv-comfyui/OpenCV log_1
ComfyUI Node

OpenCV log_1

OpenCV log_1 — the other natural-log node, and the story behind the duplicate

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV log_1
  • src
  • dst
  • nparray

log_1 is the twin of log_0 - literally the same cv2.log call with the same two inputs and the same nparray output. The only interesting thing about the _1 suffix is why it exists, and once you know that, every _0/_1 node in this pack stops being mysterious.

OpenCV's Python type stubs list every function twice: once for regular MatLike arrays and once for OpenCL-accelerated UMat arrays. This pack's generator walks those stubs and numbers the overloads it finds. log_0 is the MatLike overload, log_1 is the UMat overload - and since neither overload survived translation into ComfyUI with any difference, you get two identical nodes. There's no performance distinction here (no UMat/GPU path is actually wired up, the author confirmed - the pack runs on nparrays on the CPU).

So, the function

Element-wise natural log. Every pixel becomes ln(pixel). Two practical consequences:

  1. Dynamic-range compression. The log curve squeezes the bright end and expands the dark end. This is the classic stretch for overexposed or high-dynamic-range content - feed a blown-out frame through and the highlight detail stops being a wall of white.
  2. Float output. cv2.log returns float32 values, and ln(255) is only ~5.5, so a raw preview looks nearly black. You must normalize (scale and shift) before the result reads as an image. This trips up everyone who wires it straight into a preview and sees nothing.

Inputs are just src (NPARRAY) and an optional dst out-parameter - leave dst alone; the result is on the nparray output.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python

Restart, or ComfyUI Manager → "opencv". Dependencies: opencv-contrib-python, numpy, torch.

Troubleshooting

  • "Where's my image?" - normalize the float output first (a stretch-to-range node, or normalize_0 from this pack).
  • 'NoneType' object has no attribute 'shape' - the README flags this: some nparrays in this pack aren't displayable images without further processing. Log output is exactly that case.
  • Batch error - batch_size==1 only; use ImageFromBatch.

Honestly, log_1 is a one-trick node for a specific problem (compressing bright dynamic range in a float pipeline). If that's your problem, use either twin. If it's not, keep walking - the pack wraps 600+ cv2 functions and most of them you'll never need.

Categoryimage/OpenCV

Inputs (2)

NameTypeDefaultDescription
srcNPARRAY
dstoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY