⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gsn1.c

📁 图像中非刚性曲线的蛇形检测算法
💻 C
字号:
/****************************************************************************
 File Name  : gsn1.c
 Purpose    : contour localization and energy minimization
 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 "gsnake.h"

void testmain(char *imgfile, char *confile, int level, short mag, int sspacing,
	      int ispacing, int nhood,double lambda, EEXTTYPE Etype);

void printhelp();
void getparam(int ac, char **av, int *Mfactor, int *level, int *sspacing,
	      int *ispacing, int *nhood,double *lambda, EEXTTYPE *Etype);

int verbose = 0 ;

main( int argc, char **argv )
{
	int magnify =1;
	char *contour = NULL;
	int level = 2;
	int sspacing =2 , ispacing= 5;
	int nhood = 2;
	double lambda = _LOCAL_MINMAX;
	EEXTTYPE Etype = _EDGE;

	if (argc==1) printhelp();
	else {
		getparam(argc,argv,&magnify,&level, &sspacing, &ispacing, 
			&nhood, &lambda, &Etype);
		testmain(argv[1],argv[2],level,magnify, sspacing, ispacing,
		  	  nhood, lambda,Etype);		
		return(0);
	}	
}                                                                                                                                                          

void testmain( char *imgfile,	/* image file */
	       char *confile,	/* contour file */
	       int level,	/* pyramid level */
	       short mag, 	/* image magnifiaction factor */
	       int sspacing,	/* snaxel spacing */
	       int ispacing,	/* search segment spacing */
	       int nhood,	/* number segment */
	       double lambda,	/* regularization parameter */
	       EEXTTYPE Etype)	/* external energy type */
{
	GSNAKE mysnake(Etype);

	/* If no image file or contour file, cannot continue */
	if ( (mysnake.putRawImg(imgfile)) || (mysnake.CONTOUR::read(confile)) )
		exit(-1);

	/* Displaying the operating parameters */	
	printf("\n********   Operating Parameters    ************\n");
	printf("\nImage : %s   Contour : %s ", imgfile, confile);
	printf("\nSearch Spacing : %d  Insertion spacing : %d",
	 				sspacing, ispacing);
	printf("\nSearch Nhood : %d, Lambda : %f",nhood, lambda);
	printf("\nExternal Energy input : ");

	switch (Etype) {
		case _INTENSITY :
			printf("Intensity"); 
		        break; 

		case _EDGE :
			printf("Edge energy"); 
		        break;

		case _EDGEMAG :
			printf("Edge magnitude only"); 
		        break;
	}

	if (verbose) printf("\nVerbose mode on");
	printf("\n\n************************************************\n\n");

	mysnake.generate( level, 1 );
  	mysnake.PYRAMID::show( mag, level );
	printf("\nPress enter to continue");
	getchar();

	printf("\nPerforming localization and minimisation");
	mysnake.GSNAKE::localize();
	mysnake.GSNAKE::minimize(sspacing, nhood, ispacing, mag, verbose,
	                         lambda, 1);
	printf("\nEnd of test. Press enter. ");
	getchar(); 
}



void getparam(int ac, char **av, int *Mfactor, int *level, int *sspacing,
	      int *ispacing, int *nhood,double *lambda, EEXTTYPE *Etype)
{   
	register int i;
	char *inputstr;

	for (i=2; i<ac; i++) {
	
		if (*av[i] == '/') verbose = 1;

		if (*(av[i]) != '-') continue;
			
		inputstr = av[i]+2;

		switch( *(av[i]+1) ) {
				
		   case 'M' :
			*Mfactor=atoi(inputstr);
			break;
	
		   case 'L' :
		   	*level = atoi(inputstr);
		   	break;
	
		   case 'S' :
		    	inputstr=av[i]+3;
			*sspacing = atoi(inputstr);
			break;

		   case 'H' :
			*nhood = atoi(inputstr);
		   	break;
	
		   case 'D' :
			*ispacing = atoi(inputstr);
		   	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;
			}

		  default: break;

		}
	}
}


void printhelp()
{
	printf("\n\nLocalisation and minimisation with GSNAKE");
	printf("\n Usage :OOgsn1 <image> <contour> [ option ]");
	printf("\n [ option ]");
	printf("\n -M       :Magnification factor, default 1 ");
	printf("\n -L       :Level of pyramid to build to, default 2");
	printf("\n -S       :Stratified search segment spacing, default 2");
        printf("\n -H       :Numbers of the search segment, default 2");
        printf("\n -D       :Desired snaxel spacing of an expanded snake,");
	printf("\n          :default 5");
        printf("\n -E/i/e/m :External energy input type, default e");
	printf("\n          :i - Intensity  e - Edge magnitude and direction");
	printf("\n          :m - Edge Magnitude only\n\n");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -