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 namespace celeste
00037 {
00038 
00044 CELESTEIMPEX bool loadSVMmodel(struct svm_model*& model, std::string& model_file);
00048 CELESTEIMPEX void destroySVMmodel(struct svm_model*& model);
00049 
00059 CELESTEIMPEX vigra::BImage* getCelesteMask(struct svm_model* model, vigra::UInt16RGBImage& input, int radius, float threshold, int resize_dimension,bool adaptThreshold=false,bool verbose=true);
00060 
00061 CELESTEIMPEX HuginBase::UIntSet getCelesteControlPoints(struct svm_model* model, vigra::UInt16RGBImage& input, HuginBase::CPointVector cps, int radius, float threshold, int resize_dimension,bool verbose=true);
00062 
00069 template <class SrcIMG>
00070 void convertToUInt16(SrcIMG & src, const std::string & origType, vigra::UInt16RGBImage & dest)
00071 {
00072     dest.resize(src.size());
00073     long newMax=vigra_ext::getMaxValForPixelType("UINT16");
00074     // float needs to be from min ... max.
00075     if (origType == "FLOAT" || origType == "DOUBLE")
00076     {
00080         vigra::RGBToGrayAccessor<vigra::RGBValue<float> > ga;
00081         vigra::FindMinMax<float> minmax;   // init functor
00082         vigra::inspectImage(srcImageRange(src, ga),
00083                             minmax);
00084         double minVal = minmax.min;
00085         double maxVal = minmax.max;
00086         vigra_ext::applyMapping(srcImageRange(src), destImage(dest), minVal, maxVal, 0);
00087     }
00088     else
00089     {
00090         vigra::transformImage(srcImageRange(src), destImage(dest),
00091             vigra::functor::Arg1()*vigra::functor::Param( newMax/ vigra_ext::getMaxValForPixelType(origType)));
00092     };
00093 }
00094 
00095 
00096 }
00097 #endif
00098 

Generated on 27 Jul 2016 for Hugintrunk by  doxygen 1.4.7