SemSegTools.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. * @param classMapping mapping for a subset of classes
  37. */
  38. static void updateConfusionMatrix (
  39. const NICE::ImageT<int> & img,
  40. const NICE::ImageT<int> & gt,
  41. NICE::Matrix & M,
  42. const std::set<int> & forbiddenClasses,
  43. std::map<int,int> & classMapping );
  44. /**
  45. * @brief compute typical classification statistics using confusion matrix
  46. * @param confMat confusion matrix
  47. * @param classNames class names object
  48. * @param forbidden_classes set of classes, that should be ignored
  49. * @param classMappingInv mapping for a subset of classes
  50. */
  51. static void computeClassificationStatistics (
  52. NICE::Matrix & confMat,
  53. const OBJREC::ClassNames & classNames,
  54. const std::set<int> & forbiddenClasses,
  55. std::map<int,int> & classMappingInv );
  56. /**
  57. * @brief save results to image file
  58. * @param conf Config file
  59. * @param section section in config file
  60. * @param orig input image
  61. * @param gtruth ground truth data
  62. * @param segment segmentation result
  63. */
  64. static void saveResultsToImageFile (
  65. const NICE::Config * conf,
  66. const std::string & section,
  67. const NICE::ColorImage & orig,
  68. const NICE::ColorImage & gtruth,
  69. const NICE::ColorImage & segment,
  70. const std::string & file );
  71. /** collect pixel-wise training examples
  72. from a set of images
  73. @param conf includes settings about grid size etc.
  74. @param section section of the config
  75. @param train set of training images with localization information
  76. @param cn classNames object
  77. @param examples resulting pixel-wise examples
  78. @param imgexamples image based caching structure referenced by pixel-wise examples
  79. */
  80. static void collectTrainingExamples (
  81. const NICE::Config * conf,
  82. const std::string & section,
  83. const LabeledSet & train,
  84. const ClassNames & cn,
  85. Examples & examples,
  86. std::vector<CachedExample *> & imgexamples );
  87. };
  88. } // namespace
  89. #endif