Method GrabCut
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
GrabCut(InputArray, InputOutputArray, Rect, InputOutputArray, InputOutputArray, int, GrabCutModes)
Segments the image using GrabCut algorithm
public static void GrabCut(InputArray img, InputOutputArray mask, Rect rect, InputOutputArray bgdModel, InputOutputArray fgdModel, int iterCount, GrabCutModes mode)
Parameters
imgInputArrayInput 8-bit 3-channel image.
maskInputOutputArrayInput/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 Cv2.GC_BGD / Cv2.GC_FGD / Cv2.GC_PR_BGD / Cv2.GC_PR_FGD
rectRectROI containing a segmented object. The pixels outside of the ROI are marked as "obvious background". The parameter is only used when mode==GC_INIT_WITH_RECT.
bgdModelInputOutputArrayTemporary array for the background model. Do not modify it while you are processing the same image.
fgdModelInputOutputArrayTemporary arrays for the foreground model. Do not modify it while you are processing the same image.
iterCountintNumber 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 .
modeGrabCutModesOperation mode that could be one of GrabCutFlag value.