24#include <vigra/sized_int.hxx>
31#define IMATH_HALF_NO_LOOKUP_TABLE
34#include <ImfRgbaFile.h>
43 fgets(line, 256, file);
45 printf(
"pgm read: not a pgm file\n");
49 fgets(line, 256, file);
50 while (line[0] ==
'#')
51 fgets(line, 256, file);
54 fgets(line, 256, file);
55 sscanf(line,
"%d", &maxval);
59template<
class Functor>
63 typedef vigra::RGBValue<float> PixelType;
64 typedef std::shared_ptr<Imf::RgbaInputFile>
InFilePtr;
65 typedef std::shared_ptr<vigra_ext::FileRAII>
AutoFilePtr;
69 std::vector<InFilePtr> inputFiles;
73 for (
unsigned i=0;
i <
input.size();
i++) {
80 inputFiles.push_back(in);
81 Imath::Box2i
dw = in->dataWindow();
82 vigra::Rect2D
roi(
dw.min.x,
dw.min.y,
dw.max.x+1,
dw.max.y+1);
84 dw = in->displayWindow();
118 typedef std::shared_ptr<vigra::ArrayVector<vigra::UInt8> >
Array8Ptr;
119 typedef std::shared_ptr<Imf::Array2D<Imf::Rgba> >
ArrayPtr;
125 for (
unsigned i=0;
i <
input.size();
i++) {
126 ArrayPtr p(
new Imf::Array2D<Imf::Rgba>);
139 for (
unsigned j=0;
j <
input.size();
j++) {
143 inputFiles[
j]->setFrameBuffer( pixels, 1,
roiWidth);
149 inputFiles[
j]->readPixels (
ys,
ye);
173 for (
unsigned int j=0;
j<
input.size();
j++) {
185 PixelType val = reduce();
209 for (
int j=0;
j <
input.size();
j++) {
bool readPGMHeader(FILE *file, int &w, int &h, int &maxval)
void reduceFilesToHDR(std::vector< std::string > input, std::string output, bool onlyCompleteOverlap, Functor &reduce)
Class used for opening files.
std::string stripExtension(const std::string &basename2)
remove extension of a filename
std::string getExtension(const std::string &basename2)
Get extension of a filename.
std::string tolower(const std::string &s)
convert a string to lowercase
bool FileExists(const std::string &filename)
checks if file exists
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.