📄 gho2.c
字号:
/****************************************************************************
File Name : gho2.c
Purpose : find multiple g-snake by generalized Hough transform
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 :
kflai@iti.gov.sg
asschan@ntu.ac.sg
***************************************************************************/
#include "gsnake.h"
#include "xwindow.h"
void testmain(char *, char *, short, int, short);
void printhelp();
void getparam(int ac, char** av, short *, int *, short *);
main(int argc, char **argv)
{
int Magnify = 1;
short Level = 2;
short numgsnake = 1;
char *confile;
if (argc==1)
printhelp();
else {
getparam(argc,argv, &numgsnake, &Magnify, &Level );
testmain(argv[1], argv[2], numgsnake, Magnify, Level);
return(0);
}
}
void testmain( char *imgfile, /* image file */
char *cfile, /* contour file */
short numgsnake, /* number of desired snakes */
int mag, /* magnification factor */
short level ) /* pyramid level */
{
PYRAMID mypyramid; /* PYRAMID object */
EDGE *edgemap; /* EDGE object */
CONTOUR mycontour; /* CONTOUR object */
CONTOUR **localised; /* CONTOUR object */
SNAXEL *sptr; /* SNAXEL object */
GHOUGH GHT_OBJ; /* GHOUGH object */
int row, col; /* image of col x row */
int ratio;
if ( mypyramid.putRawImg(imgfile) )
exit (-1);
if (cfile) {
if (mycontour.read(cfile))
exit(-1);
}
else {
/* Initialise a closed contour in the centre of the test image */
/* Radius of circle = smaller of row and col divide by 5 */
/* The values are arbitrary */
row = mypyramid.rawImg->getRow();
col = mypyramid.rawImg->getCol();
mycontour.init(row/2,col/2,(double) MIN(row,col)/5,8);
}
/* Generate pyramid in verbose mode to level 3 */
mypyramid.generate(level, 1);
mypyramid.show(mag,level);
printf("\nPress enter to continue.");
getchar();
printf("\nCo-ordinates before transform\n ");
mycontour.print();
mypyramid.rawImg->show(mag);
for (sptr=mycontour.getHead();sptr;sptr=sptr->getNext())
sptr->show( mypyramid.rawImg,
ROUNDOFF(sptr->getRow())*mag,
ROUNDOFF(sptr->getCol())*mag );
printf("\nPress enter to continue.");
getchar();
/* Use external energy input Edge.The edge object used is the
highest level one because the search area will be the
smallest */
ratio = mypyramid.getLevel()-1;
/* Reduce contour to size of highest edge */
mycontour.expand(LEVEL(-ratio));
/* Get highest level in pyramid */
edgemap = mypyramid.getEdge(ratio);
localised = GHT_OBJ.localize( &mycontour, edgemap, numgsnake );
register short i;
for ( i=0; i< numgsnake; i++ ) {
printf("\nLocalised contour [%d] on image.\n", i );
/* Get the localised gsnake. */
/* Contour will be in natural image size */
localised[i]->expand(LEVEL(ratio));
localised[i]->print();
mypyramid.rawImg->show(mag);
for ( sptr=localised[i]->getHead(); sptr; sptr=sptr->getNext() )
sptr->show( mypyramid.rawImg,
ROUNDOFF(sptr->getRow())*mag,
ROUNDOFF(sptr->getCol())*mag);
printf("\n\nPress Enter to Continue\n");
getchar();
}
}
void getparam( int ac,
char** av,
short *numgsnake,
int *mag,
short *level )
{
register int i;
char *inputstr;
for (i=1; i<ac; i++) {
if( *av[i] != '-' )
continue; /* illegal input */
inputstr = av[i]+2;
switch( *(av[i]+1) ) {
case 'n' :
*numgsnake = atoi(inputstr);
break;
case 'M' :
*mag=atoi(inputstr);
break;
case 'L' :
*level=atoi(inputstr);
break;
}
}
}
void printhelp()
{
printf("\n\nLocalisation of contour on image");
printf("\n Usage :OOgho2 <image> <contour> [ option ]");
printf("\n [ option ]");
printf("\n -n : number of contours to be localized, default 1");
printf("\n -M : Magnification factor, default 1");
printf("\n -L : Level of pyramid, default 2\n\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -