28#include <hugin_config.h>
42#include "vigra/impexalpha.hxx"
44static void usage(
const char* name)
46 std::cout << name <<
": report the number of image groups in a project" << std::endl
49 <<
"Usage: " << name <<
" input.pto" << std::endl
51 << name <<
" examines the connections between images in a project and" << std::endl
52 <<
"reports back the number of parts or image groups in that project" << std::endl
54 <<
"Further switches:" << std::endl
55 <<
" --print-output-info Print more information about the output" << std::endl
56 <<
" --print-lens-info Print more information about lenses" << std::endl
57 <<
" --print-stack-info Print more information about assigned stacks" << std::endl
58 <<
" --print-image-info Print information about image files" << std::endl
59 <<
" --create-missing-images Creates placeholder images for non-existing" << std::endl
60 <<
" images in same directory as the pto file" << std::endl
62 << name <<
" is used by the assistant" << std::endl
72 std::cout << prefix <<
" " <<
i <<
": ";
90 std::cout << std::endl;
96 vigra::FindMinMax<float>
minmax;
97 vigra::inspectImage(srcImageRange(image, vigra::RedAccessor<vigra::RGBValue<float>>()),
minmax);
98 std::cout <<
" Red channel: " <<
minmax.min <<
" - " <<
minmax.max << std::endl;
100 vigra::inspectImage(srcImageRange(image, vigra::GreenAccessor<vigra::RGBValue<float>>()),
minmax);
101 std::cout <<
" Green channel: " <<
minmax.min <<
" - " <<
minmax.max << std::endl;
103 vigra::inspectImage(srcImageRange(image, vigra::BlueAccessor<vigra::RGBValue<float>>()),
minmax);
104 std::cout <<
" Blue channel: " <<
minmax.min <<
" - " <<
minmax.max << std::endl;
109 vigra::FindMinMax<float>
minmax;
110 vigra::inspectImage(srcImageRange(image),
minmax);
111 std::cout <<
" " <<
text <<
": " <<
minmax.min <<
" - " <<
minmax.max << std::endl;
117 std::cout << std::endl;
120 const std::string filename = pano.
getImage(imgNr).getFilename();
121 std::cout <<
"Image " << imgNr <<
": " << filename << std::endl;
124 if (vigra::isImage(filename.c_str()))
126 vigra::ImageImportInfo info(filename.c_str());
127 std::filesystem::path file(filename);
128 std::cout <<
" File type: " << info.getFileType() << std::endl;
129 const auto fileSize = std::filesystem::file_size(file);
130 std::cout <<
" File size: ";
133 std::cout <<
fileSize / 1000 <<
" kB" << std::endl;
137 std::cout <<
fileSize <<
" B" << std::endl;
139 std::cout <<
" Pixel type: " << info.getPixelType() << std::endl
140 <<
" Pixel size: " << info.width() <<
"x" << info.height() << std::endl
141 <<
" Resolution: " << info.getXResolution() <<
"/" << info.getYResolution() << std::endl
142 <<
" Offset: " << info.getPosition() << std::endl
143 <<
" Canvas size: " << info.getCanvasSize() << std::endl
144 <<
" ICC profile: " << (info.getICCProfile().empty() ?
"no" :
hugin_utils::GetICCDesc(info.getICCProfile())) << std::endl
145 <<
" Bands: " << info.numBands() << std::endl
146 <<
" Extra bands: " << info.numExtraBands() << std::endl;
147 if (info.numImages() > 1)
149 std::cout <<
" Subimages: " << info.numImages() <<
" (reading index " << info.getImageIndex() <<
")" << std::endl;
151 if (info.numExtraBands() == 0)
154 if (info.numBands() == 3)
157 vigra::FRGBImage image(info.size());
158 vigra::importImage(info, destImage(image));
163 if (info.numBands() == 1)
166 vigra::FImage image(info.size());
167 vigra::importImage(info, destImage(image));
172 std::cout <<
" Only RGB or grayscale images supported" << std::endl;
175 std::cout << std::endl;
179 if (info.numExtraBands() == 1)
182 if (info.numBands() == 4)
185 vigra::FRGBImage image(info.size());
186 vigra::FImage mask(info.size());
193 if (info.numBands() == 2)
196 vigra::FImage image(info.size());
197 vigra::FImage mask(info.size());
204 std::cout <<
" Only RGB or grayscale images supported" << std::endl;
207 std::cout << std::endl;
211 std::cout <<
" Only images with one or no alpha channel supported" << std::endl;
218 std::filesystem::path file(filename);
219 std::cout << std::endl <<
" not recognized by vigra as image file" << std::endl
220 <<
" File size: " << std::filesystem::file_size(file) / 1024 <<
" kiB" << std::endl << std::endl;
226 std::cout <<
" does not exists." << std::endl <<std::endl;
246 std::cout <<
"Image " << imgNr <<
": " <<
srcFile.string();
247 if (std::filesystem::exists(
srcFile))
249 std::cout <<
" exists." << std::endl;
263 std::cout <<
" does not exist. Creating " <<
newImage.filename() << std::endl;
268 vigra::exportImage(vigra::srcImageRange(image),
imgExportInfo);
276 std::cout <<
"Written output to " <<
output << std::endl;
373 std::cout << std::endl
374 <<
"Opened project " <<
input << std::endl << std::endl
375 <<
"Project contains" << std::endl
377 <<
variable_groups.getLenses().getNumberOfParts() <<
" lenses" << std::endl
378 <<
variable_groups.getStacks().getNumberOfParts() <<
" stacks" << std::endl
393 std::cout <<
"Control points statistics" << std::endl
394 << std::fixed << std::setprecision(2)
395 <<
"\tMean error : " <<
mean << std::endl
396 <<
"\tStandard deviation: " <<
sqrt(var) << std::endl
397 <<
"\tMinimum : " << min << std::endl
398 <<
"\tMaximum : " << max << std::endl;
407 std::cout <<
"All images are connected." << std::endl;
413 std::cout <<
"Found unconnected images!" << std::endl
414 <<
"There are " <<
comps.size() <<
" image groups." << std::endl;
416 std::cout <<
"Image groups: " << std::endl;
417 for (
size_t i=0;
i <
comps.size();
i++)
420 HuginGraph::ImageGraph::Components::value_type::const_iterator
it;
425 if (c+1 !=
comps[
i].size())
434 std::cout <<
", " << std::endl;
439 std::cout << std::endl;
442 std::cout << std::endl <<
"Lenses:" << std::endl;
447 std::cout << std::endl <<
"Stacks:" << std::endl;
454 std::cout << std::endl <<
"Output contains" << std::endl
455 << stacks.size() <<
" images stacks:" << std::endl;
458 std::cout << std::endl << std::endl <<
"and " <<
layers.size() <<
" exposure layers:" << std::endl;
463 std::cout <<
"Supported file formats: " << vigra::impexListFormats() << std::endl
464 <<
"Supported extensions: " << vigra::impexListExtensions() << std::endl;
declaration of functions to handle stacks and layers
Somewhere to specify what variables belong to what.
int main(int argc, char *argv[])
void InspectRGBImage(const vigra::FRGBImage &image)
void InspectGrayscaleImage(const vigra::FImage &image, const std::string text)
void PrintImageInfo(const HuginBase::Panorama &pano)
void CreateMissingImages(HuginBase::Panorama &pano, const std::string &output)
void PrintImageGroup(const std::vector< HuginBase::UIntSet > &imageGroup, const std::string &prefix=std::string())
static void calcCtrlPntsErrorStats(const PanoramaData &pano, double &min, double &max, double &mean, double &var, const int &imgNr=-1, const bool onlyActive=false, const bool ignoreLineCp=false)
Make an ImageVariableGroup for lenses and other common concepts.
const SrcPanoImage & getImage(std::size_t nr) const
get a panorama image, counting starts with 0
const PanoramaOptions & getOptions() const
returns the options for this panorama
bool ReadPTOFile(const std::string &filename, const std::string &prefix="")
read pto file from the given filename into Panorama object it does some checks on the file and issues...
std::size_t getNrOfCtrlPoints() const
number of control points
void setImageFilename(unsigned int img, const std::string &fname)
set a new image filename
bool WritePTOFile(const std::string &filename, const std::string &prefix="")
write data to given pto file
UIntSet getActiveImages() const
get active images
std::size_t getNrOfImages() const
number of images.
int getWidth() const
Get the width of the image in pixels.
int getHeight() const
Get the height of the image in pixels.
class to work with images graphs created from a HuginBase::Panorama class it creates a graph based on...
std::vector< HuginBase::UIntSet > Components
stores the components of the graph
class AlphaIterator class AlphaAccessor inline void importImageAlpha(const ImageImportInfo &import_info, ImageIterator image_iterator, ImageAccessor image_accessor, AlphaIterator alpha_iterator, AlphaAccessor alpha_accessor)
UIntSet getImagesinROI(const PanoramaData &pano, const UIntSet activeImages)
returns set of images which are visible in output ROI
std::set< unsigned int > UIntSet
std::vector< UIntSet > getHDRStacks(const PanoramaData &pano, UIntSet allImgs, PanoramaOptions opts)
returns vector of set of output stacks
std::vector< UIntSet > getExposureLayers(const PanoramaData &pano, UIntSet allImgs, PanoramaOptions opts)
returns vector of set of output exposure layers
std::string GetAbsoluteFilename(const std::string &filename)
returns the full absolute filename
std::string GetICCDesc(const vigra::ImageImportInfo::ICCProfile &iccProfile)
returns description of given icc profile
std::string GetHuginVersion()
return a string with version numbers
bool FileExists(const std::string &filename)
checks if file exists
std::string GetOutputFilename(const std::string &out, const std::string &in, const std::string &suffix)
construct output filename, if ouput is known return this value otherwise use the input filename and a...
std::string stripPath(const std::string &filename)
remove the path of a filename (mainly useful for gui display of filenames)
std::string getPathPrefix(const std::string &filename)
Get the path to a filename.
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.