SemanticSegmentation.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * @file SemanticSegmentation.h
  3. * @brief abstract interface for semantic segmentation algorithms
  4. * @author Erik Rodner
  5. * @date 03/19/2009
  6. */
  7. #ifndef SEMANTICSEGMENTATIONINCLUDE
  8. #define SEMANTICSEGMENTATIONINCLUDE
  9. #include <vector>
  10. #include "core/image/MultiChannelImage3DT.h"
  11. #include "vislearning/cbaselib/MultiDataset.h"
  12. #include "vislearning/cbaselib/LocalizationResult.h"
  13. #include "vislearning/cbaselib/CachedExample.h"
  14. #include "vislearning/cbaselib/Example.h"
  15. namespace OBJREC
  16. {
  17. /** abstract interface for semantic segmentation algorithms */
  18. class SemanticSegmentation
  19. {
  20. protected:
  21. /** accessible class names and information about
  22. number of classes etc. */
  23. const ClassNames *classNames;
  24. /** enum type for imagetype */
  25. enum
  26. {
  27. IMAGETYPE_RGB = 0,
  28. IMAGETYPE_GRAY
  29. };
  30. /** whether to load images with color information */
  31. int imagetype;
  32. public:
  33. /** simple constructor */
  34. SemanticSegmentation ();
  35. /** constructor
  36. @param conf global settings
  37. @param classNames this ClassNames object while be stored as a attribute
  38. */
  39. SemanticSegmentation ( const NICE::Config *conf,
  40. const ClassNames *classNames );
  41. /** simple destructor */
  42. virtual ~SemanticSegmentation();
  43. /** classification function (has to be overloaded by all subclasses)
  44. * @param imgData image data
  45. * @param segresult result of the semantic segmentation with a label for each pixel
  46. * @param probabilities multi-channel image with one channel for each class and
  47. * corresponding probabilities for each pixel
  48. * @param filelist filename list of images that represent slices of a stack
  49. */
  50. virtual void classify ( NICE::MultiChannelImage3DT<double> & imgData,
  51. NICE::MultiChannelImageT<double> & segresult,
  52. NICE::MultiChannelImage3DT<double> & probabilities,
  53. const std::vector<std::string> & filelist ) = 0;
  54. /** training function (has to be overloaded by all subclasses)
  55. * @param md the data set
  56. */
  57. virtual void train ( const MultiDataset * md ) = 0;
  58. /**
  59. * collect information about the depth of 3d images
  60. * @param *Files a labeled set of data
  61. * @param depthVec output of depth values
  62. * @param run3dseg whether slice counting is necessary or not
  63. */
  64. void getDepthVector ( const LabeledSet *Files, std::vector<int> & depthVec, const bool run3dseg );
  65. /**
  66. * convert different datatypes
  67. */
  68. void convertVVectorToExamples ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
  69. void convertExamplesToVVector ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
  70. void convertExamplesToLSet ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  71. void convertLSetToExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  72. void convertLSetToSparseExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  73. /**
  74. *load image slices into a single MCI3DT
  75. */
  76. void make3DImage ( const std::vector<std::string> & filelist,
  77. NICE::MultiChannelImage3DT<double> & imgData );
  78. /**
  79. * @brief show a probability map for a given class
  80. * @param prob class probabilites for each pixel
  81. * @param cl class number
  82. */
  83. void getProbabilityMap( const NICE::MultiChannelImage3DT<double> & prob );
  84. };
  85. } // namespace
  86. #endif