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.
Input image.
Initial snake coordinates. For periodic boundary conditions, endpoints must not be duplicated.
Snake length shape parameter. Higher values makes snake contract faster.
Snake smoothness shape parameter. Higher values makes snake smoother.
Controls attraction to brightness. Use negative values to attract toward dark regions.
Controls attraction to edges. Use negative values to repel snake from edges.
Explicit time stepping parameter.
DEPRECATED. See boundary_condition
below.
Maximum pixel distance to move per iteration.
Maximum iterations to optimize snake shape.
Convergence criteria.
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.
Whether to use rc or xy coordinates. The 'xy' option (current default) will be removed in version 0.18.
Optimised snake, same shape as input parameter.
Active contour model.
>>> 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: +SKIPSee :
... dist = np.sqrt((45-snake[:, 0])**2 + (35-snake[:, 1])**2) # doctest: +SKIP
... int(np.mean(dist)) # doctest: +SKIP 25
The following pages refer to to this document either explicitly or contain code examples using this.
skimage.segmentation.active_contour_model.active_contour
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