00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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
00077 if (origType == "FLOAT" || origType == "DOUBLE")
00078 {
00082 vigra::RGBToGrayAccessor<vigra::RGBValue<float> > ga;
00083 vigra::FindMinMax<float> minmax;
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