Startingfrom user-defined markers, the watershed algorithm treatspixels values as a local topography (elevation). The algorithm floodsbasins from the markers until basins attributed to different markersmeet on watershed lines. In many cases, markers are chosen as localminima of the image, from which basins are flooded.
In the example below, two overlapping circles are to be separated. Todo so, one computes an image that is the distance to thebackground. The maxima of this distance (i.e., the minima of theopposite of the distance) are chosen as markers and the flooding ofbasins from such markers separates the two circles along a watershedline.
Active contours by fitting snakes to features of images. Supports singleand multichannel 2D images. Snakes can be periodic (for segmentation) orhave fixed and/or free ends.The output snake has the same length as the input boundary.As the number of points is constant, make sure that the initial snakehas enough points to capture the details of the final contour.
Level set variation tolerance between iterations. If theL2 norm difference between the level sets of successiveiterations normalized by the area of the image is below thisvalue, the algorithm will assume that the solution wasreached.
the starting level set is defined as the oppositeof the distance from the center of the image minus half ofthe minimum value between image width and image height.This is somewhat slower, but is more likely to properlydetect implicit edges.
The Chan-Vese Algorithm is designed to segment objects withoutclearly defined boundaries. This algorithm is based on level setsthat are evolved iteratively to minimize an energy, which isdefined by weighted values corresponding to the sum of differencesintensity from the average value outside the segmented region, thesum of differences from the average value inside the segmentedregion, and a term which is dependent on the length of theboundary of the segmented region.
Given a label image, expand_labels grows label regions (connected components)outwards by up to distance units without overflowing into neighboring regions.More specifically, each background pixel that is within Euclidean distanceof
Where labels are spaced more than distance pixels are apart, this isequivalent to a morphological dilation with a disc or hyperball of radius distance.However, in contrast to a morphological dilation, expand_labels willnot expand a label region into a neighboring region.
There is an important edge case when a pixel has the same distance tomultiple regions, as it is not defined which region expands into thatspace. Here, the exact behavior depends on the upstream implementationof scipy.ndimage.distance_transform_edt.
Produces an oversegmentation of a multichannel (i.e. RGB) imageusing a fast, minimum spanning tree based clustering on the image grid.The parameter scale sets an observation level. Higher scale meansless and larger segments. sigma is the diameter of a Gaussian kernel,used for smoothing the image prior to segmentation.
A pixel is considered a boundary pixel if any of its neighborshas a different label. connectivity controls which pixels areconsidered neighbors. A connectivity of 1 (default) meanspixels sharing an edge (in 2D) or a face (in 3D) will beconsidered neighbors. A connectivity of label_img.ndim meanspixels sharing a corner will be considered neighbors.
A number used to determine the neighborhood of each evaluated pixel.Adjacent pixels whose squared distance from the center is less than orequal to connectivity are considered neighbors. Ignored iffootprint is not None.
If None (default), adjacent values must be strictly equal to theinitial value of image at seed_point. This is fastest. If a valueis given, a comparison will be done at every point and if withintolerance of the initial value will also be filled (inclusive).
If None (default), adjacent values must be strictly equal to thevalue of image at seed_point to be filled. This is fastest.If a tolerance is provided, adjacent points with values within plus orminus tolerance from the seed point are filled (inclusive).
Compute the magnitude of the gradients in the image and then inverts theresult in the range [0, 1]. Flat areas are assigned values close to 1,while areas close to borders are assigned values close to 0.
Active contours without edges implemented with morphological operators. Itcan be used to segment objects in images and volumes without well definedborders. It is required that the inside of the object looks different onaverage than the outside (i.e., the inner area of the object should bedarker or lighter than the outer area on average).
This is a version of the Chan-Vese algorithm that uses morphologicaloperators instead of solving a partial differential equation (PDE) for theevolution of the contour. The set of morphological operators used in thisalgorithm are proved to be infinitesimally equivalent to the Chan-Vese PDE(see [1]). However, morphological operators are do not suffer from thenumerical stability issues typically found in PDEs (it is not necessary tofind the right time step for the evolution), and are computationallyfaster.
Preprocessed image or volume to be segmented. This is very rarely theoriginal image. Instead, this is usually a preprocessed version of theoriginal image that enhances and highlights the borders (or otherstructures) of the object to segment.morphological_geodesic_active_contour() will try to stop the contourevolution in areas where gimage is small. Seeinverse_gaussian_gradient() as an example function toperform this preprocessing. Note that the quality ofmorphological_geodesic_active_contour() might greatly depend on thispreprocessing.
Balloon force to guide the contour in non-informative areas of theimage, i.e., areas where the gradient of the image is too small to pushthe contour towards a border. A negative value will shrink the contour,while a positive value will expand the contour in these areas. Settingthis to zero will disable the balloon force.
This is a version of the Geodesic Active Contours (GAC) algorithm that usesmorphological operators instead of solving partial differential equations(PDEs) for the evolution of the contour. The set of morphological operatorsused in this algorithm are proved to be infinitesimally equivalent to theGAC PDEs (see [1]). However, morphological operators are do not sufferfrom the numerical stability issues typically found in PDEs (e.g., it isnot necessary to find the right time step for the evolution), and arecomputationally faster.
Image to be segmented in phases. Gray-level data can be two- orthree-dimensional; multichannel data can be three- or four-dimensional with channel_axis specifying the dimension containingchannels. Data spacing is assumed isotropic unless the spacingkeyword argument is used.
Array of seed markers labeled with different positive integersfor different phases. Zero-labeled pixels are unlabeled pixels.Negative labels correspond to inactive pixels that are not takeninto account (they are removed from the graph). If labels are notconsecutive integers, the labels array will be transformed so thatlabels are consecutive. In the multichannel case, labels should havethe same shape as a single channel of data, i.e. without the finaldimension denoting channels.
The algorithm solves the diffusion equation at infinite times forsources placed on markers of each phase in turn. A pixel is labeled withthe phase that has the greatest probability to diffuse first to the pixel.
The diffusion equation is solved by minimizing x.T L x for each phase,where L is the Laplacian of the weighted graph of the image, and x isthe probability that a marker of the given phase arrives first at a pixelby diffusion (x=1 on markers of the phase, x=0 on the other markers, andthe other coefficients are looked for). Each pixel is attributed the labelfor which it has a maximal value of x. The Laplacian L of the imageis defined as:
The forward map can be extremely big for some inputs, since itslength is given by the maximum of the label field. However, in mostsituations, label_field.max() is much smaller thanlabel_field.size, and in these cases the forward map isguaranteed to be smaller than either the input or output images.
Balances color proximity and space proximity. Higher values givemore weight to space proximity, making superpixel shapes moresquare/cubic. In SLICO mode, this is the initial compactness.This parameter depends strongly on image contrast and on theshapes of objects in the image. We recommend exploring possiblevalues on a log scale, e.g., 0.01, 0.1, 1, 10, 100, beforerefining around a chosen value.
The voxel spacing along each spatial dimension. By default,slic assumes uniform spacing (same voxel resolution alongeach spatial dimension).This parameter controls the weights of the distances along thespatial dimensions during k-means clustering.
If provided, superpixels are computed only where mask is True,and seed points are homogeneously distributed over the maskusing a k-means clustering strategy. Mask number of dimensionsmust be equal to image number of spatial dimensions.
If sigma is scalar and spacing is provided, the kernel width isdivided along each dimension by the spacing. For example, if sigma=1and spacing=[5, 1, 1], the effective sigma is [0.2, 1, 1]. Thisensures sensible smoothing for anisotropic images.
The desired number of basins, or an array marking the basins with thevalues to be assigned in the label matrix. Zero means not a marker. IfNone, the (default) markers are determined as the local minima ofimage. Specifically, the computation is equivalent to applyingskimage.morphology.local_minima() onto image, followed byskimage.measure.label() onto the result (with the same givenconnectivity). Generally speaking, users are encouraged to passmarkers explicitly.
3a8082e126