SemSegObliqueTree.h 3.7 KB

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