SemanticSegmentation.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 ( const 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. */
  61. void getDepthVector ( const LabeledSet *Files, std::vector<int> & depthVec );
  62. /**
  63. * convert different datatypes
  64. */
  65. void convertVVectorToExamples ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
  66. void convertExamplesToVVector ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
  67. void convertExamplesToLSet ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  68. void convertLSetToExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  69. void convertLSetToSparseExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  70. /**
  71. *load image slices into a single MCI3DT
  72. */
  73. void make3DImage ( const std::vector<std::string> & filelist,
  74. NICE::MultiChannelImage3DT<double> & imgData );
  75. };
  76. } // namespace
  77. #endif