lazysnapping
Segment image into foreground and background using graph-based segmentation
Syntax
Description
BW = lazysnapping(___,
segments the image or volume using name-value pairs to control aspects of the
segmentation.Name,Value
)
Examples
Input Arguments
Output Arguments
Tips
The lazy snapping algorithm developed by Li et al. clusters foreground and background values using the K-means method. This implementation of the lazy snapping algorithm does not cluster similar foreground or background pixels. To improve performance, reduce the number of pixels with similar values that are identified as foreground or background.
To obtain masks
foremask
orbackmask
interactively, you can draw an ROI on the image then create a mask from the ROI by using thecreateMask
function. For more information, see Create ROI Shapes.To obtain pixel indices
foreind
orbackind
interactively, you can draw aPolyline
ROI object by using thedrawpolyline
function. Get the x- and y-coordinates of the vertices from thePosition
property of thePolyline
. Finally, convert the coordinates to linear indices by using thesub2ind
function. Note that thesub2ind
function uses (row, column) coordinates instead of (x, y) coordinates.
References
[1] Y. Li, S. Jian, C. Tang, H. Shum, Lazy Snapping In Proceedings from the 31st International Conference on Computer Graphics and Interactive Techniques, 2004.
Version History
Introduced in R2017a