Nodes/comfyui_cv/cv2.grabCut
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.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
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)

NameTypeDefaultDescription
imgNPARRAY,IMAGE,MASKInput 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.
maskNPARRAY,IMAGE,MASKInput/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_xINT0-2147483648–2147483647Rectangle top-left corner X in pixels.
rect_yINT0-2147483648–2147483647Rectangle top-left corner Y in pixels.
rect_wINT00–2147483647Rectangle width in pixels (>= 0).
rect_hINT00–2147483647Rectangle height in pixels (>= 0).
bgdModelNPARRAYTemporary 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.
fgdModelNPARRAYTemporary 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.
iterCountINT0-2147483648–2147483647Number 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 .
modeoptCOMBOGC_INIT_WITH_RECTOperation mode that could be one of the #GrabCutModes

Outputs (3)

NameTypeDescription
maskNPARRAY
bgdModelNPARRAY
fgdModelNPARRAY