RegionSegmentationMethod.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /**
  2. * @file RegionSegmentationMethod.h
  3. * @brief abstract interface for region segmantation
  4. * @author Björn Fröhlich, Alexander Freytag
  5. * @date 05/05/2009
  6. */
  7. #ifndef REGIONSEGMENTATIONMETHOD
  8. #define REGIONSEGMENTATIONMETHOD
  9. #undef DEBUGRS
  10. #include "RegionGraph.h"
  11. // STL includes
  12. #include <vector>
  13. // NICE-core includes
  14. #include "core/basics/Config.h"
  15. #include "core/basics/Persistent.h"
  16. #include "core/image/MultiChannelImage3DT.h"
  17. namespace OBJREC {
  18. class RegionSegmentationMethod : public NICE::Persistent
  19. {
  20. protected:
  21. /////////////////////////
  22. /////////////////////////
  23. // PROTECTED VARIABLES //
  24. /////////////////////////
  25. /////////////////////////
  26. // const NICE::Config *conf;
  27. public:
  28. ///////////////////// ///////////////////// /////////////////////
  29. // CONSTRUCTORS / DESTRUCTORS
  30. ///////////////////// ///////////////////// /////////////////////
  31. /** simple constructor */
  32. RegionSegmentationMethod();
  33. /** simple constructor */
  34. RegionSegmentationMethod( const NICE::Config *c );
  35. /** simple destructor */
  36. virtual ~RegionSegmentationMethod();
  37. /**
  38. * @brief Setup internal variables and objects used
  39. * @author Alexander Freytag
  40. * @param conf Config file to specify variable settings
  41. * @param s_confSection
  42. * @date 07-02-2014 ( dd-mm-yyyy )
  43. */
  44. virtual void initFromConfig ( const NICE::Config * _conf, const std::string & _confSection = "RegionSegmentation" );
  45. ///////////////////// ///////////////////// /////////////////////
  46. // SEGMENTATION STUFF
  47. ///////////////////// ///////////////////// //////////////////
  48. /**
  49. * returns the regions of a given image
  50. * @param img input image
  51. * @param mask output regions, each region has it own number
  52. * @return count of region
  53. */
  54. virtual int segRegions ( const NICE::Image & img, NICE::Matrix & mask ) const = 0;
  55. /**
  56. * returns the regions of a given image
  57. * @param img input color image
  58. * @param mask output regions, each region has it own number
  59. * @return count of region
  60. */
  61. virtual int segRegions ( const NICE::ColorImage & cimg, NICE::Matrix & mask) const;
  62. /**
  63. * returns the regions of a given 3d image
  64. * @param img input 3d image data
  65. * @param mask output regions for each image slice, each region has it own number
  66. * @param isGray grayscale image or not
  67. * @return amount of regions
  68. */
  69. virtual int segRegions (const NICE::MultiChannelImage3DT<double> & img, NICE::MultiChannelImageT<int> & mask, const int isGray) const;
  70. /**
  71. * transform a segmented color image in a grayimage, where each region has its own label
  72. * @param img input image
  73. * @param mask output mask
  74. * @return count of regions
  75. */
  76. int transformSegmentedImg( const NICE::ColorImage & img, NICE::Matrix & mask) const;
  77. /**
  78. * get the Graph representation of an segmentationa
  79. * @param cimg input color image
  80. * @param mask result mask of the regions
  81. * @param rg graph representation
  82. */
  83. void getGraphRepresentation(const NICE::ColorImage & cimg, NICE::Matrix & mask, RegionGraph & rg);
  84. /**
  85. * @brief mark contours with given segmentation
  86. *
  87. * @param cimg input image
  88. * @param mask result segmentation
  89. * @param color RGB values of marking color
  90. * @param marked resultimage
  91. * @return void
  92. **/
  93. void markContours ( const NICE::ColorImage & cimg, NICE::Matrix & mask, std::vector<int> &color, NICE::ColorImage &marked );
  94. /**
  95. * visualize the graph representation
  96. * @param cimg input color image
  97. * @param mask result mask of the regions
  98. */
  99. void visualizeGraphRepresentation(const NICE::ColorImage & cimg, NICE::Matrix & mask);
  100. ///////////////////// INTERFACE PERSISTENT /////////////////////
  101. // interface specific methods for store and restore
  102. ///////////////////// INTERFACE PERSISTENT /////////////////////
  103. /**
  104. * @brief Load object from external file (stream)
  105. * @author Alexander Freytag
  106. * @date 07-02-2014 ( dd-mm-yyyy )
  107. */
  108. void restore ( std::istream & is, int format = 0 ) = 0;
  109. /**
  110. * @brief Save object to external file (stream)
  111. * @author Alexander Freytag
  112. * @date 07-02-2014 ( dd-mm-yyyy )
  113. */
  114. void store ( std::ostream & os, int format = 0 ) const = 0;
  115. /**
  116. * @brief Clear object
  117. * @author Alexander Freytag
  118. * @date 07-02-2014 ( dd-mm-yyyy )
  119. */
  120. void clear () = 0;
  121. };
  122. } // namespace
  123. #endif