Celeste.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2008 by Tim Nugent
00003  *   timnugent@gmail.com
00004  *
00005  *   This file is part of hugin.
00006  *
00007  *   Hugin is free software: you can redistribute it and/or modify
00008  *   it under the terms of the GNU General Public License as published by
00009  *   the Free Software Foundation, either version 2 of the License, or
00010  *   (at your option) any later version.
00011  * 
00012  *   Hugin is distributed in the hope that it will be useful,
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *   GNU General Public License for more details.
00016  * 
00017  *   You should have received a copy of the GNU General Public License
00018  *   along with Hugin  If not, see <http://www.gnu.org/licenses/>.
00019  *
00020  ***************************************************************************/
00021 
00022 #ifndef __CELESTE__
00023 #define __CELESTE__
00024 
00025 #include <hugin_shared.h>
00026 #include "svm.h"
00027 #include <string>
00028 #include <vector>
00029 #include <vigra/stdimage.hxx>
00030 #include <vigra/transformimage.hxx>
00031 #include <vigra/inspectimage.hxx>
00032 #include <vigra/functorexpression.hxx>
00033 #include <vigra_ext/utils.h>
00034 #include <panodata/Panorama.h>
00035 
00036 using namespace std;
00037 
00038 namespace celeste
00039 {
00040 
00046 CELESTEIMPEX bool loadSVMmodel(struct svm_model*& model, string& model_file);
00050 CELESTEIMPEX void destroySVMmodel(struct svm_model*& model);
00051 
00061 CELESTEIMPEX vigra::BImage getCelesteMask(struct svm_model* model, vigra::UInt16RGBImage& input, int radius, float threshold, int resize_dimension,bool adaptThreshold=false,bool verbose=true);
00062 
00063 CELESTEIMPEX HuginBase::UIntSet getCelesteControlPoints(struct svm_model* model, vigra::UInt16RGBImage& input, HuginBase::CPointVector cps, int radius, float threshold, int resize_dimension,bool verbose=true);
00064 
00071 template <class SrcIMG>
00072 void convertToUInt16(SrcIMG & src, const std::string & origType, vigra::UInt16RGBImage & dest)
00073 {
00074     dest.resize(src.size());
00075     long newMax=vigra_ext::getMaxValForPixelType("UINT16");
00076     // float needs to be from min ... max.
00077     if (origType == "FLOAT" || origType == "DOUBLE")
00078     {
00082         vigra::RGBToGrayAccessor<vigra::RGBValue<float> > ga;
00083         vigra::FindMinMax<float> minmax;   // init functor
00084         vigra::inspectImage(srcImageRange(src, ga),
00085                             minmax);
00086         double minVal = minmax.min;
00087         double maxVal = minmax.max;
00088         vigra_ext::applyMapping(srcImageRange(src), destImage(dest), minVal, maxVal, 0);
00089     }
00090     else
00091     {
00092         vigra::transformImage(srcImageRange(src), destImage(dest),
00093             vigra::functor::Arg1()*vigra::functor::Param( newMax/ vigra_ext::getMaxValForPixelType(origType)));
00094     };
00095 }
00096 
00097 
00098 }
00099 #endif
00100 

Generated on Fri Aug 22 01:25:31 2014 for Hugintrunk by  doxygen 1.3.9.1