skimage 0.17.2

ParametersReturnsBackRef
active_contour(image, snake, alpha=0.01, beta=0.1, w_line=0, w_edge=1, gamma=0.01, bc=None, max_px_move=1.0, max_iterations=2500, convergence=0.1, *, boundary_condition='periodic', coordinates=None)

Active contours by fitting snakes to features of images. Supports single and multichannel 2D images. Snakes can be periodic (for segmentation) or have 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 snake has enough points to capture the details of the final contour.

Parameters

image : (N, M) or (N, M, 3) ndarray

Input image.

snake : (N, 2) ndarray

Initial snake coordinates. For periodic boundary conditions, endpoints must not be duplicated.

alpha : float, optional

Snake length shape parameter. Higher values makes snake contract faster.

beta : float, optional

Snake smoothness shape parameter. Higher values makes snake smoother.

w_line : float, optional

Controls attraction to brightness. Use negative values to attract toward dark regions.

w_edge : float, optional

Controls attraction to edges. Use negative values to repel snake from edges.

gamma : float, optional

Explicit time stepping parameter.

bc : deprecated; use ``boundary_condition``

DEPRECATED. See boundary_condition below.

max_px_move : float, optional

Maximum pixel distance to move per iteration.

max_iterations : int, optional

Maximum iterations to optimize snake shape.

convergence : float, optional

Convergence criteria.

boundary_condition : string, optional

Boundary conditions for the contour. Can be one of 'periodic', 'free', 'fixed', 'free-fixed', or 'fixed-free'. 'periodic' attaches the two ends of the snake, 'fixed' holds the end-points in place, and 'free' allows free movement of the ends. 'fixed' and 'free' can be combined by parsing 'fixed-free', 'free-fixed'. Parsing 'fixed-fixed' or 'free-free' yields same behaviour as 'fixed' and 'free', respectively.

coordinates : {'rc' or 'xy'}, optional

Whether to use rc or xy coordinates. The 'xy' option (current default) will be removed in version 0.18.

Returns

snake : (N, 2) ndarray

Optimised snake, same shape as input parameter.

Active contour model.

Examples

This example is valid syntax, but we were not able to check execution
>>> from skimage.draw import circle_perimeter
... from skimage.filters import gaussian

Create and smooth image:

This example is valid syntax, but we were not able to check execution
>>> img = np.zeros((100, 100))
... rr, cc = circle_perimeter(35, 45, 25)
... img[rr, cc] = 1
... img = gaussian(img, 2)

Initialize spline:

This example is valid syntax, but we were not able to check execution
>>> s = np.linspace(0, 2*np.pi, 100)
... init = 50 * np.array([np.sin(s), np.cos(s)]).T + 50

Fit spline to image:

This example is valid syntax, but we were not able to check execution
>>> snake = active_contour(img, init, w_edge=0, w_line=1, coordinates='rc')  # doctest: +SKIP
... dist = np.sqrt((45-snake[:, 0])**2 + (35-snake[:, 1])**2) # doctest: +SKIP
... int(np.mean(dist)) # doctest: +SKIP 25
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

skimage.segmentation.active_contour_model.active_contour

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /skimage/segmentation/active_contour_model.py#8
type: <class 'function'>
Commit: