Nodes/opencv-comfyui/OpenCV compareHist_1
ComfyUI Node

OpenCV compareHist_1

CompareHist_0's twin — same node, second overload slot

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV compareHist_1
  • H1
  • H2
  • float
method

If you've already met compareHist_0, you've met this node. compareHist_1 is its duplicate: same cv2.compareHist call, same inputs, same float output. The pack auto-generates a node for every overload in OpenCV's type stubs and numbers them, and cv2.compareHist apparently declared two signatures that end up compiling to the same implementation. I diffed the two class bodies - identical apart from the name.

So the honest advice is: pick one and forget the other. Nothing changes.

The short version of what it does

Compares two histograms and returns a similarity score:

  • H1 / H2 (NPARRAY) - histograms, same size.
  • method (INT) - 0 CORREL (higher = similar), 1 CHISQR (lower = similar), 2 INTERSECT (higher = similar), 3 BHATTACHARYYA (lower = similar). Start with 2.
  • Output: float, a scalar score - not an image.

The caveat that applies to both twins

The pack ships no calcHist node, so you can't produce the H1/H2 inputs inside opencv-comfyui itself. You need histograms from a custom Python node or another source. If you don't already have one, this node has no job for you yet - which is fine, it's an edge-of-the-pack measurement tool, not a daily driver.

Install

Standard for this pack - ComfyUI Manager (search "opencv-comfyui") or:

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

Needs opencv-python-contrib (the pack's requirements.txt also lists numpy and torch). Watch for the Cannot import name 'guidedFilter' from 'cv2.ximgproc' conflict if multiple OpenCV packages collide in your environment. And don't try to preview the float output as an image - it's a scalar, and this pack will happily hand you a confusing 'NoneType' object has no attribute 'shape' if you feed it to an image node.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
H1NPARRAY
H2NPARRAY
methodINT

Outputs (1)

NameTypeDescription
floatFLOAT