25 #include <Base/Image/Image.hh>
26 #include <Base/Image/ImageConvert.hh>
27 #include <Base/Image/ImageIO.hh>
28 #include <Image/Camera.hh>
29 #include <Utils/IOUtils.hh>
30 #include <Utils/Param.hh>
31 #include <Filter/Rescale.hh>
32 #include <Base/Common/FileHandling.hh>
44 int main(
int argc,
char* argv[]) {
47 double *ratio = p.AddParamDouble(
"ratio",
"rescale ratio", 2.0, 0.1, 1000.0,
'r');
49 Vector<int> *newsize = p.AddParamVecInt(
"size",
"new size, (0 0) will use ratio",
"0 0",
's');
51 string *input = p.AddParamString(
"input",
"input image or image list",
"",
'i');
52 string *output = p.AddParamString(
"output",
"output image",
"",
'o');
54 if(!IOUtils::ParseCommandLineEvalHelp(p, argc, argv) )
58 BIASERR(
"Give input image with -i option");
62 BIASERR(
"Give ouput image with -o option");
68 bool listMode =
false;
89 vector<string> intFiles;
95 if(res==0) listMode=
true;
97 BIASERR(
"Input suggest list of images, but parsing the list failes.");
102 intFiles.push_back(*input);
105 for(
unsigned i=0;i<intFiles.size();i++){
106 ImageIO::Load(intFiles[i], inBase);
109 IOUtils::LoadCamera(&intFiles[i], fin, pIn);
113 IOUtils::LoadCamera(&intFiles[i], in, pIn);
117 BIASERR(
"Unhandled image storage type, please add switch.");
122 if ((*newsize)[0] == 0 || ((*newsize)[1] == 0)) {
128 fscaler.
Filter(fin, fout);
138 if ((*newsize)[0] > w && (*newsize)[1] > h) {
140 fscaler.
Upsample(fin, fout, (*newsize)[0], (*newsize)[1]);
142 scaler.
Upsample(in, out, (*newsize)[0], (*newsize)[1]);
144 }
else if ((*newsize)[0] <= w && (*newsize)[1] <= h) {
146 fscaler.
Downsample(fin, fout, (*newsize)[0], (*newsize)[1]);
148 scaler.
Downsample(in, out, (*newsize)[0], (*newsize)[1]);
151 cout <<
"can only Up- or Downsample" << endl;
154 cout <<
"WARNING: Projections are only scaled in rescale-by-ratio-mode. Will leave ProjectionParameters as they are" << endl;
158 string outputFile=*output;
163 str<<dir<<base<<
"-"<<FileHandling::LeadingZeroString(i,5)<<suffix;
164 outputFile = str.str();
170 IOUtils::SaveCamera(outputFile, fout, pIn);
173 IOUtils::SaveCamera(outputFile, out, pIn);
178 IOUtils::SaveCamera(outputFile, fout);
181 IOUtils::SaveCamera(outputFile, out);
virtual parent class for API definition of all (future) filters
void Rescale(float ratio, unsigned int cam=0)
adapt internal params to resampled image
int Downsample(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
generic downsample function.
unsigned int GetWidth() const
This class hides the underlying projection model, like projection matrix, spherical camera...
virtual int Filter(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
scales the src to dst using the downsampling factor from SetFactor()
static void SplitName(const std::string &fullname, std::string &dir, std::string &base, std::string &suffix)
Split full path into:
void SetBorderHandling(const int bh)
int Upsample(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
generic upsample function
static int ParseListFile(const std::string &ListFileName, std::vector< std::string > &LinesInFile)
Extracts lines from passed file.
This class Param provides generic support for parameters.
bool IsEmpty() const
Determine whether the Projection is Empty.
enum EStorageType GetStorageType() const
This is the base class for images in BIAS.
void SetFactor(double factor)
the downsampling factor
void UnsetROI()
deprecated, use GetROI()->UnsetROI()