SemanticSegmentation.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 <objrec/nice.h>
  10. #include "vislearning/cbaselib/MultiDataset.h"
  11. #include "vislearning/cbaselib/LocalizationResult.h"
  12. #include "vislearning/cbaselib/CachedExample.h"
  13. #include "vislearning/cbaselib/Example.h"
  14. namespace OBJREC
  15. {
  16. /** abstract interface for semantic segmentation algorithms */
  17. class SemanticSegmentation
  18. {
  19. protected:
  20. /** accessible class names and information about
  21. number of classes etc. */
  22. const ClassNames *classNames;
  23. /** enum type for imagetype */
  24. enum
  25. {
  26. IMAGETYPE_RGB = 0,
  27. IMAGETYPE_GRAY
  28. };
  29. /** whether to load images with color information */
  30. int imagetype;
  31. public:
  32. /** simple constructor
  33. @param conf global settings
  34. @param classNames this ClassNames object while be stored as a attribute
  35. */
  36. SemanticSegmentation ( const NICE::Config *conf,
  37. const ClassNames *classNames );
  38. /** simple destructor */
  39. virtual ~SemanticSegmentation();
  40. /** this function has to be overloaded by all subclasses
  41. @param ce image data
  42. @param segresult result of the semantic segmentation with a label for each
  43. pixel
  44. @param probabilities multi-channel image with one channel for each class and
  45. corresponding probabilities for each pixel
  46. */
  47. virtual void semanticseg ( OBJREC::CachedExample *ce,
  48. NICE::Image & segresult,
  49. NICE::MultiChannelImageT<double> & probabilities ) = 0;
  50. /**
  51. * convert different datatypes
  52. */
  53. void convertVVectorToExamples ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
  54. void convertExamplesToVVector ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
  55. void convertExamplesToLSet ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  56. void convertLSetToExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  57. void convertLSetToSparseExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
  58. /** load img from file call localize(CachedExample *ce) etc. */
  59. void semanticseg ( const std::string & filename,
  60. NICE::Image & segresult,
  61. NICE::MultiChannelImageT<double> & probabilities );
  62. };
  63. } // namespace
  64. #endif