SemSegNovelty.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /**
  2. * @file SemSegNovelty.h
  3. * @brief semantic segmentation using the method from Csurka08
  4. * @author Björn Fröhlich
  5. * @date 04/24/2009
  6. */
  7. #ifndef SemSegNoveltyINCLUDE
  8. #define SemSegNoveltyINCLUDE
  9. #include "SemanticSegmentation.h"
  10. #include "SemSegTools.h"
  11. #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h"
  12. #include "vislearning/features/localfeatures/LFColorWeijer.h"
  13. #include "segmentation/RegionSegmentationMethod.h"
  14. /** @brief pixelwise labeling systems */
  15. namespace OBJREC {
  16. class SemSegNovelty : public SemanticSegmentation
  17. {
  18. protected:
  19. //! boolean whether to save the cache or not
  20. bool save_cache;
  21. //! boolean whether to read the cache or not, if read_cache is false, everything will be trained
  22. bool read_cache;
  23. //! The cached Data
  24. std::string cache;
  25. //! Classifier
  26. FeaturePoolClassifier *classifier;
  27. //! feature extraction
  28. LFColorWeijer *featExtract;
  29. //! Configuration File
  30. const NICE::Config *conf;
  31. //! distance between features for training
  32. int featdist;
  33. //! half of the window size for local features
  34. int whs;
  35. //! rectangle size for classification, 1 means pixelwise
  36. int testWSize;
  37. //! name of all classes
  38. ClassNames cn;
  39. //! low level Segmentation method
  40. RegionSegmentationMethod *regionSeg;
  41. //! set of forbidden/background classes
  42. std::set<int> forbidden_classes;
  43. std::set<int> forbidden_classesTrain;
  44. std::set<int> classesInUse;
  45. //! obviously, the number of classes used for training
  46. int numberOfClasses;
  47. //! where to save the uncertainty
  48. std::string uncertdir;
  49. //! find the maximum uncertainty or not
  50. bool findMaximumUncert;
  51. //! image with most uncertain region
  52. NICE::ColorImage maskedImg;
  53. //! maximum uncertainty over all images
  54. double globalMaxUncert;
  55. //! current examples for most uncertain region
  56. Examples newTrainExamples;
  57. public:
  58. /** constructor
  59. * @param conf needs a configfile
  60. * @param md and a MultiDataset (contains images and other things)
  61. */
  62. SemSegNovelty ( const NICE::Config *conf, const MultiDataset *md );
  63. /** simple destructor */
  64. virtual ~SemSegNovelty();
  65. /** The trainingstep
  66. * @param md and a MultiDataset (contains images and other things)
  67. */
  68. void train ( const MultiDataset *md );
  69. /** The main procedure. Input: Image, Output: Segmented Image with pixelwise labeles and the probabilities
  70. * @param ce image data
  71. * @param segresult result of the semantic segmentation with a label for each pixel
  72. * @param probabilities multi-channel image with one channel for each class and corresponding probabilities for each pixel
  73. */
  74. void semanticseg ( CachedExample *ce,
  75. NICE::Image & segresult,
  76. NICE::MultiChannelImageT<double> & probabilities );
  77. /**
  78. * @brief visualize a specific region in the original image
  79. *
  80. * @param img input image
  81. * @param regions map of the regions
  82. * @param region visualize this region
  83. * @param outimage result
  84. * @return void
  85. **/
  86. void visualizeRegion(const NICE::ColorImage &img, const NICE::Matrix &regions, int region, NICE::ColorImage &outimage);
  87. };
  88. } //namespace
  89. #endif