{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / segmentation / active_contour_model / active_contour

function

skimage.segmentation.active_contour_model:active_contour

source: /dev/scikit-image/src/skimage/segmentation/active_contour_model.py :9

Signature

def   active_contour ( image snake alpha = 0.01 beta = 0.1 w_line = 0.0 w_edge = 1 gamma = 0.01 max_px_move = 1.0 max_num_iter = 2500 convergence = 0.1 * boundary_condition = periodic )

Summary

Active contour model.

Extended Summary

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 : ndarray of shape (M, N[, 3])

Input image.

snake : ndarray of shape (K, 2)

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.

max_px_move : float, optional

Maximum pixel distance to move per iteration.

max_num_iter : int, optional

Maximum iterations to optimize snake shape.

convergence : float, optional

Convergence criteria.

boundary_condition : str, 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.

Returns

snake : (K, 2) ndarray

Optimised snake, same shape as input parameter.

Examples

from skimage.draw import circle_perimeter
from skimage.filters import gaussian
Create and smooth image:
img = np.zeros((100, 100))
rr, cc = circle_perimeter(35, 45, 25)
img[rr, cc] = 1
img = gaussian(img, sigma=2, preserve_range=False)
Initialize spline:
s = np.linspace(0, 2*np.pi, 100)
init = 50 * np.array([np.sin(s), np.cos(s)]).T + 50
Fit spline to image:

Aliases

  • skimage.segmentation.active_contour

Referenced by