SemSegObliqueTree.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /**
  2. * @file SemSegObliqueTree.h
  3. * @brief Semantic Segmentation using Oblique Trees
  4. * @author Sven Sickert
  5. * @date 10/17/2014
  6. */
  7. #ifndef SEMSEGOBLIQUETEEINCLUDE
  8. #define SEMSEGOBLIQUETEEINCLUDE
  9. // nice-core includes
  10. // nice-vislearning includes
  11. #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h"
  12. // nice-semseg includes
  13. #include "SemanticSegmentation.h"
  14. namespace OBJREC
  15. {
  16. class SemSegObliqueTree : public SemanticSegmentation
  17. {
  18. private:
  19. /** pointer to config file */
  20. const NICE::Config *conf;
  21. /** save / load trained classifier */
  22. bool saveLoadData;
  23. /** 0 - RGB, 1 - HSV, 2 - CIELab */
  24. int colorMode;
  25. /** file location of trained classifier */
  26. std::string fileLocation;
  27. /** classifier for categorization */
  28. FeaturePoolClassifier *fpc;
  29. /**
  30. * @brief pre-processing: resulting channels with values in the range [0,1] for RGB, HSV or GREY
  31. * @param ce current cached example
  32. * @param isColor color mode
  33. */
  34. void preprocessChannels ( CachedExample *ce, bool isColor ) const;
  35. public:
  36. /** simple constructor */
  37. SemSegObliqueTree ();
  38. /** config constructor */
  39. SemSegObliqueTree (
  40. const NICE::Config *conf,
  41. const ClassNames *classNames );
  42. /** simple destructor */
  43. virtual ~SemSegObliqueTree();
  44. /**
  45. * @brief Setup internal variables and objects used
  46. * @param conf Configuration file to specify variable settings
  47. * @param s_confSection Section in configuration file
  48. */
  49. void initFromConfig (
  50. const NICE::Config *_conf,
  51. const std::string & s_confSection = "SemSegObliqueTree" );
  52. /**
  53. * @brief training function / learn classifier
  54. * @param md the data set
  55. */
  56. void train ( const MultiDataset *md );
  57. /**
  58. * @brief classification function
  59. @param ce image data
  60. @param segresult result of the semantic segmentation with a label
  61. for each pixel
  62. @param probabilities multi-channel image with one channel for
  63. each class and corresponding probabilities for each pixel
  64. */
  65. void semanticseg ( CachedExample *ce,
  66. NICE::ImageT<int> &segresult,
  67. NICE::MultiChannelImageT<double> &probabilities );
  68. /**
  69. * Classify each voxel of a 3D image (image stack)
  70. * @author Sven Sickert
  71. * @param ce 3d image data
  72. * @param segresult segmentation results (output)
  73. * @param probabilities probabilities for each pixel (output)
  74. */
  75. void semanticseg ( OBJREC::CachedExample *ce,
  76. NICE::MultiChannelImageT<int> & segresult,
  77. NICE::MultiChannelImage3DT<double> & probabilities );
  78. ///////////////////// INTERFACE PERSISTENT /////////////////////
  79. // interface specific methods for store and restore
  80. ///////////////////// INTERFACE PERSISTENT /////////////////////
  81. /**
  82. * @brief Load segmentation object from external file (stream)
  83. */
  84. virtual void restore ( std::istream & is, int format = 0 );
  85. /**
  86. * @brief Save segmentation-object to external file (stream)
  87. */
  88. virtual void store( std::ostream & os, int format = 0 ) const;
  89. /**
  90. * @brief Clear segmentation-object object
  91. */
  92. virtual void clear ();
  93. };
  94. } // namespace
  95. #endif