RSMeanShift.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /**
  2. * @file RSMeanShift.h
  3. * @brief implementation of the MeanShift algorithm (uses EDISON)
  4. * @author Björn Fröhlich, Alexander Freytag
  5. * @date 05/05/2009
  6. */
  7. #ifndef RSMEANSHIFT
  8. #define RSMEANSHIFT
  9. #include "core/basics/Config.h"
  10. #include "RegionSegmentationMethod.h"
  11. #include <segmentation/edisonSegm/tdef.h>
  12. #include <segmentation/edisonSegm/msImageProcessor.h>
  13. namespace OBJREC {
  14. class RSMeanShift: public RegionSegmentationMethod
  15. {
  16. protected:
  17. /////////////////////////
  18. /////////////////////////
  19. // PROTECTED VARIABLES //
  20. /////////////////////////
  21. /////////////////////////
  22. //! Specifies the minimum allowable region area (in pixels) contained in the segmented image
  23. int minimumRegionArea;
  24. //! Specifies the bandwidth of the search window in the range subspace during the computation of mean shift
  25. double rangeBandwidth;
  26. //! Specifies a spatial search window of size (2r+1)x (2r+1) during the mean shift computation, where r is the spatial bandwidth
  27. int spatialBandwidth;
  28. //! Specifies the SpeedUpLevel. See EDISON Manual for details.
  29. std::string speedUpLvlString;
  30. SpeedUpLevel speedUpLevel;
  31. //! EDISON - ImageProcessor
  32. msImageProcessor *imageProc;
  33. void setSpeedUpLevel ( const std::string & _speedUpLevelString );
  34. public:
  35. ///////////////////// ///////////////////// /////////////////////
  36. // CONSTRUCTORS / DESTRUCTORS
  37. ///////////////////// ///////////////////// /////////////////////
  38. /** simple constructor */
  39. RSMeanShift();
  40. /**
  41. * @brief standard constructor, calls this->initFromConfig
  42. * @param conf config file
  43. * @author Bjoern Froehlich, Alexander Freytag
  44. */
  45. RSMeanShift(const NICE::Config * _conf );
  46. /** simple destructor */
  47. virtual ~RSMeanShift();
  48. /**
  49. * @brief Setup internal variables and objects used
  50. * @author Alexander Freytag
  51. * @param conf Config file to specify variable settings
  52. * @param s_confSection
  53. * @date 07-02-2014 ( dd-mm-yyyy )
  54. */
  55. virtual void initFromConfig ( const NICE::Config * _conf, const std::string & _confSection = "RSMeanShift" );
  56. ///////////////////// ///////////////////// /////////////////////
  57. // SEGMENTATION STUFF
  58. ///////////////////// ///////////////////// //////////////////
  59. /**
  60. * returns the regions of a given image
  61. * @param img input image
  62. * @param mask output regions, each region has it own number
  63. * @return count of region
  64. */
  65. int segRegions ( const NICE::Image & img, NICE::Matrix & mask ) const;
  66. /**
  67. * returns the regions of a given image
  68. * @param img input image
  69. * @param mask output regions, each region has it own number
  70. * @return count of region
  71. */
  72. int segRegions ( const NICE::ColorImage & img, NICE::Matrix & mask ) const;
  73. ///////////////////// INTERFACE PERSISTENT /////////////////////
  74. // interface specific methods for store and restore
  75. ///////////////////// INTERFACE PERSISTENT /////////////////////
  76. /**
  77. * @brief Load object from external file (stream)
  78. * @author Alexander Freytag
  79. * @date 07-02-2014 ( dd-mm-yyyy )
  80. */
  81. void restore ( std::istream & is, int format = 0 );
  82. /**
  83. * @brief Save object to external file (stream)
  84. * @author Alexander Freytag
  85. * @date 07-02-2014 ( dd-mm-yyyy )
  86. */
  87. void store ( std::ostream & os, int format = 0 ) const;
  88. /**
  89. * @brief Clear object
  90. * @author Alexander Freytag
  91. * @date 07-02-2014 ( dd-mm-yyyy )
  92. */
  93. void clear ();
  94. };
  95. } //namespace
  96. #endif