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).
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)
| Name | Type | Default | Description |
|---|---|---|---|
| image | NPARRAY,IMAGE | Image 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. | |
| delta | INT | 51–100 | Threshold step over which a region's area must stay stable. LARGER = fewer, more solidly stable regions; smaller = many more, including near-duplicates. |
| min_area | INT | 601–10000000 | Smallest region area in pixels - raise it to drop noise specks. |
| max_area | INT | 144001–10000000 | Largest region area in pixels; caps the whole-image region that is otherwise always 'stable'. |
| max_variation | FLOAT | 0.250–1 | Prune a region whose area varies more than this relative amount over 'delta'. Lower = stricter. |
| polarity | COMBO | both (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_diversityopt | FLOAT | 0.200–1 | Prune a region that is too similar in area to its parent - this is what suppresses nested near-duplicates. |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| regions | CV_CONTOURS | One 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'. |
| mask | NPARRAY | uint8 0/255 union of the EXACT region pixels (not the hulls) - the lossless form of the result. |
| boxes | NPARRAY | Nx4 int32 (x, y, w, h) bounding boxes, one per region. |
| areas | NPARRAY | (N,) float32 exact pixel count of each region. |
| count | INT | How many regions were found; 0 is valid, not an error. |