ComfyUI Node
cv2.grabCut
Raw wrapper of cv2.grabCut(img, mask, rect, bgdModel, fgdModel, iterCount, mode?). Parameters marked '?' are optional; blank means OpenCV default. See the OpenCV documentation for details.
cv2.grabCut
- img
- mask
- bgdModel
- fgdModel
- mask
- bgdModel
- fgdModel
◄rect_x0►
◄rect_y0►
◄rect_w0►
◄rect_h0►
◄iterCount0►
◄modeGC_INIT_WITH_RECT►
Categoryimage/CV/low-level/cv2 G
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| img | NPARRAY,IMAGE,MASK | Input 8-bit 3-channel image. 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. | |
| mask | NPARRAY,IMAGE,MASK | Input/output 8-bit single-channel mask. The mask is initialized by the function when mode is set to #GC_INIT_WITH_RECT. Its elements may have one of the #GrabCutClasses. 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. | |
| rect_x | INT | 0-2147483648–2147483647 | Rectangle top-left corner X in pixels. |
| rect_y | INT | 0-2147483648–2147483647 | Rectangle top-left corner Y in pixels. |
| rect_w | INT | 00–2147483647 | Rectangle width in pixels (>= 0). |
| rect_h | INT | 00–2147483647 | Rectangle height in pixels (>= 0). |
| bgdModel | NPARRAY | Temporary array for the background model. Do not modify it while you are processing the same image. A data array (points / matrix), NOT an image - only an NPARRAY link is accepted here. | |
| fgdModel | NPARRAY | Temporary arrays for the foreground model. Do not modify it while you are processing the same image. A data array (points / matrix), NOT an image - only an NPARRAY link is accepted here. | |
| iterCount | INT | 0-2147483648–2147483647 | Number of iterations the algorithm should make before returning the result. Note that the result can be refined with further calls with mode==#GC_INIT_WITH_MASK or mode==GC_EVAL . |
| modeopt | COMBO | GC_INIT_WITH_RECT | Operation mode that could be one of the #GrabCutModes |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| mask | NPARRAY | — |
| bgdModel | NPARRAY | — |
| fgdModel | NPARRAY | — |