Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
biasconvert.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5 Multimediale Systeme der Informationsverarbeitung
6 Institut fuer Informatik
7 Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 
26 #include <Image/Camera.hh>
27 #include <Base/Image/ImageBase.hh>
28 #include <Base/Image/ImageIO.hh>
29 #include <Base/Image/ImageConvert.hh>
30 #include <Base/Image/ImageAttributes.hh>
31 #include <Geometry/PMatrix.hh>
32 #include <bias_config.h>
33 #include <stdio.h>
34 #include <fstream>
35 #include <Utils/Param.hh>
36 
37 #ifdef WIN32
38 # include "Base/Common/getopt_W32.h"
39 #else //not WIN32
40 # include <getopt.h>
41 #endif //WIN32
42 
43 using namespace BIAS;
44 using namespace std;
45 
46 /**
47  @file
48  @ingroup g_tools
49  @brief Convert input image format to output image format, see biasconvert.cpp
50  @author MIP
51 */
52 void writePixelToFileFloat(void** imageArray, unsigned int w,
53  unsigned int h, ofstream& ofs) {
54  float* row = (float*)imageArray[h];
55  ofs<<row[w];
56 }
57 
58 void writePixelToFileUChar(void** imageArray, unsigned int w,
59  unsigned int h, ofstream& ofs) {
60  unsigned char* row = (unsigned char*)imageArray[h];
61  ofs<<row[w];
62 }
63 
64 
65 int DetermineFiletype(const string &fn)
66 {
68 }
69 
70 
71 
72 void AdoptPMatrix(PMatrix &P,float scalex,float scaley)
73 {
74  PMatrix *newP=NULL;
76  KMatrix K;
78 
79  if (P[0][0] != 0) {
80  P.GetC(C);
81  P.GetK(K);
82  P.GetR(R);
83 
84  K[0][0] *= scalex;
85  K[1][1] *= scaley;
86  K[0][2] *= scalex;
87  K[1][2] *= scaley;
88  // the skew
89  K[0][1] *= scaley;
90  newP = new PMatrix(K,R,C);
91  P = *newP;
92  }
93 }
94 
95 
96 
97 int ReadPMatrix(PMatrixBase &pmat,const string &filename)
98 {
99  int row,col;
100  ifstream pmatfile(filename.c_str());
101  if (!pmatfile){
102  cerr << "unable to open " << filename<< endl;
103  perror("");
104  return -1;
105  }
106  pmatfile >> row >> col;
107  if (!pmatfile){
108  cerr << "error reading " << filename << endl;
109  return -1;
110  }
111  if (row!=3 || col!=4){
112  cerr << "P Matrix should have size 3x4, not: " <<row<<"x"<<col << endl;
113  return -1;
114  }
115 
116 
117  for (int r=0; r < row; r++)
118  for (int c=0; c< col; c++)
119  pmatfile >> pmat[r][c];
120  return 0;
121 
122 }
123 
124 int ReadEXIF(const string &ifile, KMatrix &KExif, int &EXIFMode)
125 {
126  //cout<<"reading exif tags"<<endl;
127  ImageAttributes Att;
128  Att.InitExifTags();
129  if (Att.Read(ifile)!=BIAS_IMAGEATTRIBUTES_SUCCESS) {
130  cerr<<"error reading exif tags ..."<<endl;
131  EXIFMode = 0;
132  return -1;
133  } else {
134  //Att.Print();
135  KExif.SetIdentity();
136  bool success = true;
137  success = success && (Att.GetFocalLengthXPixel(KExif[0][0])>=0);
138  success = success && (Att.GetFocalLengthYPixel(KExif[1][1])>=0);
139  success = success && (Att.GetPrincipalPoint(KExif[0][2],
140  KExif[1][2] )>=0);
141  if (success) {
142  cout<<"Found a K="<<KExif<<endl;
143  } else {
144  cout<<"Error, not enough EXIF data to get K:"<<KExif<<endl;
145  EXIFMode = 0;
146  }
147  return (success)?(0):(-1);
148  }
149  return -7657;
150 }
151 
152 int main (int argc, char *argv[])
153 {
154  // pic.SetDebugLevel(D_CAM_IO);
155  Param param;
156  bool *help = param.AddParamBool("help", "display help", false, 'h');
157  bool *togrey = param.AddParamBool("toGrey", "convert image to grey image", false, 'g');
158  bool *toHSL = param.AddParamBool("toHSL", "convert image to HSL image", false, 'l');
159  bool *toRGB = param.AddParamBool("toRGB", "convert image to RGB image", false, 'r');
160 
161  bool *verbose = param.AddParamBool("verbose", "verbose output", false, 'v');
162  int *EXIFMode = param.AddParamInt("KFromExif", "Compute K Matrix from exif data (0,1,2):", 0, 0, 2, 'e');
163  string *pmatfile = param.AddParamString("PMatrixFile", "add P-Matrix", "", 'p');
164  double *scale = param.AddParamDouble("modulate", "Modulate (scale) all pixel values", 1.0, -DBL_MAX, DBL_MAX, 'm');
165  double *shift = param.AddParamDouble("offset", "Offset all pixels", 0.0, -DBL_MAX, DBL_MAX, 'o');
166  double *newzero = param.AddParamDouble("newZero", "new value for zero (useful for inverting depth maps)", 0.0, -DBL_MAX, DBL_MAX, 'z');
167  int *imagequality = param.AddParamInt("quality", "quality for lossy formats [0;100] best=100", BIAS_DEFAULT_IMAGE_QUALITY, 0, 100, 'q');
168  bool *clip = param.AddParamBool("clip", "clip values to [0,255], only effective if -m or -o", false, 'c');
169  bool *convertToMatrix = param.AddParamBool("convertToMatrix", "convert to matrix textfile, readable my matlab with simple header", false, 'T');
170  bool *convertFromMatrix = param.AddParamBool("convertFromMatrix", "convert from matrix textfile containing rows cols colorchannels and interleaved flag in the first line and then the image matrix row by row", false, 'F');
171  bool *ToIMA = param.AddParamBool("convertToIma", "convert into binary ima fileformat needed by RealEyes", false, 'I');
172 
173  vector<string> st_enum;
174  vector<int> st_ids;
175  st_enum.push_back("auto"); st_ids.push_back(ImageBase::ST_invalid);
176  st_enum.push_back("unsignedchar"); st_ids.push_back(ImageBase::ST_unsignedchar);
177  st_enum.push_back("float"); st_ids.push_back(ImageBase::ST_float);
178 #ifdef BUILD_IMAGE_USHORT
179  st_enum.push_back("unsignedshort"); st_ids.push_back(ImageBase::ST_unsignedshortint);
180 #endif
181  int *outstparam = param.AddParamEnum("storageType", "Output Storage Type", st_enum, ImageBase::ST_invalid, &st_ids, 's');
182  bool replacezero = false;
183  bool maxDynamics = false;
184 
185  int fup = param.ParseCommandLine(argc, argv);
186 
187  bool scaleshift = (*scale != 1.0 || *shift != 0.0);
188 
189  if (*help || argc <3) {
190  cout << "Usage: " << argv[0] << " [options] infile outfile\n";
191  param.Usage();
192  cout <<"if neither -m nor -o is given float images are scaled \n"
193  <<"and shifted automatically"<<endl;
194  return 0;
195  }
196  string ifile = argv[fup];
197  string ofile = argv[fup+1];
198 
199  ImageBase ipic;
200 
201  Camera<unsigned char> ucocam;
202  Camera<float> focam;
203 #ifdef BUILD_IMAGE_USHORT
204  Camera<unsigned short> usocam;
205 #endif
208 
210  PMatrix P_;
211 
212  // after getopt() all recognized options are before non-options
213  ifile = argv[argc-2];
214  ofile = argv[argc-1];
215 
216  if (*newzero != 0.0) {
217  replacezero = true;
218  }
219  ///////////////////////////////////////
220  //check for matlab ot image file format
221  if(!*convertToMatrix && !*ToIMA) {
222  //determine output image format
223  // if no ending is given it is saved as auto (mip)
224  ofiletype = (ImageIO::TFileFormat)DetermineFiletype(ofile);
225  if ((ofiletype ==-1) || (ofiletype==ImageIO::FF_unknown)){
226  BIASWARN("unknown FileFormat"<<ofile);
227  ofiletype =ImageIO::FF_auto;
228  }
229 
230  if (ofiletype == ImageIO::FF_pgm)
231  *togrey = true;
232  }
233 
234  if (*verbose) {
235  cout <<"load "<<ifile<<", "<<flush;
236  }
237  ///////////////////////////////////////////////////////
238  //check for text file images, like Matlab
239  if (*convertFromMatrix) {
240  if (ImageIO::ImportMatrix(ifile,ipic,*verbose)!=0) return -1;
241  } else {
242  if (ImageIO::Load(ifile,ipic)<0){
243  BIASERR("could not load " <<ifile);
244  exit(1);
245  }
246  }
247 
248  if (*outstparam != ImageBase::ST_invalid && !scaleshift) {
249  if (ipic.GetStorageType() != *outstparam) {
250  ImageBase convtemp;
251  ImageConvert::ConvertST(ipic, convtemp, (ImageBase::EStorageType)(*outstparam));
252  ipic.StealImage(convtemp);
253  }
254  }
255 
256  ///////////////////////////////////////////////////////
257  //if output file format is auto, call Save() and return
258  if(ofiletype ==ImageIO::FF_auto){
259  return BIAS::ImageIO::Save(ofile,ipic);
260  }
261 
262  //check if it is IMA file format, call Write and return
263  if(*ToIMA) {
264  cout<<"writing IMA format (RealEyes)\n";
265  Image<unsigned char> flipped(ipic);
266  flipped.Flip();
267  ImageBase sink(ipic.GetWidth(), ipic.GetHeight(),
269  false);
270 
271  ImageConvert::Convert(flipped, sink, ImageBase::CM_RGB, true);
272  return ImageIO::WriteRAW_IMA(ofile, sink);
273  }
274 
275  if (*verbose) ipic.PrintHeader();
276 
277  ///////////////////////////////////////
278  //check for matlab call WriteMatlab and return
279  if(*convertToMatrix) {
281  if(filename != ofile) {
282  BIASWARNONCE("Changed filenames to extension .matrix")
283  }
284  return ImageIO::ExportMatrix(filename,ipic,*verbose);
285  }
286 
287  KMatrix KExif;
288  if (*EXIFMode>0) {
289  if (ReadEXIF(ifile, KExif, *EXIFMode)!=0) return -1;
290  }
291 
292  if (ipic.GetStorageType() == ImageBase::ST_float) {
293  if (verbose) cout <<"storagetype is float"<<endl;
294  Camera<float> fcam(ipic);
295  fcam.ParseMetaData();
296  P_ = fcam.GetP();
297 
298  //check for other types than MIP or OpenEXR
299  //means we convert to UCHAR
300  if (ofiletype != ImageIO::FF_mip && ofiletype != ImageIO::FF_exr) {
301  if (scaleshift){
302  if (*verbose) {
303  float min,max;
304  fcam.GetMinMaxPixelValue(min,max);
305  cout << "min = " << min << ", max = " << max << endl;
306  }
307 
308  float mean =0.0;
309  float *fcamptr=fcam.GetImageData();
310  float num_elem=0;
311  //float max=(255-shift)/scale;
312  //float min=-shift/scale;
313  for (unsigned int i = 0; i < fcam.GetWidth()*fcam.GetHeight(); i++){
314  if (*fcamptr != -1.0){
315  mean += *fcamptr;
316  num_elem++;
317  }
318  fcamptr++;
319  }
320 
321  mean /= num_elem;
322  fcamptr=fcam.GetImageData();
323  float variance=0.0;
324  float scaledmean=0.0;
325  for (unsigned int i = 0; i < fcam.GetWidth()*fcam.GetHeight();i++){
326  if (*fcamptr != -1.0)
327  variance += (*fcamptr-mean)*(*fcamptr-mean);
328  }
329 
330  fcam.ScaleShift(*scale,*shift);
331  fcamptr=fcam.GetImageData();
332  if (clip)
333  for (unsigned int i = 0; i < fcam.GetWidth()*fcam.GetHeight();i++){
334  *fcamptr = (*fcamptr < 255) ? *fcamptr : 255 ;
335  *fcamptr = (*fcamptr > 0) ? *fcamptr : 0 ;
336  scaledmean += *fcamptr;
337  fcamptr++;
338  }
339 
340  if (*verbose){
341  variance/= num_elem;
342  cout << "mean = " << mean << ", scaledmean="
343  << scaledmean/num_elem
344  << ", variance = "
345  << variance << ", fill rate = "
346  << num_elem/fcam.GetWidth()/fcam.GetHeight() << endl;
347  }
348  } else {
349  if (*verbose) {
350  float min,max;
351  fcam.GetMinMaxPixelValue(min,max);
352  cout << "min = " << min << ", max = " << max << endl;
353  }
354  fcam.ScaleShiftBetween(0,255);
355  }
356  //ucocam = fcam;
357  //OutST = ImageBase::ST_float;
359  ImageConvert::ConvertST(fcam, ucocam, OutST );
360  // copy meta data to ucocam
361  *ucocam.GetMetaData()=*fcam.GetMetaData();
362  ucocam.ParseMetaData();
363  }//end if (ofiletype != ImageIO::FF_mip && ofiletype != ImageIO::FF_exr)
364 
365  else {//this is ofiletype==mip || type ==exr
366 
367  if (*togrey) ImageConvert::ToGrey(fcam , focam);
368  else if(*toHSL) ImageConvert::ToHSL(fcam, focam);
369  else if(*toRGB) ImageConvert::ToRGB(fcam, focam);
370  else focam = fcam;
371 
372  if (replacezero) {
373  /*if (newzero==0.0) {
374  float min, max;
375  // automatic value range detection
376  focam.GetMinMaxPixelValue(min,max);
377  newzero = min - (max-min / 20.0);
378  } */
379  float *focamptr = focam.GetImageData(),
380  *fcamptr = fcam.GetImageData();
381  for (unsigned int i = 0; i < focam.GetWidth()*focam.GetHeight();i++){
382  if ((*fcamptr) <= 0) {
383  *focamptr = float(*newzero);
384  //cout<<"0";
385  }
386  fcamptr++;
387  focamptr++;
388  }
389  } //end replace zero
390 
391  if (scaleshift) {
392  focam.ScaleShift(*scale,*shift);
393  }//end scaleshift
394  OutST = ImageBase::ST_float;
395  }
396 
397  }// end if (ipic.GetStorageType() == ImageBase::ST_float) {
398  /////////unsigned char input images //////////////
399  else if (ipic.GetStorageType() == ImageBase::ST_unsignedchar) {
400 #ifdef BIAS_DEBUG
401  if (verbose) {
402  if (Debug::GetGlobalDebugLevel()<D_CONVERT)
403  Debug::SetGlobalDebugLevel(D_CONVERT);
404  }
405 #endif
406  if (*verbose) cout <<"storagetype is unsigned char"<<endl;
407  Camera<unsigned char> uccam(ipic);
409  uccam.ParseMetaData();
410  P_ = uccam.GetP();
411 
412  // all meta datas are preserved now (felix)
413  if (*verbose) cout <<"P: "<<P_<<endl;
414 
415  if (scaleshift) {
416  if (*scale>1.0) {
417  BIASWARN("You scale an unsigned char image with more than 1.0");
418  }
419  uccam.ScaleShift(*scale,*shift);
420  }
421  // meta datas are lost here
422  if (*togrey) ImageConvert::ToGrey(uccam, ucocam);
423  else if(*toHSL) ImageConvert::ToHSL(uccam, ucocam);
424  else if(*toRGB) ImageConvert::ToRGB(uccam, ucocam);
425  else ImageConvert::ToRGB(uccam, ucocam);
426 
427  // copy meta data to ucocam
428  *ucocam.GetMetaData()=*uccam.GetMetaData();
429  ucocam.ParseMetaData();
430  }// end if (ipic.GetStorageType() == ImageBase::ST_unsignedchar)
431  ////////////unsigned short input images //////////////
432 #ifdef BUILD_IMAGE_USHORT
433  else if (ipic.GetStorageType() == ImageBase::ST_unsignedshortint) {
434 # ifdef BIAS_DEBUG
435  if (*verbose) {
436  if (Debug::GetGlobalDebugLevel()<D_CONVERT)
437  Debug::SetGlobalDebugLevel(D_CONVERT);
438  }
439 # endif
440  if (*verbose)
441  cout << "input storagetype is unsigned short int"<<endl
442  << "output file type is "<<ofiletype<<endl;
443  Camera<unsigned short> uscam(ipic);
444  if (ofiletype!=ImageIO::FF_mip){
445  Camera<unsigned char> tmpcam;
447  uscam.ParseMetaData();
448  P_ = uscam.GetP();
449  // uccam.GetTime(sec,usec);
450  // all meta datas are preserved now (felix)
451  if (verbose) cout <<"P: "<<P_<<endl;
452 
453  // now scale and shift if necessary
454  if (scaleshift){
455  Image<float> foim;
457  foim.ScaleShift(*scale, *shift);
458  if (clip){
459  foim.BelowThresholdToValue(0.0, 0.0);
460  foim.AboveThresholdToValue(255.0, 255.0);
461  }
462  ImageConvert::ConvertST(foim, tmpcam, OutST);
463  } else {
464  ImageConvert::ConvertST(uscam, tmpcam, OutST);
465  }
466 
467  // meta datas are lost here
468  if (*togrey) ImageConvert::ToGrey(tmpcam, ucocam);
469  else if(*toHSL) ImageConvert::ToHSL(tmpcam, ucocam);
470  else if(*toRGB) ImageConvert::ToRGB(tmpcam, ucocam);
471  else if (ipic.GetChannelCount()!=1) ImageConvert::ToRGB(tmpcam, ucocam);
472 
473  // copy meta data to ucocam
474  *ucocam.GetMetaData()=*uscam.GetMetaData();
475  ucocam.ParseMetaData();
476  } else { // do not convert, output can be written as
478 
479  // meta datas are lost here
480  if (*togrey) ImageConvert::ToGrey(uscam, usocam);
481  else if(*toHSL) ImageConvert::ToHSL(uscam, usocam);
482  else if(*toRGB) ImageConvert::ToRGB(uscam, usocam);
483  else if (ipic.GetChannelCount()!=1) ImageConvert::ToRGB(uscam, usocam);
484  else usocam = uscam;
485 
486  // copy meta data to ucocam
487  *usocam.GetMetaData()=*uscam.GetMetaData();
488  usocam.ParseMetaData();
489  }
490  if (*verbose) cout << "output storage type is "<<OutST<<endl;
491  } //end if (ipic.GetStorageType() == ImageBase::ST_unsignedshortint) {
492 #endif
493 
494  if (*pmatfile != "") {
495  if (*verbose) cout <<"read "<<*pmatfile<<", ";
496  if (ReadPMatrix(P_,*pmatfile) < 0)
497  exit(1);
498  ucocam.SetP(P_);
499  focam.SetP(P_);
500  }
501 
502  // if (downbypoweroftwo >0) {
503  // if (verbose) cout <<"rescale, "<<flush;
504  // Filter f;
505  // Camera<unsigned char> tmppic;
506  // f.DownsampleByPowerOfTwo(opic,tmppic,downbypoweroftwo);
507  // opic = tmppic;
508  // AdoptPMatrix(P_, scalex,scaley);
509  // }
510 
511  ///////////////////////////////////////////
512  // now switch over output storage type
513  ///////////////////////////////////////////
514  if (OutST == ImageBase::ST_unsignedchar) {
515  if (EXIFMode>0) ucocam.SetK(KExif);
516  ucocam.UpdateMetaData();
517  if (*verbose) cout <<"write unsigned char "<<ofile<<", "<<flush;
518  if (ofiletype == ImageIO::FF_mip) {
519  if(maxDynamics)
520  ucocam.ScaleShiftBetween(0,255);
521  //ImageIO::Save(ofile, ucocam);
522  ImageIO::Save(ofile, ucocam);
523  } else {
524  // if (ofiletype !=ImageIO::FF_ppm && ofiletype !=ImageIO::FF_pgm) {
525  if (ucocam.GetChannelCount() == 1 && (ofiletype == ImageIO::FF_png || ofiletype == ImageIO::FF_jpg)) {
526  Camera<unsigned char> tmp = ucocam;
527  ImageConvert::ToRGB(tmp, ucocam);
528  }
529  string::size_type endofprefix = ofile.rfind('.');
530  ofile = ofile.substr(0,endofprefix);
531  ImageIO::Save(ofile,ucocam,ofiletype,false,*imagequality);
532  }
533  } else if (OutST == ImageBase::ST_float) {
534  // all meta datas are preserved now (felix)
535  if (*EXIFMode>0) focam.SetK(KExif);
536  focam.UpdateMetaData();
537  if(maxDynamics)
538  focam.ScaleShiftBetween(0,255);
539  ImageIO::Save(ofile, focam);
540  // ImageIO::Save(ofile, focam);
541  if (*verbose) cout <<"write float "<<ofile<<", "<<flush;
542  }
543 #ifdef BUILD_IMAGE_USHORT
544  else if (OutST == ImageBase::ST_unsignedshortint) {
545  if (*EXIFMode>0) usocam.SetK(KExif);
546  usocam.UpdateMetaData();
547  //ImageIO::Save(ofile, usocam);
548  ImageIO::Save(ofile, usocam);
549  if (*verbose) cout <<"write unsigned short "<<ofile<<", "<<flush;
550  }
551 #endif
552 
553  if (*verbose) cout <<"done"<<endl;
554 
555  return 0;
556 }
557 
static long int GetGlobalDebugLevel()
Definition: Debug.hh:431
void PrintHeader(std::ostream &os=std::cout) const
Definition: ImageBase.cpp:905
int AboveThresholdToValue(StorageType Threshold, StorageType Value)
sets alls pixels with values above Threshold to Value
Definition: Image.cpp:1028
(16bit) unsigned integer image storage type
Definition: ImageBase.hh:114
static int ExportMatrix(const std::string &FileName, const ImageBase &img, const bool verbose)
Export BIAS images to text images.
Definition: ImageIO.cpp:1268
int BelowThresholdToValue(StorageType Threshold, StorageType Value)
sets alls pixels with values below Threshold to Value
Definition: Image.cpp:1013
int ScaleShiftBetween(double Min, double Max)
scales and shifts image so afterwards every pixel has a value between Min and Max ...
Definition: Image.cpp:1118
MetaData * GetMetaData()
Definition: ImageBase.hh:456
bool * AddParamBool(const std::string &name, const std::string &help, bool deflt=false, char cmdshort=0, int Group=GRP_NOSHOW)
Definition: Param.cpp:305
int GetPrincipalPoint(double &x, double &y)
look up principal point
double * AddParamDouble(const std::string &name, const std::string &help, double deflt=0.0, double min=-DBL_MAX, double max=DBL_MAX, char cmdshort=0, int Group=GRP_NOSHOW)
Definition: Param.cpp:351
float image storage type
Definition: ImageBase.hh:118
static std::string ExtensionName(const std::string &oldName, const std::string &newExtension)
appends extension to name if extension is not already extension, avoids double extension like &quot;...
Definition: ImageIO.cpp:1072
int * AddParamEnum(const std::string &name, const std::string &help, const std::vector< std::string > &enums, const int deflt=0, const std::vector< int > *IDs=NULL, const char cmdshort=0, const int Group=GRP_NOSHOW)
Definition: Param.cpp:468
int SetP(const PMatrix &matP)
Definition: Camera.hh:102
int ScaleShift(double Scale, double Shift)
scales and shifts image (all channels simultanously)
Definition: Image.cpp:1064
static BIASImageBase_EXPORT int ToHSL(const Image< StorageType > &source, Image< StorageType > &dest)
Create a HSL converted copy of source image in this Release() and Init() are called if necessary...
Definition: ToHSL.cpp:36
int GetR(Matrix3x3< double > &R)
Definition: PMatrix.cpp:204
static BIAS::ImageIO::TFileFormat GetFileFormat(const std::string &str)
determines the BIAS::ImageIO::TFileFormat for a given filename/ extension Decision based on extension...
Definition: ImageIO.cpp:2543
unsigned int GetWidth() const
Definition: ImageBase.hh:312
int ParseCommandLine(int &argc, char *argv[])
scan command line arguments for valid parameters
Definition: Param.cpp:1028
invalid not set image storage type
Definition: ImageBase.hh:111
void Usage(std::ostream &os=std::cout)
print Help-Information to stdout
Definition: Param.cpp:176
int StealImage(ImageBase &source)
steals the image data array from source, after releasing the actual image data and sets source image ...
Definition: ImageBase.cpp:395
static int ConvertST(const BIAS::ImageBase &source, BIAS::ImageBase &dest, ImageBase::EStorageType targetST)
Function to convert the storage type of images e.g.
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
Definition: ImageBase.hh:382
color values, 3 channels, order: red,green,blue
Definition: ImageBase.hh:131
TFileFormat
format specifier when writing an image to a file Do NOT change order or associated enum value because...
Definition: ImageIO.hh:76
unsigned int GetHeight() const
Definition: ImageBase.hh:319
class BIASGeometry_EXPORT PMatrix
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
Definition: ImageIO.cpp:725
int Read(const std::string &filename)
main entry routine to read all EXIF tags from the header of image file.
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrixBase.hh:74
int GetFocalLengthXPixel(double &fp)
compute focallength in pixels
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
Definition: Image.hh:137
static std::string GetExtension(const BIAS::ImageIO::TFileFormat &fmt)
return the default extension for a given FileFormat enum
Definition: ImageIO.cpp:2499
int UpdateMetaData()
copy P_ and co.
Definition: Camera.cpp:446
int GetC(Vector3< double > &C)
computes translation vector origin world coo -&gt; origin camera coo (center), uses decomposition, which is cached
Definition: PMatrix.cpp:165
This class Param provides generic support for parameters.
Definition: Param.hh:231
contains all atribute info and values of e.g. a file.
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...
Definition: ImageIO.cpp:141
void InitExifTags()
initialize me vector with all known EXIF tags
static int Convert(BIAS::ImageBase &source, BIAS::ImageBase &dest, enum BIAS::ImageBase::EColorModel targetColorModel, bool bPlanar=false)
main general conversion function, calls desired specialized functions, always initializes the destIma...
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
Definition: KMatrix.hh:48
enum EStorageType GetStorageType() const
Definition: ImageBase.hh:414
(8bit) unsigned char image storage type
Definition: ImageBase.hh:112
int * AddParamInt(const std::string &name, const std::string &help, int deflt=0, int min=std::numeric_limits< int >::min(), int max=std::numeric_limits< int >::max(), char cmdshort=0, int Group=GRP_NOSHOW)
For all adding routines:
Definition: Param.cpp:276
static int ImportMatrix(const std::string &FileName, ImageBase &img, const bool verbose)
Import text images to BIAS.
Definition: ImageIO.cpp:1232
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrix.hh:88
void SetK(const KMatrix &K)
Definition: Camera.hh:173
static int WriteRAW_IMA(const std::string &FileName, const ImageBase &img_const)
Write image in binary file format needed by RealEyes.
Definition: ImageIO.cpp:1173
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
std::string * AddParamString(const std::string &name, const std::string &help, std::string deflt="", char cmdshort=0, int Group=GRP_NOSHOW)
Definition: Param.cpp:327
static int ToRGB(const Image< StorageType > &source, Image< StorageType > &dest)
Create a RGB converted copy of source image in this.
int ParseMetaData(bool bUse2x64bitTS=true)
After ImageIO::Load() operated on AppData_, this method fills P_, Timestamp, DC_*, ...
Definition: Camera.cpp:154
int GetFocalLengthYPixel(double &fp)
compute focallength in pixels
static void SetGlobalDebugLevel(long int lev)
Definition: Debug.hh:424
void SetIdentity()
set the elements of this matrix to the identity matrix (possibly overriding the inherited method) ...
Definition: Matrix3x3.hh:429
int GetK(KMatrix &K)
calibration matrix
Definition: PMatrix.cpp:220
static int ToGrey(const ImageBase &source, ImageBase &dest)
wrapper for the templated function ToGrey