/** * @file SemSegTools.h * @brief tools for semantic segmentation * @author Erik Rodner * @date 03/19/2009 */ #ifndef SEMSEGTOOLSINCLUDE #define SEMSEGTOOLSINCLUDE #include "core/basics/Config.h" #include "core/basics/ResourceStatistics.h" #include "vislearning/cbaselib/MultiDataset.h" #include "vislearning/cbaselib/Example.h" #include "vislearning/cbaselib/CachedExample.h" namespace OBJREC { /** tools for semantic segmentation */ class SemSegTools { protected: public: /** * @brief produce an image with segmentation result as overlay * @param orig original input image * @param segment segmentation result * @param result overlay image */ static void segmentToOverlay ( const NICE::Image * orig, const NICE::ColorImage & segment, NICE::ColorImage & result ); /** * @brief update confusion matrix with results of current image * @param img segmentation result * @param gt ground truth data * @param M confusion matrix * @param forbidden_classes set of classes, that should be ignored * @param classMapping mapping for a subset of classes */ static void updateConfusionMatrix ( const NICE::ImageT & img, const NICE::ImageT & gt, NICE::Matrix & M, const std::set & forbiddenClasses, std::map & classMapping ); /** * @brief compute typical classification statistics using confusion matrix * @param confMat confusion matrix * @param classNames class names object * @param forbidden_classes set of classes, that should be ignored * @param classMappingInv mapping for a subset of classes */ static void computeClassificationStatistics ( NICE::Matrix & confMat, const OBJREC::ClassNames & classNames, const std::set & forbiddenClasses, std::map & classMappingInv ); /** * @brief compute some resource statistics * @param rs resource statistics object */ static void computeResourceStatistics ( NICE::ResourceStatistics & rs ); /** * @brief save results to image file * @param conf Config file * @param section section in config file * @param orig input image * @param gtruth ground truth data * @param segment segmentation result */ static void saveResultsToImageFile ( const NICE::Config * conf, const std::string & section, const NICE::ColorImage & orig, const NICE::ColorImage & gtruth, const NICE::ColorImage & segment, const std::string & file, std::string & outStr ); /** * @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 */ static void getDepthVector ( const LabeledSet *Files, std::vector & depthVec, const bool run3dseg ); /** collect pixel-wise training examples from a set of images @param conf includes settings about grid size etc. @param section section of the config @param train set of training images with localization information @param cn classNames object @param examples resulting pixel-wise examples @param imgexamples image based caching structure referenced by pixel-wise examples @param run3Dseg whether to run in 3D segmentation mode or not */ static void collectTrainingExamples ( const NICE::Config * conf, const std::string & section, const LabeledSet & train, const ClassNames & cn, Examples & examples, std::vector & imgexamples, const bool run3Dseg = false ); }; } // namespace #endif