Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Celeste.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2008 by Tim Nugent
3  * timnugent@gmail.com
4  *
5  * This file is part of hugin.
6  *
7  * Hugin is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * Hugin is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Hugin If not, see <http://www.gnu.org/licenses/>.
19  *
20  ***************************************************************************/
21 
22 #ifndef __CELESTE__
23 #define __CELESTE__
24 
25 #include <hugin_shared.h>
26 #include "svm.h"
27 #include <string>
28 #include <vector>
29 #include <vigra/stdimage.hxx>
30 #include <vigra/transformimage.hxx>
31 #include <vigra/inspectimage.hxx>
32 #include <vigra/functorexpression.hxx>
33 #include <vigra_ext/utils.h>
34 #include <panodata/Panorama.h>
35 
36 namespace celeste
37 {
38 
44 CELESTEIMPEX bool loadSVMmodel(struct svm_model*& model, std::string& model_file);
48 CELESTEIMPEX void destroySVMmodel(struct svm_model*& model);
49 
59 CELESTEIMPEX vigra::BImage* getCelesteMask(struct svm_model* model, vigra::UInt16RGBImage& input, int radius, float threshold, int resize_dimension,bool adaptThreshold=false,bool verbose=true);
60 
61 CELESTEIMPEX HuginBase::UIntSet getCelesteControlPoints(struct svm_model* model, vigra::UInt16RGBImage& input, HuginBase::CPointVector cps, int radius, float threshold, int resize_dimension,bool verbose=true);
62 
69 template <class SrcIMG>
70 void convertToUInt16(SrcIMG & src, const std::string & origType, vigra::UInt16RGBImage & dest)
71 {
72  dest.resize(src.size());
73  long newMax=vigra_ext::getMaxValForPixelType("UINT16");
74  // float needs to be from min ... max.
75  if (origType == "FLOAT" || origType == "DOUBLE")
76  {
80  vigra::RGBToGrayAccessor<vigra::RGBValue<float> > ga;
81  vigra::FindMinMax<float> minmax; // init functor
82  vigra::inspectImage(srcImageRange(src, ga),
83  minmax);
84  double minVal = minmax.min;
85  double maxVal = minmax.max;
86  vigra_ext::applyMapping(srcImageRange(src), destImage(dest), minVal, maxVal, 0);
87  }
88  else
89  {
91  vigra::functor::Arg1()*vigra::functor::Param( newMax/ vigra_ext::getMaxValForPixelType(origType)));
92  };
93 }
94 
95 
96 }
97 #endif
98 
void destroySVMmodel(struct svm_model *&model)
frees the resource of model
Definition: Celeste.cpp:60
double getMaxValForPixelType(const std::string &v)
Definition: utils.h:89
#define CELESTEIMPEX
Definition: hugin_shared.h:43
void transformImage(vigra::triple< SrcImageIterator, SrcImageIterator, SrcAccessor > src, vigra::triple< DestImageIterator, DestImageIterator, DestAccessor > dest, std::pair< AlphaImageIterator, AlphaAccessor > alpha, vigra::Diff2D destUL, TRANSFORM &transform, PixelTransform &pixelTransform, bool warparound, Interpolator interpol, AppBase::ProgressDisplay *progress, bool singleThreaded=false)
Transform an image into the panorama.
vigra::BImage * getCelesteMask(struct svm_model *model, vigra::UInt16RGBImage &input, int radius, float threshold, int resize_dimension, bool adaptThreshold, bool verbose)
calculates the mask using SVM
Definition: Celeste.cpp:313
void convertToUInt16(SrcIMG &src, const std::string &origType, vigra::UInt16RGBImage &dest)
converts the given image to UInt16RGBImage only this image is correctly processed by celeste ...
Definition: Celeste.h:70
void applyMapping(vigra::triple< SrcIterator, SrcIterator, SrcAccessor > img, vigra::pair< DestIterator, DestAccessor > dest, T min, T max, int mapping)
Definition: utils.h:685
functions to manage ROI&#39;s
std::set< unsigned int > UIntSet
Definition: PanoramaData.h:51
bool loadSVMmodel(struct svm_model *&model, std::string &model_file)
loads the SVM model from file
Definition: Celeste.cpp:45
vigra::pair< typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::ImageAccessor > destImage(ROIImage< Image, Alpha > &img)
Definition: ROIImage.h:324
vigra::triple< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImageRange(const ROIImage< Image, Mask > &img)
helper function for ROIImages
Definition: ROIImage.h:287
std::vector< CPoint > CPointVector
Definition: ControlPoint.h:102
std::vector< deghosting::BImagePtr > threshold(const std::vector< deghosting::FImagePtr > &inputImages, const double threshold, const uint16_t flags)
Threshold function used for creating alpha masks for images.
Definition: threshold.h:41
HuginBase::UIntSet getCelesteControlPoints(struct svm_model *model, vigra::UInt16RGBImage &input, HuginBase::CPointVector cps, int radius, float threshold, int resize_dimension, bool verbose)
Definition: Celeste.cpp:363