## .\

# cgsnake.pro

## top cgSnake

Image Processing

`result = cgSnake(image, x_init, y_init [, ALPHA=float] [, BETA=float] [, /BLUR] [, DELTA_MAX=float] [, DELTA_MIN=float], DISPLAY_IMAGE=DISPLAY_IMAGE [, GAMMA=float] [, GRADIENTSCALE=float] [, GVF_ITERATIONS=integer] [, ITERATIONS=integer] [, KAPPA=float] [, MAX_VALUE=varies] [, MIN_VALUE=varies] [, MU=float] [, PARAMETERFILE=string] [, SIGMA=float] [, SPATIAL_SCALE=double])`

This program applies the Gradient Vector Flow active contour algorithm, as described by Chenyang Xu and Jerry L. Prince in "Snakes, Shapes, and Gradient Vector Flow" in the March 1998 IEEE Transactions on Image Processing, Vol. 7, No.3. Additional information, including references to research papers, is available via Cheyang Xu's web page.

Active contours are often described as "snakes" because they writhe and move under the influence of external and internal forces, toward a feature of interest in an image, usually an edge. This program gives the user the opportunity to control both external and internal forces to find an optimal set of active contour parameters. Active contours are most often used with images to find and describe regions of interest.

This program requires the GVF_Snake object, which can be purchased at the Coyote Store.

### Return value

The function returns an ROI structure containing the deformed points of the final contour in addition to other information. The return structure looks like this:

```
roiStruct = { npts: 0L ; The length of the X and Y fields in the structure.
x: 0.0 ; The X values (in image coordinates) of the final contour.
y: 0.0 ; The Y values (in image coordinates) of the final contour.
perimeter: 0.0 ; The perimenter length of the ROI.
area: 0.0 ; The area enclosed by the ROI.
values: ; A vector of length npts, giving the value of the image at (x,y).
}
```

### Parameters

- image in required
The image for which the active contour (snake) will be applied. This argument must be 2D. The user will be asked to select an image file if this argument is not provided.

- x_init in required type=float
The initial X points of the active contour or snake. Must be paired with Y. Assume values are pixel locations within image.

- y_init in required type=float
The initial Y points of the active contour or snake. Must be paired with X. Assume values are pixel locations within image.

### Keywords

- ALPHA in optional type=float default=0.10
The elasticity parameter of the active contour. It reflects the contour's ability to stretch along its length.

- BETA in optional type=float default=0.25
The rigidity parameter of the active contour. It reflects the contour's ability to bend, as, for example, around corners.

- BLUR in optional type=boolean default=1
Set this keyword to 1 if you want a Gaussian Blur applied to image before processing. Set it to 0 otherwise.

- DELTA_MAX in optional type=float default=5.50
The maximum pixel distance for adaptive interpolation.

- DELTA_MIN in optional type=float default=0.25
The minimum pixel distance for adaptive interpolation.

- DISPLAY_IMAGE
- GAMMA in optional type=float default=1.0
The viscosity parameter. Larger values make it harder to deform the active contour in space.

- GRADIENTSCALE in optional type=float default=1.75
A multiplication factor for the gradient calculations.

- GVF_ITERATIONS in optional type=integer default=30
The number of iterations for calculating the Gradient Vector Flow (GVF).

- ITERATIONS in optional type=integer default=120
The number of iterations to use in calculating the snake positions.

- KAPPA in optional type=float default=1.25
The external force weight.

- MAX_VALUE in optional type=varies
The maximum value for scaling the image data to create contrast for the edge mask.

- MIN_VALUE in optional type=varies
The minimum value for scaling the image data to create contrast for the edge mask.

- MU in optional type=float default=0.10
The regularization parameter. This should be set according to the amount of noise in the image. Use a larger value for noisier images.

- PARAMETERFILE in optional type=string
The name of a parameter file created with the ActiveContour program and containing most of the snake parameters set here with other keywords.

- SIGMA in optional type=float default=1.0
The standard deviation or sigma of the Gaussian function used in Gaussian blurring.

- SPATIAL_SCALE in optional type=double default=1.0D
Set this keyword to a two-element array that specifies the pixel scale in the X and Y directions ([xscale, yscale]). The scale factors are applied when the perimeter and area calculations for the final contour is made. Default is [1.0D, 1.0D].

### Author information

- Author:
FANNING SOFTWARE CONSULTING:

`David W. Fanning 1645 Sheely Drive Fort Collins, CO 80526 USA Phone: 970-221-0438 E-mail: david@idlcoyote.com Coyote's Guide to IDL Programming: http://www.idlcoyote.com`

- Copyright:
Copyright (c) 2013, Fanning Software Consulting, Inc.

- History:
Modification History:

`Written by David W. Fanning, 25 October 2013, based on ActiveContour program from 2003.`

## File attributes

Modification date: | Fri Mar 27 11:07:37 2015 |

Lines: | 216 |

Docformat: | rst rst |