SemanticSegmentation.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. @param conf global settings
  35. @param classNames this ClassNames object while be stored as a attribute
  36. */
  37. SemanticSegmentation ( const NICE::Config *conf,
  38. const ClassNames *classNames );
  39. /** simple destructor */
  40. virtual ~SemanticSegmentation();
  41. /** classification function (has to be overloaded by all subclasses)
  42. * @param imgData image data
  43. * @param segresult result of the semantic segmentation with a label for each pixel
  44. * @param probabilities multi-channel image with one channel for each class and
  45. * corresponding probabilities for each pixel
  46. * @param filelist filename list of images that represent slices of a stack
  47. */
  48. virtual void classify ( NICE::MultiChannelImage3DT<double> & imgData,
  49. NICE::MultiChannelImageT<double> & segresult,
  50. NICE::MultiChannelImage3DT<double> & probabilities,
  51. const std::vector<std::string> & filelist ) = 0;
  52. /** training function (has to be overloaded by all subclasses)
  53. * @param md the data set
  54. */
  55. virtual void train ( const MultiDataset * md ) = 0;
  56. /**
  57. * collect information about the depth of 3d images
  58. * @param *Files a labeled set of data
  59. * @param depthVec output of depth values
  60. * @param run3dseg whether slice counting is necessary or not
  61. */
  62. void getDepthVector ( const LabeledSet *Files, std::vector<int> & depthVec, const bool run3dseg );
  63. /**
  64. * convert different datatypes
  65. */
  66. void convertVVectorToExamples ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
  67. void convertExamplesToVVector ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
  68. void convertExamplesToLSet ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  69. void convertLSetToExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  70. void convertLSetToSparseExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  71. /**
  72. *load image slices into a single MCI3DT
  73. */
  74. void make3DImage ( const std::vector<std::string> & filelist,
  75. NICE::MultiChannelImage3DT<double> & imgData );
  76. /**
  77. * @brief show a probability map for a given class
  78. * @param prob class probabilites for each pixel
  79. * @param cl class number
  80. */
  81. void getProbabilityMap( const NICE::MultiChannelImage3DT<double> & prob );
  82. };
  83. } // namespace
  84. #endif