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

📄 gsn3.c

📁 图像中非刚性曲线的蛇形检测算法
💻 C
字号:
/****************************************************************************
 File Name  : gsn3.c
 Purpose    : internal and external energy calculation
 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"
#include "xwindow.h"

void getparam(int ac, char **av, int *Mfactor, int *level,
	      int *correlateX, int *correlateY, char **outfile);
void testmain(char *imgfile, int level, int mag,
	      int correlateX, int correlateY, char *outfile);
void printhelp();

main( int argc, char **argv )
{
	int level = 2;
	int magnify = 1;
	int correlateX = 5;
	int correlateY = 5;
	char *outfile = NULL;

	if (argc==1) printhelp();
	else {
		getparam(argc,argv,&magnify,&level, 
			&correlateX,&correlateY,&outfile);			
		testmain(argv[1],level,magnify,
			 correlateX,correlateY,outfile);
		return(0);
	}	
}         


void testmain( char *imgfile,	/* image file */
	       int level,	/* pyramid level */
	       int mag,		/* magnification factor */
	       int correlateX,	/* X resolution for correlation */
	       int correlateY,	/* Y resolution for correlation */
	       char *outfile)	/* output file */
{

	int row, col, i;
	GSNAKE mysnake;
	SNAXEL *sptr;
	
	if (mysnake.putRawImg(imgfile) ) exit(-1);
	
	row = mysnake.PYRAMID::rawImg->getRow();
	col = mysnake.PYRAMID::rawImg->getCol();
	mysnake.generate(level,1);
	
	/* Autoinitialising of a closed snake */
	/* centre at cg of image, radius= smaller of row/col divide by 4 */
	
	printf("\nCreating template from image dimension ..");
	mysnake.CONTOUR::init(row/2, col/2,(double)MIN(row,col)/4);
	printf("\nPerforming localisation of contour.");
	mysnake.localize();
	mysnake.computeCG();
	mysnake.computeAvgLength();

	printf("\nEnergy values before fine localisation ");
	printf("\n   Snake energy calculation");
	printf("\n********************************");
	printf("\n[col row]\tEint\tEext\tEtotal\tLambda\n");
	printf("---------\t----\t----\t------\t------\n");
        mysnake.ESnake( 0, 1 );
        printf("\nTotal energy : %f\n",
                mysnake.getEsnake() );
	mysnake.show(mag);
	printf("\nPress enter to continue ..");
	getchar();

	mysnake.fineLocalize( correlateX, correlateY );  
	
	printf("\nTotal energy after fine localisation ");
	printf("\n   Snake energy calculation");
	printf("\n********************************");
	printf("\n[col row]\tEint\tEext\tEtotal\tLambda\n");
	printf("---------\t----\t----\t------\t------\n");
	mysnake.computeCG();
	mysnake.computeAvgLength();
        mysnake.ESnake( 0, 1 );
        printf("\nTotal energy : %f\n", mysnake.getEsnake() );
	mysnake.show(mag);
	printf("\nPress enter to continue ..");
	getchar();
}                                                                                                                                                 

void getparam( int ac, char **av,
	       int *Mfactor, int *level,
	       int *correlateX, int *correlateY,
	       char **outfile )
{   
	register int i;
	char *inputstr;

	for (i=2; i<ac; i++) {
	
		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 'O' :
			*outfile = inputstr;
			break;

		   case 'C' :
			inputstr = av[i]+3;
                        switch (*(av[i]+2)) {
                           case 'x': 
				*correlateX = atoi(inputstr);
				break;
                           case 'y': 
				*correlateY = atoi(inputstr);
				break;
                        }

		   default :
			break;
		}
	}
}


void printhelp()
{
	printf("\n\nEnergy calculation before and after fine correlation.");
	printf("\n Usage :OOgsn3 <image> [ option ]");
	printf("\n [ option ]");
	printf("\n -M    :Magnification factor, default 1 ");
	printf("\n -L    :Level of pyramid to build to, default 2");
	printf("\n -C    :Resolution of fine correlation,");
	printf("\n       :default x=5, y=5\n\n");
}

⌨️ 快捷键说明

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