main.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /****************************************************************************
  2. *
  3. * MODULE: i.segment
  4. * AUTHOR(S): Markus Metz
  5. * based on the the GSoC project by Eric Momsen <eric.momsen at gmail com>
  6. * PURPOSE: Object recognition, segments an image group.
  7. * COPYRIGHT: (C) 2012 by Eric Momsen, and the GRASS Development Team
  8. *
  9. * This program is free software under the GNU General
  10. * Public License (>=v2). Read the COPYING file that
  11. * comes with GRASS for details.
  12. *
  13. *
  14. * NOTE: the word "segment" is already used by the
  15. * Segmentation Library for the data files/tiling, so
  16. * iseg (image segmentation) will be used to refer to
  17. * the image segmentation.
  18. *
  19. *****************************************************************************/
  20. #include <stdlib.h>
  21. #include <stdio.h>
  22. #include <grass/gis.h>
  23. #include <grass/glocale.h>
  24. #include "iseg.h"
  25. int main(int argc, char *argv[])
  26. {
  27. struct globals globals; /* input and output file descriptors, data structure, buffers */
  28. struct GModule *module;
  29. G_gisinit(argv[0]);
  30. module = G_define_module();
  31. G_add_keyword(_("imagery"));
  32. G_add_keyword(_("segmentation"));
  33. G_add_keyword(_("classification"));
  34. G_add_keyword(_("object recognition"));
  35. module->description =
  36. _("Identifies segments (objects) from imagery data.");
  37. parse_args(argc, argv, &globals);
  38. G_debug(1, "Main: starting open_files()");
  39. if (open_files(&globals) != TRUE)
  40. G_fatal_error(_("Error in reading data"));
  41. G_debug(1, "Main: starting create_isegs()");
  42. if (create_isegs(&globals) != TRUE)
  43. G_fatal_error(_("Error in creating segments"));
  44. G_debug(1, "Main: starting write_output()");
  45. if (write_ids(&globals) != TRUE)
  46. G_fatal_error(_("Error in writing IDs"));
  47. if (globals.method == ORM_RG && globals.gof) {
  48. if (write_gof_rg(&globals) != TRUE)
  49. G_fatal_error(_("Error in writing goodness of fit"));
  50. }
  51. if (globals.method == ORM_MS && globals.bsuf) {
  52. if (write_bands_ms(&globals) != TRUE)
  53. G_fatal_error(_("Error in writing new band values"));
  54. }
  55. G_debug(1, "Main: starting close_files()");
  56. close_files(&globals);
  57. G_done_msg(_("Number of segments created: %d"), globals.max_rid);
  58. exit(EXIT_SUCCESS);
  59. }