Nodes/comfyui_cv/CV Detect MSER Regions
ComfyUI Node

CV Detect MSER Regions

Maximally Stable Extremal Regions (cv2.MSER): sweeps EVERY grayscale threshold at once and keeps the blobs whose area barely changes across a wide range of them. That is the difference from 'CV Find Contours' on a thresholded image - there is no threshold to pick, and regions at different brightness levels are all found in the same pass, so it survives uneven lighting. The classic use is text and sign detection (letters are extremely stable regions) and generic region proposals. MSER is a cv2 class the raw wrappers cannot expose. Regions may NEST and overlap. Finding nothing is a valid result (count = 0).

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Detect MSER Regions
  • image
  • regions
  • mask
  • boxes
  • areas
  • count
delta5
min_area60
max_area14400
max_variation0.25
polarityboth (dark and bright regions)
min_diversity0.20
Categoryimage/CV/contours

Inputs (7)

NameTypeDefaultDescription
imageNPARRAY,IMAGEImage to search (converted to grayscale internally). 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.
deltaINT51–100Threshold step over which a region's area must stay stable. LARGER = fewer, more solidly stable regions; smaller = many more, including near-duplicates.
min_areaINT601–10000000Smallest region area in pixels - raise it to drop noise specks.
max_areaINT144001–10000000Largest region area in pixels; caps the whole-image region that is otherwise always 'stable'.
max_variationFLOAT0.250–1Prune a region whose area varies more than this relative amount over 'delta'. Lower = stricter.
polarityCOMBOboth (dark and bright regions)MSER normally runs twice - once on the image and once inverted - so it finds dark-on-light AND light-on-dark regions. Restrict it to the second pass only when you know the polarity and want half the work.
min_diversityoptFLOAT0.200–1Prune a region that is too similar in area to its parent - this is what suppresses nested near-duplicates.

Outputs (5)

NameTypeDescription
regionsCV_CONTOURSOne contour per region (its convex outline) - draw with 'CV Draw Contours' or measure with 'CV Shape Moments'. Convex hulls, so concave detail is in 'mask'.
maskNPARRAYuint8 0/255 union of the EXACT region pixels (not the hulls) - the lossless form of the result.
boxesNPARRAYNx4 int32 (x, y, w, h) bounding boxes, one per region.
areasNPARRAY(N,) float32 exact pixel count of each region.
countINTHow many regions were found; 0 is valid, not an error.