📄 gsfit.c
字号:
/****************************************************************************
File Name : gsfit.c
Purpose : extract arbitrary contour
Date : Aug 31,1995
GSNAKE API is jointly developed by the Information Technology Institute (ITI), Singapore, and the School of Applied Science, Nanyang Technological
University (NTU), Singapore.
These software programs are available to the user without any license or royalty fees. Permission is hereby granted to use, copy, modify, and distribute this software and its documentation for any purpose. ITI and NTU gives no warranty, express, implied, or statuary for the software and/or documentation provided, including, without limitation, waranty of merchantibility and warranty of fitness for a particular purpose. The software provided hereunder is on an "as is" basis, and ITI and NTU has no obligation to provide maintenance, support, updates, enhancements, or modifications.
GSNAKE API is available for any UNIX compatible system. User feedback, bugs, or software and manual suggestions should be sent via electronic mail to one of the following, who may or may not act on them as he/she desires :
asschan@ntu.ac.sg
kflai@iti.gov.sg
***************************************************************************/
#include "xwindow.h"
#include "gsnake.h"
void getparam(int ac, char** av);
void printHelp();
int verbose = 0; /* verbose mode */
int spacing = 5; /* snaxel spacing */
int spac = 2; /* search segment spacing */
int nhood = 2; /* number of search segment */
double lambda = _LOCAL_MINMAX; /* regularization parameter */
EEXTTYPE Etype = _EDGE; /* external energy type */
int level = 2; /* Gaussian pyramid level */
int mag = 1; /* image magnification factor */
float low_p = 0.9; /* low percentage range */
float high_p = 0.95; /* high percentage range */
float low_v = 0.2; /* low intensity range */
float high_v = 0.9; /* high intensity range */
float e_pow = 1; /* exponential power */
main( int argc, char **argv )
{
IMAGE myimage; /* image object */
GSNAKE mysnake; /* gsnake object */
short register i, j;
if (argc==1) printHelp();
else {
getparam(argc,argv);
/* perform gaussian pyramid */
if ( !(myimage.read(argv[1]))) {
printf("\nHistogram Specification parameters :");
printf("\n\tLow Percent:%f \tHigh Percent:%f",low_p,high_p);
printf("\n\tLow Value :%f \tHigh Value :%f",low_v,high_v);
printf("\n\tExponent :%f \tMagnification:%d",e_pow,mag);
mysnake.putRawImg( &myimage );
printf("\n\nGenerating Gaussian pyramid images ... wait");
mysnake.generate( level, verbose,
low_p, high_p,low_v, high_v, e_pow);
}
else
exit( -1 );
/* generate gsnake */
short row = myimage.getRow();
short col = myimage.getCol();
if ( !mysnake.read( argv[2] ) ) {
printf("\n\nGSNAKE performance parameters :");
printf("\n\tExternal Energy\t: ");
switch (Etype) {
case _EDGE : printf("Edge"); break;
case _EDGEMAG : printf("Edge magnitude"); break;
case _INTENSITY : printf("Intensity");break;
default : break;
}
printf("\n\tSearch spacing\t: %d",spac);
printf("\n\tInsertion spacing\t: %d",spacing);
printf("\n\tSearch neighbourhood\t: %d",nhood);
printf("\n\tRegularization lambda\t: %f", lambda );
printf("\n\nGeneralized Hough transform ... wait");
mysnake.localize();
printf("\nEnergy minimization ... wait\n");
mysnake.minimize( spac, nhood, spacing, mag, verbose, lambda );
mysnake.show( (unsigned char)mag );
printf("\n\nEnter to continue ...");
getchar();
}
}
xwin_close();
}
void getparam( int ac, char** av )
{
register int i;
char *inputstr;
for (i=2; i<ac; i++) {
if (*av[i] == '/') verbose = 1;
if( *av[i] != '-' )
continue; /* illegal input */
inputstr = av[i]+2;
switch( *(av[i]+1) ) {
case 'L' :
level = atoi(inputstr);
break;
case 'M' :
mag = atoi(inputstr);
break;
case 'P' :
inputstr=av[i]+3;
switch (*(av[i]+2)) {
case 'l': low_p=atof(inputstr); break;
case 'h': high_p=atof(inputstr);break;
}
break;
case 'V' :
inputstr = av[i]+3;
switch( *(av[i]+2) ) {
case 'l' : low_v = atof(inputstr);break;
case 'h' : high_v = atof(inputstr);break;
}
break;
case 'e' :
e_pow=atof(inputstr);
break;
case 'S' :
inputstr=av[i]+3;
switch (*(av[i]+2)) {
case 's': spacing = atoi(inputstr); break;
case 'd': spac = atoi(inputstr);break;
case 'n': nhood = atoi(inputstr);break;
}
break;
case 'R' :
lambda = atof(inputstr);
break;
case 'E' :
switch (*(av[i]+2)) {
case 'i': Etype = _INTENSITY; break;
case 'e': Etype = _EDGE; break;
case 'm': Etype = _EDGEMAG;break;
}
break;
default : break;
}
}
}
void printHelp()
{
printf("\n\n Match of a template on an image\n");
printf("\n Usage: gsfit <image> <contour> -[option]<value>");
printf("\n [ option ]:");
printf("\n -L : Level of pyramid to build to, default 2");
printf("\n -M : Magnification factor, default 1");
printf("\n -E : External energy input type, default e");
printf("\n : i - Intensity e - Edge Data");
printf("\n : m - Edge Magnitude only");
printf("\n -S : Stratified Search spacing");
printf("\n : s - snaxel spacing, default 5");
printf("\n : d - search segment spacing, default 2");
printf("\n : n - number of search segment, default 2");
printf("\n -R : Regularization parameter, default _LOCAL_MINMAX");
printf("\n -Pl,Ph : Percentage range for histogram specification, default 0.9-0.95");
printf("\n -Vl,Vh : Intensity range for histogram specification, default 0.2-0.9");
printf("\n -e : Exponential Factor, default 1");
printf("\n / : Activate verbose, default 0\n\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -