/** * @file SemSegNovelty.h * @brief semantic segmentation using the method from Csurka08 * @author Björn Fröhlich * @date 04/24/2009 */ #ifndef SemSegNoveltyINCLUDE #define SemSegNoveltyINCLUDE #include "SemanticSegmentation.h" #include "SemSegTools.h" #include "vislearning/classifier/classifierbase/FeaturePoolClassifier.h" #include "vislearning/features/localfeatures/LFColorWeijer.h" #include "segmentation/RegionSegmentationMethod.h" /** @brief pixelwise labeling systems */ namespace OBJREC { class SemSegNovelty : public SemanticSegmentation { protected: //! 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; //! Classifier FeaturePoolClassifier *classifier; //! feature extraction LFColorWeijer *featExtract; //! Configuration File const NICE::Config *conf; //! distance between features for training int trainWsize; //! half of the window size for local features int whs; //! rectangle size for classification, 1 means pixelwise int testWSize; //! name of all classes ClassNames cn; //! low level Segmentation method RegionSegmentationMethod *regionSeg; //! set of forbidden/background classes std::set forbidden_classes; std::set forbidden_classesTrain; std::set classesInUse; //! obviously, the number of classes used for training int numberOfClasses; //! where to save the uncertainty std::string uncertdir; //! find the maximum uncertainty or not bool findMaximumUncert; //! image with most uncertain region NICE::ColorImage maskedImg; //! maximum uncertainty over all images double globalMaxUncert; //! current examples for most uncertain region Examples newTrainExamples; enum NoveltyMethod{ GPVARIANCE, // novel = large variance GPUNCERTAINTY, //novel = small uncertainty (mean / var) GPMINMEAN, //novel = small mean GPMEANRATIO, //novel = small difference between mean of most plausible class and mean of snd // most plausible class (not useful in binary settings) GPWEIGHTALL, // novel = large weight in alpha vector after updating the model (can be predicted exactly) GPWEIGHTRATIO // novel = small difference between weights for alpha vectors with assumptions of GT label to be the most // plausible against the second most plausible class }; //! specify how "novelty" shall be computed, e.g., using GP-variance, GP-uncertainty, or predicted weight entries NoveltyMethod noveltyMethod; inline void computeClassificationResults( const NICE::MultiChannelImageT & feats, NICE::Image & segresult, NICE::MultiChannelImageT & probabilities, const int & xsize, const int & ysize, const int & featdim ); void computeNoveltyByVariance( NICE::FloatImage & noveltyImage, const NICE::MultiChannelImageT & feats, NICE::Image & segresult, NICE::MultiChannelImageT & probabilities, const int & xsize, const int & ysize, const int & featdim ); void computeNoveltyByGPUncertainty ( NICE::FloatImage & noveltyImage, const NICE::MultiChannelImageT & feats, NICE::Image & segresult, NICE::MultiChannelImageT & probabilities, const int & xsize, const int & ysize, const int & featdim ); public: /** constructor * @param conf needs a configfile * @param md and a MultiDataset (contains images and other things) */ SemSegNovelty ( const NICE::Config *conf, const MultiDataset *md ); /** simple destructor */ virtual ~SemSegNovelty(); /** The trainingstep * @param md and a MultiDataset (contains images and other things) */ void train ( 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::MultiChannelImageT & probabilities ); /** * @brief visualize a specific region in the original image * * @param img input image * @param regions map of the regions * @param region visualize this region * @param outimage result * @return void **/ void visualizeRegion(const NICE::ColorImage &img, const NICE::Matrix ®ions, int region, NICE::ColorImage &outimage); }; } //namespace #endif