imglearn.c
资源名称:gsnake.rar [点击查看]
上传用户:shhuayu888
上传日期:2013-03-28
资源大小:1788k
文件大小:4k
源码类别:
Windows编程
开发平台:
Unix_Linux
- /****************************************************************************
- 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 SHAPEnn", *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 DEFORMATIONnn", *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. nn");
- }
English
