|
@@ -1,4 +1,4 @@
|
|
-/**
|
|
|
|
|
|
+/**
|
|
* @file SemSegCsurka.h
|
|
* @file SemSegCsurka.h
|
|
* @brief semantic segmentation using the method from Csurka08
|
|
* @brief semantic segmentation using the method from Csurka08
|
|
* @author Björn Fröhlich
|
|
* @author Björn Fröhlich
|
|
@@ -29,7 +29,7 @@
|
|
#include "objrec/segmentation/RSGraphBased.h"
|
|
#include "objrec/segmentation/RSGraphBased.h"
|
|
#include "objrec/segmentation/RSCache.h"
|
|
#include "objrec/segmentation/RSCache.h"
|
|
|
|
|
|
-#include "SemSegTools.h"
|
|
|
|
|
|
+#include "SemSegTools.h"
|
|
|
|
|
|
#include "vislearning/math/cluster/GMM.h"
|
|
#include "vislearning/math/cluster/GMM.h"
|
|
#include "vislearning/math/cluster/KMeansOnline.h"
|
|
#include "vislearning/math/cluster/KMeansOnline.h"
|
|
@@ -54,191 +54,196 @@ class SemSegCsurka : public SemanticSegmentation
|
|
{
|
|
{
|
|
|
|
|
|
protected:
|
|
protected:
|
|
-
|
|
|
|
- //! for normalization
|
|
|
|
- std::vector<double> vecmin, vecmax;
|
|
|
|
-
|
|
|
|
- //! boolean whether to save the cache or not
|
|
|
|
- bool save_cache;
|
|
|
|
-
|
|
|
|
- //! boolean whether to read the cache or not, if read_cache is false, everything will be trained
|
|
|
|
- bool read_cache;
|
|
|
|
-
|
|
|
|
- //! The cached Data
|
|
|
|
- std::string cache;
|
|
|
|
-
|
|
|
|
- //! The PCA
|
|
|
|
- PCA pca;
|
|
|
|
-
|
|
|
|
- //! using normalization
|
|
|
|
- bool norm;
|
|
|
|
-
|
|
|
|
- //! feature Dimension after PCA
|
|
|
|
- int dim;
|
|
|
|
-
|
|
|
|
- //! Classifier
|
|
|
|
- FeaturePoolClassifier *classifier;
|
|
|
|
- VecClassifier *vclassifier;
|
|
|
|
-
|
|
|
|
- //! Configuration File
|
|
|
|
- const Config *conf;
|
|
|
|
-
|
|
|
|
- ClassNames cn;
|
|
|
|
-
|
|
|
|
- //! whether to use the colorfeats or not
|
|
|
|
- bool usecolorfeats;
|
|
|
|
-
|
|
|
|
- //! low level Segmentation method
|
|
|
|
- RegionSegmentationMethod *seg;
|
|
|
|
-
|
|
|
|
- //! weight for the gaussimage
|
|
|
|
- double sigmaweight;
|
|
|
|
-
|
|
|
|
- //! Gaussian Mixture
|
|
|
|
- GMM *g;
|
|
|
|
-
|
|
|
|
- //! KMeans
|
|
|
|
- KMeansOnline *k;
|
|
|
|
-
|
|
|
|
- //! use pca or not
|
|
|
|
- bool usepca;
|
|
|
|
-
|
|
|
|
- //! forced recalculation of the pca
|
|
|
|
- bool calcpca;
|
|
|
|
-
|
|
|
|
- //! use highlevel transformation with gmm or not
|
|
|
|
- bool usegmm;
|
|
|
|
-
|
|
|
|
- //! use highlevel transformation with kmeans or not
|
|
|
|
- bool usekmeans;
|
|
|
|
-
|
|
|
|
- int bestclasses;
|
|
|
|
-
|
|
|
|
- //! how much clusters of the kmeans to use
|
|
|
|
- int kmeansfeat;
|
|
|
|
-
|
|
|
|
- //! use hard assignment or not
|
|
|
|
- bool kmeanshard;
|
|
|
|
-
|
|
|
|
- //! use fisher kernel for bag if visual words
|
|
|
|
- bool usefisher;
|
|
|
|
-
|
|
|
|
- //! forced recalculation of the gmm
|
|
|
|
- bool dogmm;
|
|
|
|
-
|
|
|
|
- //! number of gaussians
|
|
|
|
- int gaussians;
|
|
|
|
-
|
|
|
|
- //! whether to use the relative location features or not
|
|
|
|
- bool userellocprior;
|
|
|
|
-
|
|
|
|
- //! which classifier to use
|
|
|
|
- std::string cname;
|
|
|
|
-
|
|
|
|
- //! use regions segmentation or not
|
|
|
|
- bool useregions;
|
|
|
|
-
|
|
|
|
- //! how many features should be used for training the classifier (relative value between 0 and 1
|
|
|
|
- double anteil;
|
|
|
|
-
|
|
|
|
- //! save steps for faster computing postprocesses
|
|
|
|
- bool savesteps;
|
|
|
|
-
|
|
|
|
- //! the relative location features
|
|
|
|
- RelativeLocationPrior *relloc;
|
|
|
|
-
|
|
|
|
- //! Shape pp
|
|
|
|
- PPSuperregion *srg;
|
|
|
|
-
|
|
|
|
- //! Graph Cut pp
|
|
|
|
- PPGraphCut *gcopt;
|
|
|
|
-
|
|
|
|
- //! smooth high level features or not
|
|
|
|
- bool smoothhl;
|
|
|
|
-
|
|
|
|
- //! sigma for high level smoothing
|
|
|
|
- double smoothfactor;
|
|
|
|
-
|
|
|
|
- //! which OpponentSIFT implementation to use {NICE, VANDESANDE}
|
|
|
|
- std::string opSiftImpl;
|
|
|
|
-
|
|
|
|
- //! read features?
|
|
|
|
- bool readfeat;
|
|
|
|
-
|
|
|
|
- //! write features?
|
|
|
|
- bool writefeat;
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * converts the low level features in high level features
|
|
|
|
- * @param ex input and output features
|
|
|
|
- * @param reduce reduce the dataset (1.0 means no reduction)
|
|
|
|
- */
|
|
|
|
- void convertLowToHigh(Examples &ex, double reduce = 1.0);
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Starts the PCA
|
|
|
|
- * @param ex input features
|
|
|
|
- */
|
|
|
|
- void initializePCA(Examples &ex);
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * using PCA on al input features
|
|
|
|
- * @param ex input features
|
|
|
|
- */
|
|
|
|
- void doPCA(Examples &ex);
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * normalize the features between 0 and 1
|
|
|
|
- * @param ex input features
|
|
|
|
- */
|
|
|
|
- void normalize(Examples &ex);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * smooth the high level features
|
|
|
|
- * @param ex input features
|
|
|
|
- */
|
|
|
|
- void smoothHL(Examples ex);
|
|
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ //! for normalization
|
|
|
|
+ std::vector<double> vecmin, vecmax;
|
|
|
|
+
|
|
|
|
+ //! boolean whether to save the cache or not
|
|
|
|
+ bool save_cache;
|
|
|
|
+
|
|
|
|
+ //! boolean whether to read the cache or not, if read_cache is false, everything will be trained
|
|
|
|
+ bool read_cache;
|
|
|
|
+
|
|
|
|
+ //! The cached Data
|
|
|
|
+ std::string cache;
|
|
|
|
+
|
|
|
|
+ //! The PCA
|
|
|
|
+ PCA pca;
|
|
|
|
+
|
|
|
|
+ //! using normalization
|
|
|
|
+ bool norm;
|
|
|
|
+
|
|
|
|
+ //! feature Dimension after PCA
|
|
|
|
+ int dim;
|
|
|
|
+
|
|
|
|
+ //! Classifier
|
|
|
|
+ FeaturePoolClassifier *classifier;
|
|
|
|
+ VecClassifier *vclassifier;
|
|
|
|
+
|
|
|
|
+ //! Configuration File
|
|
|
|
+ const Config *conf;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //! name of all classes
|
|
|
|
+ ClassNames cn;
|
|
|
|
+
|
|
|
|
+ //! set of forbidden/background classes
|
|
|
|
+ set<int> forbidden_classes;
|
|
|
|
+
|
|
|
|
+ //! whether to use the colorfeats or not
|
|
|
|
+ bool usecolorfeats;
|
|
|
|
+
|
|
|
|
+ //! low level Segmentation method
|
|
|
|
+ RegionSegmentationMethod *seg;
|
|
|
|
+
|
|
|
|
+ //! weight for the gaussimage
|
|
|
|
+ double sigmaweight;
|
|
|
|
+
|
|
|
|
+ //! Gaussian Mixture
|
|
|
|
+ GMM *g;
|
|
|
|
+
|
|
|
|
+ //! KMeans
|
|
|
|
+ KMeansOnline *k;
|
|
|
|
+
|
|
|
|
+ //! use pca or not
|
|
|
|
+ bool usepca;
|
|
|
|
+
|
|
|
|
+ //! forced recalculation of the pca
|
|
|
|
+ bool calcpca;
|
|
|
|
+
|
|
|
|
+ //! use highlevel transformation with gmm or not
|
|
|
|
+ bool usegmm;
|
|
|
|
+
|
|
|
|
+ //! use highlevel transformation with kmeans or not
|
|
|
|
+ bool usekmeans;
|
|
|
|
+
|
|
|
|
+ int bestclasses;
|
|
|
|
+
|
|
|
|
+ //! how much clusters of the kmeans to use
|
|
|
|
+ int kmeansfeat;
|
|
|
|
+
|
|
|
|
+ //! use hard assignment or not
|
|
|
|
+ bool kmeanshard;
|
|
|
|
+
|
|
|
|
+ //! use fisher kernel for bag if visual words
|
|
|
|
+ bool usefisher;
|
|
|
|
+
|
|
|
|
+ //! forced recalculation of the gmm
|
|
|
|
+ bool dogmm;
|
|
|
|
+
|
|
|
|
+ //! number of gaussians
|
|
|
|
+ int gaussians;
|
|
|
|
+
|
|
|
|
+ //! whether to use the relative location features or not
|
|
|
|
+ bool userellocprior;
|
|
|
|
+
|
|
|
|
+ //! which classifier to use
|
|
|
|
+ std::string cname;
|
|
|
|
+
|
|
|
|
+ //! use regions segmentation or not
|
|
|
|
+ bool useregions;
|
|
|
|
+
|
|
|
|
+ //! how many features should be used for training the classifier (relative value between 0 and 1
|
|
|
|
+ double anteil;
|
|
|
|
+
|
|
|
|
+ //! save steps for faster computing postprocesses
|
|
|
|
+ bool savesteps;
|
|
|
|
+
|
|
|
|
+ //! the relative location features
|
|
|
|
+ RelativeLocationPrior *relloc;
|
|
|
|
+
|
|
|
|
+ //! Shape pp
|
|
|
|
+ PPSuperregion *srg;
|
|
|
|
+
|
|
|
|
+ //! Graph Cut pp
|
|
|
|
+ PPGraphCut *gcopt;
|
|
|
|
+
|
|
|
|
+ //! smooth high level features or not
|
|
|
|
+ bool smoothhl;
|
|
|
|
+
|
|
|
|
+ //! sigma for high level smoothing
|
|
|
|
+ double smoothfactor;
|
|
|
|
+
|
|
|
|
+ //! which OpponentSIFT implementation to use {NICE, VANDESANDE}
|
|
|
|
+ std::string opSiftImpl;
|
|
|
|
+
|
|
|
|
+ //! read features?
|
|
|
|
+ bool readfeat;
|
|
|
|
+
|
|
|
|
+ //! write features?
|
|
|
|
+ bool writefeat;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * converts the low level features in high level features
|
|
|
|
+ * @param ex input and output features
|
|
|
|
+ * @param reduce reduce the dataset (1.0 means no reduction)
|
|
|
|
+ */
|
|
|
|
+ void convertLowToHigh ( Examples &ex, double reduce = 1.0 );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Starts the PCA
|
|
|
|
+ * @param ex input features
|
|
|
|
+ */
|
|
|
|
+ void initializePCA ( Examples &ex );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * using PCA on al input features
|
|
|
|
+ * @param ex input features
|
|
|
|
+ */
|
|
|
|
+ void doPCA ( Examples &ex );
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * normalize the features between 0 and 1
|
|
|
|
+ * @param ex input features
|
|
|
|
+ */
|
|
|
|
+ void normalize ( Examples &ex );
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * smooth the high level features
|
|
|
|
+ * @param ex input features
|
|
|
|
+ */
|
|
|
|
+ void smoothHL ( Examples ex );
|
|
|
|
+
|
|
public:
|
|
public:
|
|
-
|
|
|
|
- /** constructor
|
|
|
|
- * @param conf needs a configfile
|
|
|
|
- * @param md and a MultiDataset (contains images and other things)
|
|
|
|
- */
|
|
|
|
- SemSegCsurka( const Config *conf, const MultiDataset *md );
|
|
|
|
-
|
|
|
|
- /** simple destructor */
|
|
|
|
- virtual ~SemSegCsurka();
|
|
|
|
-
|
|
|
|
- /** The trainingstep
|
|
|
|
- * @param md and a MultiDataset (contains images and other things)
|
|
|
|
- */
|
|
|
|
- void train ( const MultiDataset *md );
|
|
|
|
-
|
|
|
|
- /** The trainingstep for the postprocess
|
|
|
|
- * @param md and a MultiDataset (contains images and other things)
|
|
|
|
- */
|
|
|
|
- void trainpostprocess( const MultiDataset *md );
|
|
|
|
-
|
|
|
|
- /** The main procedure. Input: Image, Output: Segmented Image with pixelwise labeles and the probabilities
|
|
|
|
- * @param ce 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
|
|
|
|
- */
|
|
|
|
- void semanticseg ( CachedExample *ce,
|
|
|
|
|
|
+
|
|
|
|
+ /** constructor
|
|
|
|
+ * @param conf needs a configfile
|
|
|
|
+ * @param md and a MultiDataset (contains images and other things)
|
|
|
|
+ */
|
|
|
|
+ SemSegCsurka ( const Config *conf, const MultiDataset *md );
|
|
|
|
+
|
|
|
|
+ /** simple destructor */
|
|
|
|
+ virtual ~SemSegCsurka();
|
|
|
|
+
|
|
|
|
+ /** The trainingstep
|
|
|
|
+ * @param md and a MultiDataset (contains images and other things)
|
|
|
|
+ */
|
|
|
|
+ void train ( const MultiDataset *md );
|
|
|
|
+
|
|
|
|
+ /** The trainingstep for the postprocess
|
|
|
|
+ * @param md and a MultiDataset (contains images and other things)
|
|
|
|
+ */
|
|
|
|
+ void trainpostprocess ( const MultiDataset *md );
|
|
|
|
+
|
|
|
|
+ /** The main procedure. Input: Image, Output: Segmented Image with pixelwise labeles and the probabilities
|
|
|
|
+ * @param ce 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
|
|
|
|
+ */
|
|
|
|
+ void semanticseg ( CachedExample *ce,
|
|
NICE::Image & segresult,
|
|
NICE::Image & segresult,
|
|
NICE::MultiChannelImageT<double> & probabilities );
|
|
NICE::MultiChannelImageT<double> & probabilities );
|
|
|
|
|
|
/** this procedure is equal semanticseg, if there is no post process
|
|
/** this procedure is equal semanticseg, if there is no post process
|
|
- * @param ce 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 Regionen the output regions
|
|
|
|
- * @param mask the positions of the regions
|
|
|
|
- */
|
|
|
|
- void classifyregions ( CachedExample *ce, NICE::Image & segresult, NICE::MultiChannelImageT<double> & probabilities, Examples &Regionen, NICE::Matrix &mask );
|
|
|
|
- void getFeats(NICE::Image arg1, VVector arg2, VVector arg3);
|
|
|
|
|
|
+ * @param ce 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 Regionen the output regions
|
|
|
|
+ * @param mask the positions of the regions
|
|
|
|
+ */
|
|
|
|
+ void classifyregions ( CachedExample *ce, NICE::Image & segresult, NICE::MultiChannelImageT<double> & probabilities, Examples &Regionen, NICE::Matrix &mask );
|
|
|
|
+ void getFeats ( NICE::Image arg1, VVector arg2, VVector arg3 );
|
|
};
|
|
};
|
|
|
|
|
|
} //namespace
|
|
} //namespace
|