SemSegTools.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /**
  2. * @file SemSegTools.h
  3. * @brief tools for semantic segmentation
  4. * @author Erik Rodner
  5. * @date 03/19/2009
  6. */
  7. #ifndef SEMSEGTOOLSINCLUDE
  8. #define SEMSEGTOOLSINCLUDE
  9. #include "core/basics/Config.h"
  10. #include "vislearning/cbaselib/MultiDataset.h"
  11. #include "vislearning/cbaselib/Example.h"
  12. #include "vislearning/cbaselib/CachedExample.h"
  13. namespace OBJREC
  14. {
  15. /** tools for semantic segmentation */
  16. class SemSegTools
  17. {
  18. protected:
  19. public:
  20. /**
  21. * @brief produce an image with segmentation result as overlay
  22. * @param orig original input image
  23. * @param segment segmentation result
  24. * @param result overlay image
  25. */
  26. static void segmentToOverlay (
  27. const NICE::Image * orig,
  28. const NICE::ColorImage & segment,
  29. NICE::ColorImage & result );
  30. /**
  31. * @brief update confusion matrix with results of current image
  32. * @param img segmentation result
  33. * @param gt ground truth data
  34. * @param M confusion matrix
  35. * @param forbidden_classes set of classes, that should be ignored
  36. */
  37. static void updateConfusionMatrix (
  38. const NICE::Image & img,
  39. const NICE::Image & gt,
  40. NICE::Matrix & M,
  41. const std::set<int> & forbiddenClasses );
  42. /**
  43. * @brief compute typical classification statistics using confusion matrix
  44. * @param confMat confusion matrix
  45. * @param classNames class names object
  46. * @param forbidden_classes set of classes, that should be ignored
  47. */
  48. static void computeClassificationStatistics (
  49. NICE::Matrix & confMat,
  50. const OBJREC::ClassNames & classNames,
  51. const std::set<int> & forbiddenClasses );
  52. /**
  53. * @brief save results to image file
  54. * @param conf Config file
  55. * @param section section in config file
  56. * @param orig input image
  57. * @param gtruth ground truth data
  58. * @param segment segmentation result
  59. */
  60. static void saveResultsToImageFile (
  61. const NICE::Config * conf,
  62. const std::string & section,
  63. const NICE::ColorImage & orig,
  64. const NICE::ColorImage & gtruth,
  65. const NICE::ColorImage & segment,
  66. const std::string & file );
  67. /** collect pixel-wise training examples
  68. from a set of images
  69. @param conf includes settings about grid size etc.
  70. @param section section of the config
  71. @param train set of training images with localization information
  72. @param cn classNames object
  73. @param examples resulting pixel-wise examples
  74. @param imgexamples image based caching structure referenced by pixel-wise examples
  75. */
  76. static void collectTrainingExamples (
  77. const NICE::Config * conf,
  78. const std::string & section,
  79. const LabeledSet & train,
  80. const ClassNames & cn,
  81. Examples & examples,
  82. std::vector<CachedExample *> & imgexamples );
  83. };
  84. } // namespace
  85. #endif