26#include <hugin_config.h>
30#include <vigra/impex.hxx>
42 #define snprintf _snprintf
64 for(
char *c =
optarg; *c; c++) {
82 std::cerr<<
"Error: unknown option" << std::endl;
91 for(
char *c =
optarg; *c; c++) {
100 std::cerr<<
"Error: unknown option" << std::endl;
108 std::cout <<
"deghosting_mask: creates mask for removing ghosting in images" << std::endl
111 <<
"Usage: deghosting_mask [options] inputfile(s) " << std::endl
112 <<
" option are: " << std::endl
113 <<
" -o, --output=PREFIX prefix for output masks" << std::endl
114 <<
" -i, --iterations=ITER number of iterations, default is (ITER > 0)" << std::endl
116 <<
" -s, --sigma=SIGMA standard deviation of Gaussian weighting" << std::endl
117 <<
" function (SIGMA > 0); default: " <<
sigma << std::endl
119 <<
" -t, --threshold=THRESH threshold; default: " <<
thresholdLim << std::endl
120 <<
" -c, --contrast=CONTR change contrast before applying threshold;" << std::endl
121 <<
" default: " <<
contrast << std::endl
122 <<
" -a, --advanced=SET advanced settings. Possible options are:" << std::endl
123 <<
" f use gray images for computation. It's about two times faster" << std::endl
124 <<
" but it usually returns worse results." << std::endl
125 <<
" You also have to change threshold to smaller value (around 100)" << std::endl
126 <<
" g use gamma 2.2 correction instead of logarithm if input images are HDR" << std::endl
127 <<
" m do not scale image, NOTE: slows down process" << std::endl
128 <<
" t use simple threshold, may result in holes in images" << std::endl
129 <<
" w compute \"complete\" weights, not only probabilities" << std::endl
130 <<
" -w, --save=SET advanced save settings" << std::endl
131 <<
" i save initial weights" << std::endl
132 <<
" w save generated weights" << std::endl
133 <<
" -h, --help display this help" << std::endl
134 <<
" -v, --verbose verbose, repeat for more verbose output" << std::endl;
140 const char *
optstring =
"o:i:s:r:t:c:a:w:hv";
203 std::cerr <<
"There's a problem with parsing options" << std::endl;
222 std::cerr <<
"There's a problem with parsing options" << std::endl;
235 std::cerr <<
"There's a problem with parsing options" << std::endl;
308 std::cout << std::endl;
318 std::vector<std::string> inputFiles;
321 inputFiles.push_back(
argv[
i]);
324 std::vector<deghosting::FImagePtr> weights;
325 std::vector<vigra::Rect2D>
inputROI;
347 for (
unsigned int i = 0;
i<weights.size(); ++
i)
357 vigra::exportImage(srcImageRange(*weights[
i],
roi),
exWeights);
362 for (
unsigned int i = 0;
i < weights.size(); ++
i)
364 vigra::transformImage(vigra::srcImageRange(*(weights[
i])), vigra::destImage(*(weights[
i])), vigra::BrightnessContrastFunctor<vigra::FImage::PixelType>(1,
contrast, 0, 255));
370 for (
unsigned int i = 0;
i<weights.size(); ++
i)
387 catch (
const std::exception & e)
389 std::cerr <<
"caught exception: " << e.what() << std::endl;
393 std::cerr <<
"caught unknown exception" << std::endl;
static uint16_t debugFlags
int main(int argc, char *argv[])
void parseOptions_advanced(char *optarg)
function handling advanced options
static uint16_t otherThresholdFlags
static double thresholdLim
void parseOptions_save(char *optarg)
function handling save options
static const uint16_t OTHER_GRAY
static deghosting::EMoR response(0.0f)
static uint16_t otherFlags
static const uint16_t SAVE_GENWEIGHTS
Tool for creating b/w alpha masks to eliminate ghosting artifacts Copyright (C) 2009 Lukáš Jirkovský ...
void simpleDenoise(SrcIterator sy, SrcIterator send, SrcAccessor sa, DestIterator dy, DestAccessor da)
Simple denoising algorithm Copyright (C) 2009 Lukáš Jirkovský l.jirkovsky@gmail.com
std::vector< float > EMoR
const uint16_t ADV_MULTIRES
const uint16_t SAVE_INITWEIGHTS
std::string stripExtension(const std::string &basename2)
remove extension of a filename
std::string GetHuginVersion()
return a string with version numbers
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)
const uint16_t THRESHOLD_DONTCARE
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.