Chan-Vese Segmentation
|
Chan-Vese active contours without edges image segmentation. More...
#include "num.h"
Go to the source code of this file.
Typedefs | |
typedef struct chanvesestruct | chanveseopt |
Functions | |
chanveseopt * | ChanVeseNewOpt () |
Create a new chanveseopt options object. More... | |
void | ChanVeseFreeOpt (chanveseopt *Opt) |
Free chanveseopt options object. | |
void | ChanVeseSetMu (chanveseopt *Opt, num Mu) |
Specify mu, the edge length penalty. | |
void | ChanVeseSetNu (chanveseopt *Opt, num Nu) |
Specify nu, the area penalty (may be positive or negative) | |
void | ChanVeseSetLambda1 (chanveseopt *Opt, num Lambda1) |
Specify lambda1, the fit weight inside the curve. | |
void | ChanVeseSetLambda2 (chanveseopt *Opt, num Lambda2) |
Specify lambda2, the fit weight outside the curve. | |
void | ChanVeseSetTol (chanveseopt *Opt, num Tol) |
Specify the convergence tolerance. | |
void | ChanVeseSetDt (chanveseopt *Opt, num dt) |
Specify the timestep. | |
void | ChanVeseSetMaxIter (chanveseopt *Opt, int MaxIter) |
Specify the maximum number of iterations. | |
void | ChanVeseSetPlotFun (chanveseopt *Opt, int(*PlotFun)(int, int, num, const num *, const num *, const num *, int, int, int, void *), void *PlotParam) |
Specify plotting function. More... | |
void | ChanVesePrintOpt (const chanveseopt *Opt) |
int | ChanVese (num *Phi, const num *f, int Width, int Height, int NumChannels, const chanveseopt *Opt) |
Chan-Vese two-phase image segmentation. More... | |
void | ChanVeseInitPhi (num *Phi, int Width, int Height) |
Default initialization for Phi. | |
void | RegionAverages (num *c1, num *c2, const num *Phi, const num *f, int Width, int Height, int NumChannels) |
Compute averages inside and outside of the segmentation contour. | |
Chan-Vese active contours without edges image segmentation.
Definition in file chanvese.h.
int ChanVese | ( | num * | Phi, |
const num * | f, | ||
int | Width, | ||
int | Height, | ||
int | NumChannels, | ||
const chanveseopt * | Opt | ||
) |
Chan-Vese two-phase image segmentation.
Phi | pointer to array to hold the resulting segmentation |
f | the input image |
Width,Height,NumChannels | the size of f |
Tol | convergence tolerance |
MaxIter | maximum number of iterations |
Mu | length penalty |
Nu | area penalty (positive penalizes area inside the curve) |
Lambda1 | fit penalty inside the curve |
Lambda2 | fit penalty outside the curve |
dt | timestep |
PlotFun | function for outputting intermediate results |
This function performs Chan-Vese active contours two-phase image segmentation by minimizing the functional
where the minimization is over all set boundaries C and scalars c1 and c2. The boundary C is implicitly represented by level set function Phi.
The input f can be a grayscale image or an image with any number of channels, i.e., three channels for a color image, or possibly many more in a hyperspectral image. If f is a multichannel image, the segmentation is done using the Chan, Sandberg, Vese vector extension of the Chan-Vese model,
where denotes the Euclidean norm.
The data for f should be stored as a contiguous block of data of Width*Height*NumChannels elements, where the elements are ordered so that f[x + Width*(y + Height*k)] = kth component of the pixel at (x,y)
The array Phi is a contiguous array of size Width by Height with the same order as f. Phi is a level set function of the segmentation, meaning the segmentation is indicated by its sign: Phi[x + Width*y] >= 0 means (x,y) is inside the segmentation curve, Phi[x + Width*y] < 0 means (x,y) is outside. Before calling this routine, Phi should be initialized either by calling InitPhi or by setting it to a level set function of an initial guess of the segmentation. After this routine, the final segmentation is obtained from the sign of Phi.
The routine runs at most MaxIter number of iterations and stops when the change between successive iterations is less than Tol. Set Tol=0 to force the routine to run exactly MaxIter iterations.
Definition at line 127 of file chanvese.c.
chanveseopt* ChanVeseNewOpt | ( | ) |
Create a new chanveseopt options object.
This routine creates a new chanveseopt options object and initializes it to default values. It is the caller's responsibility to call ChanVeseFreeOpt to free the chanveseopt object when done.
Definition at line 369 of file chanvese.c.
void ChanVeseSetPlotFun | ( | chanveseopt * | Opt, |
int(*)(int, int, num, const num *, const num *, const num *, int, int, int, void *) | PlotFun, | ||
void * | PlotParam | ||
) |
Specify plotting function.
Opt | chanveseopt options object |
PlotFun | plotting function |
PlotParam | void pointer for passing addition parameters |
Specifying the plotting function gives control over how ChanVese displays information. Setting PlotFun = NULL disables all normal display (error messages are still displayed).
An example PlotFun is
The State argument is either 0, 1, or 2, and indicates ChanVese's status. Iter is the number of Bregman iterations completed, Delta is the change in the solution Delta = ||u^cur - u^prev||_2 / ||f||_2. Argument u gives a pointer to the current solution, which can be used to plot an animated display of the solution progress. PlotParam is a void pointer that can be used to pass additional information to PlotFun if needed.
Definition at line 483 of file chanvese.c.