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

📄 gsinit.c

📁 图像中非刚性曲线的蛇形检测算法
💻 C
字号:
/****************************************************************************
 File Name  : gsinit
 Purpose    : to create g-snake template
 Release    : Version 1.0
 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 , char** ,int *, INITMODE *, SNAKEMODE *,int *,char **);
void printHelp();

main( int argc, char **argv )
{
	IMAGE	myimage;		/* image object */
	GSNAKE	mysnake;		/* gsnake object */
	
	int Numpts	= 16;		/* number of snaxels */
	int level	= 2;		/* Gaussian pyramid level */
	int mag		= 1;		/* magnification factor */
	INITMODE Mode	= _LOADTEMPLATE;/* contour initialization */
	SNAKEMODE SMode = _CLOSED;	/* gsnake mode */
	char *filename	= NULL;		/* output filename */

	short row, col;			/* image size */
	short register i, j;

	if (argc == 1)
	   printHelp();

	else {
				
	   getparam(argc, argv, &mag, &Mode, &SMode, &Numpts, &filename);

	   if  ( !(myimage.read(argv[1])) ) { 
	
		/* generate gsnake */
		row = myimage.getRow();
		col = myimage.getCol();

		printf("\nCreate template ... wait\n\n");	

		/* Generating line or circle based on image automatically */
		if (Mode == _LOADTEMPLATE) {

		   if ( SMode == _CLOSED )		
		   	mysnake.CONTOUR::init( row/2, col/2, 
					(double)MIN(row,col)/4.0,Numpts );
		   else
			mysnake.CONTOUR::init( 
					(short)(col/4), (short)(row/4),
					(short)(3*col/4), (short)(row/2),
					 Numpts );
		}

		/* Generating template using either click or drag */
		if (Mode != _LOADTEMPLATE) 

		    /* Initialising level 0 image */
		    mysnake.CONTOUR::init( &myimage, mag, Mode,SMode);
		
		if ( !filename ) 
		    filename = strdup("contour");		

		if ( mysnake.write(filename) )
		    printf("\nUnable to write to file %s\n", filename);
	     }
	}	

	xwin_close();
}


void getparam( int ac, char** av,
	       int *Mfactor,		/* magnification factor */
	       INITMODE *mode,		/* contour initialization mode */
 	       SNAKEMODE *smode,	/* gsnake mode */
	       int *Numpt,		/* number of snaxels */
	       char **outfile )		/* output filename */
{   
	register short i;
	char *inputstr;

	for (i=2; i<ac; i++) {

		if( *av[i] != '-' )
			continue;	/* illegal input */

		inputstr = av[i]+2;

		switch( *(av[i]+1) ) {

		   case 'I' :
			switch (*(av[i]+2)) {
			   case 'c': *mode = _CLICKMOUSE; break;
			   case 'd': *mode = _DRAGMOUSE;break;			
			   case 'a': *mode = _LOADTEMPLATE;break;
			}
			break;

		   case 'S' :
			switch (*(av[i]+2)) {
			   case 'c': *smode = _CLOSED; break;
			   case 'o': *smode = _OPENED;break;			
			}
			break;

		   case 'M' :
			*Mfactor=atoi(inputstr);	
			break;
		
		   case 'N' :
			*Numpt=atoi(inputstr);
			break;

		   case 'O' :
			*outfile = inputstr;
			break;
 
		   default: break;
		}
	}
}



void printHelp()
{		
	printf("\n\nCreation of GSNAKE template");
	printf("\n\nUsage: gsinit <image> -[option]  ");
	printf("\n [ option ]\n ");
	printf("\n    M     : Magnification factor, default 1");
	printf("\n    N     : Number of points in SNAKE, default 16");
	printf("\n    I d/c : Snake initialisation, default a");
	printf("\n 	    : d - Drag  c - Click  a - Automatic ");
	printf("\n    S o/c : Type of snake to be formed, default c");
	printf("\n          : o - Open ended  c - Closed");
	printf("\n    O     : Output contour filename,"); 
	printf("\n          : default filename <contour>\n\n");
}	
		

⌨️ 快捷键说明

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