.\
gvf_snake__define.pro
Contouring, Analysis
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: http://iacl.ece.jhu.edu/projects/gvf/. This program is different from the ActiveContour program in that a graphical user interface is not required to run the program. This program is normally called from the Coyote Library routine cgSnake.
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 can be purchased at the Coyote Store.
Class description for GVF_Snake
Inheritance
- IDL_OBJECT
Properties
Properties in GVF_Snake
- SCALE get
- DELTA_MIN get set init
- DRAW_CREATE get
- MU get set init
- GVF_ITERATIONS get set init
- DELTA_MAX get set init
- X get set
- Y get set
- GRADIENTSCALE get set init
- MIN_VALUE get set init
- PARAMETERFILE init
- BLUR get set init
- KAPPA get set init
- GAMMA get set init
- SPATIAL_SCALE get set init
- MAX_VALUE get set init
- ALPHA get set init
- SIGMA get set init
- DISPLAY_IMAGE init
- ITERATIONS get set init
- IMAGE get set
- BETA get set init
- ROI get
Fields
Fields in IDL_OBJECT
- IDL_OBJECT_BOTTOM 0LL
- __OBJ__ obj_new()
- IDL_OBJECT_TOP 0LL
Fields in GVF_Snake
- YSNAKE_F ptr_new()
- XSIZE 0L
- MU 0.000000
- GVF_ITERATIONS 0L
- YSIZE 0L
- U ptr_new()
- V ptr_new()
- ORIGINAL ptr_new()
- GRADIENTSCALE 0.000000
- EDGEMAP ptr_new()
- XSNAKE_F ptr_new()
- BLUR 0L
- KAPPA 0.000000
- GAMMA 0.000000
- NPTS 0L
- SPATIAL_SCALE [0.00000000D, 0.00000000D]
- MIN_V 0.000000
- XRANGE [0.000000, 0.000000]
- XSNAKE ptr_new()
- DMIN 0.000000
- INITIALROI 0B
- FX ptr_new()
- ALPHA 0.000000
- FY ptr_new()
- YRANGE [0.000000, 0.000000]
- YSNAKE ptr_new()
- DMAX 0.000000
- SIGMA 0.000000
- IMAGE ptr_new()
- ITERATIONS 0L
- MAX_V 0.000000
- BETA 0.000000
- ROI obj_new()
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.
Routines
result = GVF_Snake::INIT(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 is the initialization routine for the GVF_Snake object.
GVF_Snake::ArcSample, x_in, y_in [, x_out] [, y_out] [, PHASE=float] [, POINTS=integer]
This procedure takes a closed curve in X and Y and re-samples it in equal arc lengths.
result = GVF_Snake::ApplySnake( [/Cancel])
This function runs the GVF Active Contour code to completion.
GVF_Snake::Contrast_Stretch, info
This procedure receives stretch information from cgStretch when the image changes or is stretched.
GVF_Snake::Edgemap
This method calculates the edgemap for the object image.
result = GVF_Snake::GaussianBlur(image [, Scale=float])
This function applies a Gaussian filter function to the image.
GVF_Snake::GetProperty [, ALPHA=float] [, BETA=float] [, /BLUR] [, DELTA_MAX=float] [, DELTA_MIN=float], DRAW_CREATE=DRAW_CREATE [, GAMMA=float], IMAGE=IMAGE [, ITERATIONS=integer] [, KAPPA=float] [, GRADIENTSCALE=float] [, GVF_ITERATIONS=integer] [, MAX_VALUE=varies] [, MIN_VALUE=varies] [, MU=float] [, ROI=float] [, SCALE=float] [, SIGMA=float] [, SPATIAL_SCALE=double] [, X=float] [, Y=float]
This method allows the user to get various properties of the object.
result = GVF_Snake::Gradient(image [, direction])
This function calculates and returns the gradient of an image.
result = GVF_Snake::Laplacian(image)
This function applies and returns the Laplacian filtered image.
result = GVF_Snake::LoadParameters(file)
This function loads a parameter file that was created by the ActiveContour program.
GVF_Snake::SetProperty [, ALPHA=float] [, BETA=float] [, /BLUR] [, DELTA_MAX=float] [, DELTA_MIN=float] [, GAMMA=float] [, IMAGE=IMAGE] [, ITERATIONS=integer] [, KAPPA=float] [, GRADIENTSCALE=float] [, GVF_ITERATIONS=integer] [, MAX_VALUE=varies] [, MIN_VALUE=varies] [, MU=float] [, SIGMA=float] [, SPATIAL_SCALE=double] [, X=float] [, Y=float]
This method allows the user to set various properties of the object.
result = GVF_Snake::SnakeDeform(x, y)
This function deforms the snake according to the pressures applied by the parameters.
result = GVF_Snake::SnakeInterpolate(pts)
This function interpolates the snake adaptively.
GVF_Snake::Threshold, min_t, max_t
This methods updates the thresholded image.
GVF_Snake::CLEANUP
This is the clean-up routine for the object.
GVF_Snake__Define [, class]
This is the class definition module.
Routine details
top GVF_Snake::INIT
result = GVF_Snake::INIT(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 is the initialization routine for the GVF_Snake object.
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 for display.
- MIN_VALUE in optional type=varies
The minimum value for scaling the image data for display.
- 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].
top GVF_Snake::ArcSample
GVF_Snake::ArcSample, x_in, y_in [, x_out] [, y_out] [, PHASE=float] [, POINTS=integer]
This procedure takes a closed curve in X and Y and re-samples it in equal arc lengths. The purpose is to have a curve with approximately equally-spaced intervals along its length. This is essential for getting a good fit with the ActiveContour algorithm.
Parameters
- x_in in required type=vector
The X locations of the input curve.
- y_in in required type=vector
The Y locations of the input curve.
- x_out out optional type=vector
The X locations of the output curve.
- y_out out optional type=vector
The Y locations of the output curve.
Keywords
- PHASE in optional type=float default=0.0
A parameter that takes the phase of the curve into account. Its value should be between 0.0 and 1.0 and is confined to be so.
- POINTS in optional type=integer default=50
The number of points in the output curve.
top GVF_Snake::ApplySnake
result = GVF_Snake::ApplySnake( [/Cancel])
This function runs the GVF Active Contour code to completion.
Return value
Returns a structure containing the active contour results.
retValue = {NPTS:N_Elements(x), X:x, Y:y, $ PERIMETER:perimeter, AREA:area, $ VALUES:(*self.original)[Round(x),Round(y)]}
Keywords
- Cancel out optional type=boolean default=0
On exit, this value will be set to 1 if the user cancelled the active contour operation.
top GVF_Snake::Contrast_Stretch
GVF_Snake::Contrast_Stretch, info
This procedure receives stretch information from cgStretch when the image changes or is stretched. The image and stretch parameters are updated in the object.
Parameters
- info in required type=structure
The info structure returned from cgStretch when the image is stretched there.
top GVF_Snake::Edgemap
GVF_Snake::Edgemap
This method calculates the edgemap for the object image. The edgemap is stored in the pointer self.edgemap.
top GVF_Snake::GaussianBlur
result = GVF_Snake::GaussianBlur(image [, Scale=float])
This function applies a Gaussian filter function to the image.
Return value
Returns a blurred image.
Parameters
- image in required
The image to be blurred.
Keywords
- Scale in optional type=float default=1.0
A scale factor that is multiplied to the Gaussian mask.
top GVF_Snake::GetProperty
GVF_Snake::GetProperty [, ALPHA=float] [, BETA=float] [, /BLUR] [, DELTA_MAX=float] [, DELTA_MIN=float], DRAW_CREATE=DRAW_CREATE [, GAMMA=float], IMAGE=IMAGE [, ITERATIONS=integer] [, KAPPA=float] [, GRADIENTSCALE=float] [, GVF_ITERATIONS=integer] [, MAX_VALUE=varies] [, MIN_VALUE=varies] [, MU=float] [, ROI=float] [, SCALE=float] [, SIGMA=float] [, SPATIAL_SCALE=double] [, X=float] [, Y=float]
This method allows the user to get various properties of the object. In general, the same keywords that are used for the INIT method can be used here.
Keywords
- ALPHA out 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 out 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 out 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 out optional type=float default=5.50
The maximum pixel distance for adaptive interpolation.
- DELTA_MIN out optional type=float default=0.25
The minimum pixel distance for adaptive interpolation.
- DRAW_CREATE
- GAMMA out optional type=float default=1.0
The viscosity parameter. Larger values make it harder to deform the active contour in space.
- IMAGE
- ITERATIONS out optional type=integer default=120
The number of iterations to use in calculating the snake positions.
- KAPPA out optional type=float default=1.25
The external force weight.
- GRADIENTSCALE out optional type=float default=1.75
A multiplication factor for the gradient calculations.
- GVF_ITERATIONS out optional type=integer default=30
The number of iterations for calculating the Gradient Vector Flow (GVF).
- MAX_VALUE out optional type=varies
The maximum value for scaling the image data for display.
- MIN_VALUE out optional type=varies
The minimum value for scaling the image data for display.
- MU out 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.
- ROI out optional type=float
The final contour, stored as an IDLanROI object. Not available in the demo version of the program.
- SCALE out optional type=float default=1.0
Set this keyword to a scaling factor for the image. This keyword is set automatically according to the size of the input image, unless specified explicitly. Scaling only applies when the program creates it own image display window (i.e., the DRAWID keyword is not used).
- SIGMA out optional type=float default=1.0
The standard deviation or sigma of the Gaussian function used in Gaussian blurring.
- SPATIAL_SCALE out 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].
- X out optional type=float
The X points of the current active contour or snake.
- Y out optional type=float
The Y points of the current active contour or snake
top GVF_Snake::Gradient
result = GVF_Snake::Gradient(image [, direction])
This function calculates and returns the gradient of an image.
Return value
Returns the gradient image.
Parameters
- image in required
The image for which the gradient is to be calculated.
- direction in optional type=boolean default=0
The direction the gradient is to be applied. 0 indicates the X direction and 1 indicates the Y direction.
top GVF_Snake::Laplacian
result = GVF_Snake::Laplacian(image)
This function applies and returns the Laplacian filtered image.
Return value
Returns the Laplacian image.
Parameters
- image in required
The image for which the Laplacian filter is to be applied.
top GVF_Snake::LoadParameters
result = GVF_Snake::LoadParameters(file)
This function loads a parameter file that was created by the ActiveContour program.
Parameters
- file in required
The parameter file from which the program parameters are to be read.
top GVF_Snake::SetProperty
GVF_Snake::SetProperty [, ALPHA=float] [, BETA=float] [, /BLUR] [, DELTA_MAX=float] [, DELTA_MIN=float] [, GAMMA=float] [, IMAGE=IMAGE] [, ITERATIONS=integer] [, KAPPA=float] [, GRADIENTSCALE=float] [, GVF_ITERATIONS=integer] [, MAX_VALUE=varies] [, MIN_VALUE=varies] [, MU=float] [, SIGMA=float] [, SPATIAL_SCALE=double] [, X=float] [, Y=float]
This method allows the user to set various properties of the object. In general, the same keywords that are used for the INIT method can be used here.
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.
- GAMMA in optional type=float default=1.0
The viscosity parameter. Larger values make it harder to deform the active contour in space.
- IMAGE in optional
A 2D image array.
- 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.
- 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).
- MAX_VALUE in optional type=varies
The maximum value for scaling the image data for display.
- MIN_VALUE in optional type=varies
The minimum value for scaling the image data for display.
- 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.
- 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].
- X in optional type=float
The initial X points of the active contour or snake. Optional. Must be used with Y.
- Y in optional type=float
The initial Y points of the active contour or snake. Optional. Must be used with X.
top GVF_Snake::SnakeDeform
result = GVF_Snake::SnakeDeform(x, y)
This function deforms the snake according to the pressures applied by the parameters. The method was adapted for IDL from Xu and Prince's MatLab program for Active Contouring, available on their web page: http://iacl.ece.jhu.edu/projects/gvf/.
Return value
Returns an [n,2] array of deformed data points.
Parameters
- x in required type=float
The X points of the current snake.
- y in required type=float
The Y points of the current snake.
top GVF_Snake::SnakeInterpolate
result = GVF_Snake::SnakeInterpolate(pts)
This function interpolates the snake adaptively. If the distance between two adjacent points is greater than self.dmax, then a point is inserted between them. If the distance between two adjacent points is less than self.dmin, then either point i or point i+1 is removed.
Return value
Returns an [n,2] array of interpolated data points.
Parameters
- pts in required type=float
An [n,2] array containing the current active contour points.
top GVF_Snake::Threshold
GVF_Snake::Threshold, min_t, max_t
This methods updates the thresholded image.
Parameters
- min_t in required type=float
The minimum threshold value.
- max_t in required type=float
The maximum threshold value.
top GVF_Snake::CLEANUP
GVF_Snake::CLEANUP
This is the clean-up routine for the object. Anything that may leak memory is cleaned up or destroyed here.
top GVF_Snake__Define
GVF_Snake__Define [, class]
This is the class definition module. Structures used to manipulate map projectatum information are also created here.
Parameters
- class out optional type=structure
Occasionally, it is useful to have an object class definition as a structure variable. Using this output keyword will allow that.
File attributes
Modification date: | Mon Nov 11 10:54:48 2013 |
Lines: | 1,321 |
Docformat: | rst rst |