skimage2.segmentation.felzenszwalb#
- skimage2.segmentation.felzenszwalb(image, scale=1, sigma=0.8, min_size=20, *, channel_axis=-1)[source]#
Computes Felsenszwalbâs efficient graph based image segmentation.
Produces an oversegmentation of a multichannel (i.e. RGB) image using a fast, minimum spanning tree based clustering on the image grid. The parameter
scalesets an observation level. Higher scale means less and larger segments.sigmais the diameter of a Gaussian kernel, used for smoothing the image prior to segmentation.The number of produced segments as well as their size can only be controlled indirectly through
scale. Segment size within an image can vary greatly depending on local contrast.For RGB images, the algorithm uses the euclidean distance between pixels in color space.
- Parameters:
- imagendarray of shape (M, N[, 3])
Input image.
- scalefloat
Free parameter. Higher means larger clusters.
- sigmafloat
Width (standard deviation) of Gaussian kernel used in preprocessing.
- min_sizeint
Minimum component size. Enforced using postprocessing.
- channel_axisint or None, optional
If None, the image is assumed to be a grayscale (single channel) image. Otherwise, this parameter indicates which axis of the array corresponds to channels.
Added in version 0.19:
channel_axiswas added in 0.19.
- Returns:
- segment_maskndarray of shape (M, N)
Integer mask indicating segment labels.
Notes
The
kparameter used in the original paper renamed toscalehere.References
[1]Efficient graph-based image segmentation, Felzenszwalb, P.F. and Huttenlocher, D.P. International Journal of Computer Vision, 2004
Examples
>>> from _skimage2.segmentation import felzenszwalb >>> from _skimage2.data import coffee >>> img = coffee() >>> segments = felzenszwalb(img, scale=3.0, sigma=0.95, min_size=5)