SemSegTools.h 3.4 KB

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