|
@@ -1,13 +1,16 @@
|
|
|
/**
|
|
|
* @file SemanticSegmentation.h
|
|
|
* @brief abstract interface for semantic segmentation algorithms
|
|
|
-* @author Erik Rodner
|
|
|
-* @date 03/19/2009
|
|
|
+* @author Erik Rodner, Alexander Freytag, Sven Sickert
|
|
|
+* @date 03/19/2009, latest update: 14-05-2014 (dd-mm-yyyy)
|
|
|
|
|
|
*/
|
|
|
#ifndef SEMANTICSEGMENTATIONINCLUDE
|
|
|
#define SEMANTICSEGMENTATIONINCLUDE
|
|
|
|
|
|
+// nice-core includes
|
|
|
+#include <core/basics/Persistent.h>
|
|
|
+
|
|
|
#include <vector>
|
|
|
#include "core/image/MultiChannelImage3DT.h"
|
|
|
#include "vislearning/cbaselib/MultiDataset.h"
|
|
@@ -20,85 +23,148 @@ namespace OBJREC
|
|
|
{
|
|
|
|
|
|
/** abstract interface for semantic segmentation algorithms */
|
|
|
-class SemanticSegmentation
|
|
|
+class SemanticSegmentation : public NICE::Persistent
|
|
|
{
|
|
|
|
|
|
-protected:
|
|
|
- /** accessible class names and information about
|
|
|
- number of classes etc. */
|
|
|
- const ClassNames *classNames;
|
|
|
-
|
|
|
- /** enum type for imagetype */
|
|
|
- enum
|
|
|
- {
|
|
|
- IMAGETYPE_RGB = 0,
|
|
|
- IMAGETYPE_GRAY
|
|
|
- };
|
|
|
-
|
|
|
- /** whether to load images with color information */
|
|
|
- int imagetype;
|
|
|
-
|
|
|
-public:
|
|
|
-
|
|
|
- /** simple constructor */
|
|
|
- SemanticSegmentation ();
|
|
|
-
|
|
|
- /** constructor
|
|
|
- @param conf global settings
|
|
|
- @param classNames this ClassNames object while be stored as a attribute
|
|
|
- */
|
|
|
- SemanticSegmentation ( const NICE::Config *conf,
|
|
|
- const ClassNames *classNames );
|
|
|
-
|
|
|
- /** simple destructor */
|
|
|
- virtual ~SemanticSegmentation();
|
|
|
-
|
|
|
- /** classification function (has to be overloaded by all subclasses)
|
|
|
- * @param imgData image data
|
|
|
- * @param segresult result of the semantic segmentation with a label for each pixel
|
|
|
- * @param probabilities multi-channel image with one channel for each class and
|
|
|
- * corresponding probabilities for each pixel
|
|
|
- * @param filelist filename list of images that represent slices of a stack
|
|
|
- */
|
|
|
- virtual void classify ( NICE::MultiChannelImage3DT<double> & imgData,
|
|
|
- NICE::MultiChannelImageT<double> & segresult,
|
|
|
- NICE::MultiChannelImage3DT<double> & probabilities,
|
|
|
- const std::vector<std::string> & filelist ) = 0;
|
|
|
-
|
|
|
- /** training function (has to be overloaded by all subclasses)
|
|
|
- * @param md the data set
|
|
|
- */
|
|
|
- virtual void train ( const MultiDataset * md ) = 0;
|
|
|
-
|
|
|
- /**
|
|
|
- * collect information about the depth of 3d images
|
|
|
- * @param *Files a labeled set of data
|
|
|
- * @param depthVec output of depth values
|
|
|
- * @param run3dseg whether slice counting is necessary or not
|
|
|
- */
|
|
|
- void getDepthVector ( const LabeledSet *Files, std::vector<int> & depthVec, const bool run3dseg );
|
|
|
-
|
|
|
- /**
|
|
|
- * convert different datatypes
|
|
|
- */
|
|
|
- void convertVVectorToExamples ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
|
|
|
- void convertExamplesToVVector ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
|
|
|
- void convertExamplesToLSet ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
|
|
|
- void convertLSetToExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
|
|
|
- void convertLSetToSparseExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
|
|
|
-
|
|
|
- /**
|
|
|
- *load image slices into a single MCI3DT
|
|
|
- */
|
|
|
- void make3DImage ( const std::vector<std::string> & filelist,
|
|
|
- NICE::MultiChannelImage3DT<double> & imgData );
|
|
|
-
|
|
|
- /**
|
|
|
- * @brief show a probability map for a given class
|
|
|
- * @param prob class probabilites for each pixel
|
|
|
- * @param cl class number
|
|
|
- */
|
|
|
- void getProbabilityMap( const NICE::MultiChannelImage3DT<double> & prob );
|
|
|
+ protected:
|
|
|
+ /** accessible class names and information about
|
|
|
+ number of classes etc. */
|
|
|
+ const ClassNames *classNames;
|
|
|
+
|
|
|
+ /** enum type for imagetype */
|
|
|
+ enum IMAGETYP
|
|
|
+ {
|
|
|
+ IMAGETYPE_RGB = 0,
|
|
|
+ IMAGETYPE_GRAY
|
|
|
+ };
|
|
|
+
|
|
|
+ /** whether to load images with color information */
|
|
|
+ IMAGETYP imagetype;
|
|
|
+
|
|
|
+ int iterationCountSuffix;
|
|
|
+
|
|
|
+ public:
|
|
|
+
|
|
|
+ ///////////////////// ///////////////////// /////////////////////
|
|
|
+ // CONSTRUCTORS / DESTRUCTORS
|
|
|
+ ///////////////////// ///////////////////// /////////////////////
|
|
|
+
|
|
|
+ /** default constructor */
|
|
|
+ SemanticSegmentation ( );
|
|
|
+
|
|
|
+ /** simple constructor
|
|
|
+ @param conf global settings
|
|
|
+ @param classNames this ClassNames object while be stored as a attribute
|
|
|
+ */
|
|
|
+ SemanticSegmentation ( const NICE::Config *conf,
|
|
|
+ const ClassNames *classNames );
|
|
|
+
|
|
|
+ /** simple destructor */
|
|
|
+ virtual ~SemanticSegmentation();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @brief Setup internal variables and objects used
|
|
|
+ * @author Alexander Freytag
|
|
|
+ * @param conf Config file to specify variable settings
|
|
|
+ * @param s_confSection
|
|
|
+ */
|
|
|
+ void initFromConfig(const NICE::Config *conf, const std::string & s_confSection = "SemanticSegmentation");
|
|
|
+
|
|
|
+ ///////////////////// ///////////////////// /////////////////////
|
|
|
+ // SEGMENTATION STUFF
|
|
|
+ ///////////////////// ///////////////////// /////////////////////
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @brief Classification function (has to be overloaded by all subclasses)
|
|
|
+ * @author Sven Sickert
|
|
|
+ * @param imgData image data
|
|
|
+ * @param segresult result of the semantic segmentation with a label for each pixel
|
|
|
+ * @param probabilities multi-channel image with one channel for each class and
|
|
|
+ * corresponding probabilities for each pixel
|
|
|
+ * @param filelist filename list of images that represent slices of a stack
|
|
|
+ */
|
|
|
+ virtual void classify ( NICE::MultiChannelImage3DT<double> & imgData,
|
|
|
+ NICE::MultiChannelImageT<double> & segresult,
|
|
|
+ NICE::MultiChannelImage3DT<double> & probabilities,
|
|
|
+ const std::vector<std::string> & filelist ) = 0;
|
|
|
+
|
|
|
+ /** training function (has to be overloaded by all subclasses)
|
|
|
+ * @param md the data set
|
|
|
+ */
|
|
|
+ virtual void train ( const MultiDataset * md ) = 0;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @brief Load image slices into a MultiChannelImage3DT
|
|
|
+ * @author Sven Sickert
|
|
|
+ * @param filelist filename list of images that represent slices of a stack
|
|
|
+ * @param imgData output
|
|
|
+ */
|
|
|
+ void make3DImage ( const std::vector<std::string> & filelist,
|
|
|
+ NICE::MultiChannelImage3DT<double> & imgData );
|
|
|
+
|
|
|
+
|
|
|
+ ///////////////////// ///////////////////// /////////////////////
|
|
|
+ // DATA CONVERSION
|
|
|
+ ///////////////////// ///////////////////// /////////////////////
|
|
|
+
|
|
|
+ /**
|
|
|
+ * convert different datatypes
|
|
|
+ */
|
|
|
+ void convertVVectorToExamples ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
|
|
|
+ void convertExamplesToVVector ( NICE::VVector &feats,OBJREC::Examples &examples, std::vector<int> &label );
|
|
|
+ void convertExamplesToLSet ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
|
|
|
+ void convertLSetToExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
|
|
|
+ void convertLSetToSparseExamples ( OBJREC::Examples &examples, OBJREC::LabeledSetVector &lvec );
|
|
|
+
|
|
|
+ ///////////////////// ///////////////////// /////////////////////
|
|
|
+ // GET / SET
|
|
|
+ ///////////////////// ///////////////////// /////////////////////
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @brief Collect information about the depth of 3d images
|
|
|
+ * @author Sven Sickert
|
|
|
+ * @param Files a labeled set of data
|
|
|
+ * @param depthVec output of depth values
|
|
|
+ * @param run3dseg whether slice counting is necessary or not
|
|
|
+ */
|
|
|
+ void getDepthVector ( const LabeledSet *Files, std::vector<int> & depthVec, const bool run3dseg );
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @brief Save probability maps of all classes to iamge files
|
|
|
+ * @author Sven Sickert
|
|
|
+ * @param prob class probability maps
|
|
|
+ */
|
|
|
+ void getProbabilityMap( const NICE::MultiChannelImage3DT<double> & prob );
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @author Alexander Freytag
|
|
|
+ * @date 06-02-2014 ( dd-mm-yyyy )
|
|
|
+ */
|
|
|
+ void setClassNames ( const OBJREC::ClassNames * _classNames ) ;
|
|
|
+
|
|
|
+ void setIterationCountSuffix( const int & _iterationCountSuffix);
|
|
|
+
|
|
|
+ ///////////////////// INTERFACE PERSISTENT /////////////////////
|
|
|
+ // interface specific methods for store and restore
|
|
|
+ ///////////////////// INTERFACE PERSISTENT /////////////////////
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @brief Load active-segmentation-object from external file (stream)
|
|
|
+ * @author Alexander Freytag
|
|
|
+ */
|
|
|
+ virtual void restore ( std::istream & is, int format = 0 );
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @brief Save active-segmentation-object to external file (stream)
|
|
|
+ * @author Alexander Freytag
|
|
|
+ */
|
|
|
+ virtual void store( std::ostream & os, int format = 0 ) const;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @brief Clear active-segmentation-object object
|
|
|
+ * @author Alexander Freytag
|
|
|
+ */
|
|
|
+ virtual void clear ();
|
|
|
|
|
|
};
|
|
|
|