Hugin trunk 0.1
Loading...
Searching...
No Matches
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
36namespace celeste
37{
38
44CELESTEIMPEX bool loadSVMmodel(struct svm_model*& model, std::string& model_file);
48CELESTEIMPEX void destroySVMmodel(struct svm_model*& model);
49
59CELESTEIMPEX vigra::BImage* getCelesteMask(struct svm_model* model, vigra::UInt16RGBImage& input, int radius, float threshold, int resize_dimension,bool adaptThreshold=false,bool verbose=true);
60
61CELESTEIMPEX HuginBase::UIntSet getCelesteControlPoints(struct svm_model* model, vigra::UInt16RGBImage& input, HuginBase::CPointVector cps, int radius, float threshold, int resize_dimension,bool verbose=true);
62
69template <class SrcIMG>
70void 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 {
90 vigra::transformImage(srcImageRange(src), destImage(dest),
91 vigra::functor::Arg1()*vigra::functor::Param( newMax/ vigra_ext::getMaxValForPixelType(origType)));
92 };
93}
94
95
96}
97#endif
98
#define CELESTEIMPEX
std::vector< CPoint > CPointVector
std::set< unsigned int > UIntSet
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
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
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 destroySVMmodel(struct svm_model *&model)
frees the resource of model
Definition Celeste.cpp:60
bool loadSVMmodel(struct svm_model *&model, std::string &model_file)
loads the SVM model from file
Definition Celeste.cpp:45
double getMaxValForPixelType(const std::string &v)
Definition utils.h:89
void applyMapping(vigra::triple< SrcIterator, SrcIterator, SrcAccessor > img, vigra::pair< DestIterator, DestAccessor > dest, T min, T max, int mapping)
Definition utils.h:685
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
functions to manage ROI's