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

📄 ima1.c

📁 图像中非刚性曲线的蛇形检测算法
💻 C
字号:
/****************************************************************************
 File Name  : ima1.c
 Purpose    : reading, writing and correlation of images
 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 "xwindow.h"
#include "gsnake.h"

void testmain(char *,char *,char *,int );
void printhelp();
void getparam(int, char **, int *, char **, char **);

main(int argc, char *argv[])
{
	int i, j;
	int magnify;
	char *imgfile;
	char *tempfile=NULL;
	char *outfile = NULL;
	
	magnify =1;

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


void testmain( char *imgfile,	/* input image file */
	       char *tmpfile,	/* image template */
	       char *outfile,	/* output image file */
	       int mag )	/* magnification factor */
{  

	IMAGE test1,test2;
	IMAGE *test3;

	/* Read test images */
	if ( test1.read(imgfile) )  exit(-1);
	
	printf("Showing test image : %s",imgfile);
	test1.show(mag);
	
	/* If user did not specify template image, use a gaussian template */
	if (tmpfile) {
		if( test2.read(tmpfile) ) exit( -1 ); 
	}
	else
		test2.initAsGauss();
	test2.show(mag); 
	
	printf("\nCorrelating image..");	
  	test3=test1.correlate(&test2,2,2,1); 
	
	/* Show all three images horizontally */
	
	/* Allocate window space for three images */
	test1.show(mag,3,0,0);
	
	/* Show images with offsets */
	test2.show(mag,1,test1.getCol());
	test3->show(mag,1,test2.getCol()+test1.getCol());
	printf("\nPress enter to continue ");
	getchar();
	
	/* write result to file */
	if (outfile)
	   test3->write(outfile) ;
	else
	   test3->write("out.bin");
	
	printf("End of test..");
	xwin_close();	
}


void getparam(int ac, char **av, int *Mfactor, char **temp, 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 'T' :
		   	 *temp=inputstr;
			 break;

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

		    default: break;
		};
	};
};


void printhelp()
{
	printf("\n\nCorrelation of two images");
	printf("\n Usage :OOima1 <image> -T<template> [ option ] ");
	printf("\n [ option ]");
	printf("\n -M    :Magnification factor, default 1 ");
	printf("\n -O    :Output image file");
	printf("\n\n");
}

⌨️ 快捷键说明

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