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