123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- /**
- * @file SemSegCsurka.h
- * @brief semantic segmentation using the method from Csurka08
- * @author Björn Fröhlich
- * @date 04/24/2009
- */
- #ifndef SemSegCsurkaINCLUDE
- #define SemSegCsurkaINCLUDE
- #include "SemanticSegmentation.h"
- #include "vislearning/math/ftransform/PCA.h"
- #include "vislearning/features/localfeatures/GenericLocalFeatureSelection.h"
- #include "vislearning/features/localfeatures/LFonHSG.h"
- #include "vislearning/features/localfeatures/LFColorSande.h"
- #include "vislearning/features/localfeatures/LocalFeatureColorWeijer.h"
- #include "vislearning/features/localfeatures/LFReadCache.h"
- #include "vislearning/features/localfeatures/LFWriteCache.h"
- #include "vislearning/features/fpfeatures/VectorFeature.h"
- #include "vislearning/features/fpfeatures/SparseVectorFeature.h"
- #include "vislearning/cbaselib/CachedExample.h"
- #include "vislearning/baselib/Preprocess.h"
- #include "vislearning/baselib/Globals.h"
- #include "segmentation/RegionSegmentationMethod.h"
- #include "segmentation/RSMeanShift.h"
- #include "segmentation/RSGraphBased.h"
- #include "segmentation/RSCache.h"
- #include "SemSegTools.h"
- #include "vislearning/math/cluster/GMM.h"
- #include "vislearning/math/cluster/KMeansOnline.h"
- #include <vislearning/classifier/genericClassifierSelection.h>
- #include <vislearning/classifier/fpclassifier/randomforest/FPCRandomForests.h>
- #include <vislearning/classifier/fpclassifier/gphik/FPCGPHIK.h>
- #include <vislearning/classifier/fpclassifier/logisticregression/FPCSMLR.h>
- #include "semseg/semseg/postsegmentation/RelativeLocationPrior.h"
- #include "semseg/semseg/postsegmentation/PPSuperregion.h"
- #include "semseg/semseg/postsegmentation/PPGraphCut.h"
- /** @brief pixelwise labeling systems */
- namespace OBJREC {
- class SemSegCsurka : public SemanticSegmentation
- {
- 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 NICE::Config *conf;
- //! name of all classes
- ClassNames cn;
- //! set of forbidden/background classes
- std::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:
- /** constructor
- * @param conf needs a configfile
- * @param md and a MultiDataset (contains images and other things)
- */
- SemSegCsurka ( const NICE::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::ImageT<int> & segresult,
- NICE::MultiChannelImageT<double> & probabilities );
- void semanticseg ( CachedExample *ce,
- NICE::MultiChannelImageT<int> & segresult,
- NICE::MultiChannelImage3DT<double> & probabilities )
- {}
- /** 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::ImageT<int> & segresult, NICE::MultiChannelImageT<double> & probabilities, Examples &Regionen, NICE::Matrix &mask );
- void getFeats ( NICE::Image arg1, NICE::VVector arg2, NICE::VVector arg3 );
- };
- } //namespace
- #endif
|