pym2.c
Upload User: shhuayu888
Upload Date: 2013-03-28
Package Size: 1788k
Code Size: 4k
Category:

Windows Develop

Development Platform:

Unix_Linux

  1. /****************************************************************************
  2.  File Name  : pym1.c
  3.  Purpose    : Getting gaussian image and edge map
  4.  Date     : Aug 31,1995
  5. GSNAKE API is jointly developed by the Information Technology Institute (ITI), Singapore, and the School of Applied Science, Nanyang Technological
  6. University (NTU), Singapore. 
  7. 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.
  8. 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 :
  9. asschan@ntu.ac.sg
  10. kflai@iti.gov.sg
  11. ***************************************************************************/
  12. #include "gsnake.h"
  13. void testmain(char *,int,int, int );
  14. void printhelp();
  15. void getparam(int, char **, int *, int *, int *);
  16. main(int argc,char **argv)
  17. {
  18. int plevel=2;
  19. int i_level=0;
  20. int magnify =1;
  21. if (argc==1) printhelp();
  22. else {
  23. getparam(argc,argv,&plevel,&i_level,&magnify);
  24. testmain(argv[1],plevel,i_level,magnify);
  25. return(0);
  26. }
  27. }
  28. void testmain( char *imgfile, /* image file */
  29.        int pymlevel, /* pyramid levels */
  30.        int i_level, /* level of interest */
  31.        int mag) /* maginification factor */
  32. {
  33. IMAGE myimage1,
  34.       *myimage2; /* IMAGE object */
  35. PYRAMID mypyramid; /* PYRAMID object */
  36. EDGE *myedge; /* EDGE object */
  37. if ( myimage1.read( imgfile ) ) {
  38. printf("nUnable to get image.n");
  39. exit(-1);
  40. }
  41. /* Placing image into pyramid object by using another image */
  42. mypyramid.putRawImg( &myimage1 );
  43. /* generating pyramid by default conditioning parameters */
  44. mypyramid.generate( pymlevel, 1 );
  45. if ( !i_level ) 
  46. i_level = mypyramid.getLevel() - 1;
  47. /* get edge map and Guassian images of interest */
  48. myimage2 = mypyramid.getGauss( i_level );
  49. myedge = mypyramid.getEdge( i_level );
  50. /* Showing gaussian image at level */
  51. if ( myimage2 && myedge) {
  52. printf("nShowing level %d Gaussian image", i_level);
  53. myimage2->show( mag*i_level );
  54. printf("nPress enter to continue .");
  55. getchar();
  56. printf("nShowing level %d edge map", i_level);
  57. myedge->show( mag*i_level );
  58. printf("nPress enter to continue.");
  59. getchar();
  60. }
  61. else 
  62. printf("nLevel specified is invalid.");
  63. printf("nEnd of testn");
  64. }
  65. void getparam(int ac, char **av,int *plev, int *lev,int *Mfactor)
  66. {   
  67. register int i;
  68. char *inputstr;
  69. for (i=2; i<ac; i++) {
  70. if (*(av[i]) != '-') continue;
  71. inputstr = av[i]+2;
  72. switch( *(av[i]+1) ) {
  73.    case 'M' :
  74. *Mfactor=atoi(inputstr);
  75. break;
  76.    case 'L' :
  77.      *plev=atoi(inputstr);
  78.  break;
  79.    case 'l' :
  80.      *lev = atoi(inputstr);
  81.      break;
  82.     default: break;
  83. }
  84. }
  85. }
  86. void printhelp()
  87. {
  88. printf("nnCreation of pyramid");
  89. printf("n Usage :OOpym2 <image> [ option ]");
  90. printf("n [ option ] ");
  91. printf("n -M    : Magnification factor, default 1 ");
  92. printf("n -L    : Level of pyramid, default 2");
  93. printf("n -l    : Level of image to take. Default top levelnn");
  94. }