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

📄 imglearn.c

📁 图像中非刚性曲线的蛇形检测算法
💻 C
字号:
/****************************************************************************
 File Name  : imglearn.c
 Purpose    : to train shape matrix and deformation variance
 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 help();

main( int argc, char **argv )
{
	MODEL model;		/* to store results of learning */
	GSNAKE sample(_EDGE);	/* sample will use _EDGE as external energy */
	char *outfile;		/* output contour file */
	char **imgsamples;	/* image samples */
	short level = 2;        /* pyramid level */
	register short i;
	
	if (argc < 3) {
                help();
                exit( -1 );
        }
	
	imgsamples = &argv[2] ;
	outfile = argv[1] ;
	
	for(i=0; *imgsamples ; i++, imgsamples++) {

	    printf("Using Sample %s to Learn SHAPE\n\n", *imgsamples);
	    
	    sample.putRawImg(*imgsamples);
	
	    if( i==0 ) {

		/* use manually selected feature points to 
	   	   estimate the shape matrix */
	   	   
		sample.CONTOUR::init( sample.rawImg );
		model.LearnShape( &sample );
	    }

	  /* Using the initial shape matrix and minimiax regularization, 
	     the total energy of gsnake is minimize and then the shape 
	     matrix is updated */

	    model.duplicate(&sample);
	    sample.generate(level, 1);  	/* generate pyramid */

	    sample.localize(5, 5, 1, 0.25, 3);  /* localize the contour */
	    sample.minimize(5, 5, 0);		/* minimize energy */
	    sample.deform();			/* manually adjust */
	    
	    model.LearnShape( &sample );  	/* average out the shape coef */
	    
	    if(i) model.regenerate() ;	/* regenerate the shape based on mtx */
	}


	/* deformation and noise variance are done only after the 
	   shape matrix has been properly trained */
	for(imgsamples = &argv[2]; *imgsamples; imgsamples++) {
	
		printf("Using Sample %s to Learn DEFORMATION\n\n", *imgsamples);

	    	sample.putRawImg(*imgsamples);
	    	model.duplicate(&sample);
	    	sample.generate(level, 1);
	    	sample.localize(5, 5, 1, 0.25, 3);
	    	sample.putGLambda(_LOCAL_MINMAX);
	    	sample.minimize(5, 5, 0);
	    	sample.deform();
	
		model.LearnDeform( &sample ); /* average out the deform param */
		
		
	}
	
	model.computeZ() ;  /* compute normalizing constant using monte_carlo
			       estimation */

	model.CONTOUR::print() ;

	model.CONTOUR::write( outfile );	/* write it to file */
	
}

void help()
{
           printf("\n Image learn Utility \n");
           printf(" Usage : imglearn <contour> <image samples>\n");
           printf(" Images can be of type bin or SUN raster. \n\n");
}

⌨️ 快捷键说明

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