CV Select Component At Point
'give me the blob that's under this pixel'
- image
- mask
- found
Segmentation gives you a binary image full of blobs. Usually you want exactly one of them, and "the largest" is the wrong heuristic more often than you'd think. CV Select Component At Point asks a better question: which blob is here?
The author's own example is the clearest one. In a clock face, the hands are the only dark blob connected to the dial center; the numerals, the tick marks and the rim are all separate connected components. Probe the center, keep the hands, discard the rest. No area thresholding, no morphology hairball, no tuning.
How it works
It runs connected-component labelling over the binary input and keeps the component(s) that touch your probe point. With search_radius = 0 that's literally one pixel - the exact pixel under (x, y). Raise the radius and it accepts components that touch a disk of that radius around the point, which is what you want when your probe coordinate comes from an upstream centroid that might be a pixel or two off.
That connecting step is where the pack does something worth knowing about: it writes a 0/255 binary mask, not a cropped rectangle. So the region you get back hugs the object's outline. That matters downstream - the KB's masking doc makes the point that a bbox mask leaves a rectangular patch whose seams can show when you re-render it, while a polygon-shaped mask mostly doesn't. Blob-shaped masks are the same family.
What you actually set
- image - the binary image, or a MASK. Non-zero is foreground. It takes a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY, and it hands the mask back in the format you gave it - so a MASK in, a MASK out, no conversion node in the middle. For a full-batch pass, use it alongside the pack's arithmetic nodes, which do process whole IMAGE batches when both sides match.
- x, y - the probe point, FLOAT, default 0. Wire these from
CV Split Pointif what you have is a point tuple, or just type the coordinates you clicked out of a preview. - search_radius - FLOAT, default 0, min 0.
0is the exact-pixel case. A handful of pixels is the forgiving version.
Two outputs: mask (0/255, in the input's format) and found (BOOLEAN). Feed the mask to CV Find Contours, CV Crop by Masks, or straight into an inpaint/refine branch. Branch on found with a control-flow node for the case where your probe missed everything - which the node reports rather than raising, so a workflow with one bad frame doesn't die mid-batch.
Install
ComfyUI Manager → search ComfyUI CV → install → restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
pip install "opencv-contrib-python-headless~=5.0.0.93"
Python ≥ 3.12 and a ComfyUI recent enough for the V3 node API. This node needs no model files.
Common issues
foundis false and the mask is empty. No foreground under the probe - which is a real answer, not a bug. Usually the threshold upstream was too aggressive, or your coordinate is a latent coordinate rather than a pixel one. Scale it first;CV Scale PointsandCV Scale BBoxesare the two ways.- You got the wrong blob. The component touches your point because a thin bridge connects it to the blob you wanted. Check the mask before the threshold: two blobs merging into one is a morphology problem, not a node problem.
connectivityisn't a knob here (CV Keep Largest Componenthas it, this one doesn't) - the fix is upstream, usually a 4-connectivity erode/erode-open pass. - The mask reads black in the preview but the numbers look right. A 0/255 uint8 mask previews as near-black on a dark UI. Run it through the pack's conversion nodes if you want to see it as an image.
- Everything in
image/CVdisappears after installing an unrelated pack. A non-contrib OpenCV wheel got pulled in and wiped the contrib submodules in the sharedsite-packages/cv2. Fix withtools/repair_opencv_contrib.py --checkthen--apply.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | COMFY_MATCHTYPE_V3 | Binary image (or MASK); non-zero = foreground. The mask comes back in this input's format. 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. | |
| x | FLOAT | 0.00-1000000–1000000 | X pixel coordinate of the probe point. |
| y | FLOAT | 0.00-1000000–1000000 | Y pixel coordinate of the probe point. |
| search_radius | FLOAT | 0.000–1000000 | Also accept components that touch a disk of this radius around (x, y). 0 = the exact pixel only. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| mask | COMFY_MATCHTYPE_V3 | 0/255 mask of the selected component(s), in the image input's format. |
| found | BOOLEAN | — |