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

Windows Develop

Development Platform:

Unix_Linux

  1. /****************************************************************************
  2.  File Name  : imgclass.c
  3.  Purpose    : classify various templates
  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 printhelp();
  14. void testmain( char **imgsample );
  15. main( int argc, char **argv )
  16. {
  17. char **imgsamples ;
  18. imgsamples = &argv[1] ;
  19. if( argc < 2 )
  20. printhelp();
  21. else 
  22. testmain( imgsamples );
  23. }
  24. void testmain( char **imgsamples ) /* image samples */
  25. {
  26. register short i ;
  27. CLASSIFY shape(_EDGE) ;
  28. shape.Nrxy = 3 ;    /* allow some stretching in diagonal direction */
  29. if( shape.read("ellip.con") != NOERROR ||
  30.     shape.read("rect.con") != NOERROR  ) {
  31.      printf("cannot find contour filesn") ;
  32.      exit(-1) ;
  33. }
  34. for(i=0; *imgsamples; i++, imgsamples++) {
  35. IMAGE myImage ;
  36. if( myImage.read(*imgsamples) != NOERROR )
  37. break ;
  38. int id = shape.classify(&myImage, _MARGIN_PROB) ;
  39. printf("%s : %sn", *imgsamples, shape.getLabel(id) ) ;
  40. shape.dump(*imgsamples) ;
  41. }
  42. exit(0) ;
  43. }
  44. void printhelp()
  45. {
  46.         printf("n To classify various templates");
  47.         printf("n Usage : imgclass <image samples>nn");
  48. }