grabCut
import { grabCut } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
example: samples/cpp/grabcut.cpp
An example using the GrabCut algorithm
Runs the GrabCut algorithm.
The function implements the GrabCut image segmentation algorithm.
grabCut(img: Mat, mask: Mat, rect: Rect, bgdModel: Mat, fgdModel: Mat, iterCount: number, mode: number): void;2 available overloads
grabCut(img: Mat, mask: Mat, rect: Rect, bgdModel: Mat, fgdModel: Mat, iterCount: number): void;grabCut(img: Mat, mask: Mat, rect: Rect, bgdModel: Mat, fgdModel: Mat, iterCount: number, mode: number): void;imgInput 8-bit 3-channel image.
maskInput/output value, modified by the native operation. 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.
rectROI 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 .
bgdModelInput/output value, modified by the native operation. Temporary array for the background model. Do not modify it while you are processing the same image.
fgdModelInput/output value, modified by the native operation. Temporary arrays for the foreground model. Do not modify it while you are processing the same image.
iterCountNumber 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 .
modeOperation mode that could be one of the #GrabCutModes
These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.