Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleLogPolarMapping.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 /**
27  * @example ExampleLogPolarMapping.cpp
28  @relates LogPolarMapping
29  @brief transforms an image to the logarithmic polar mapping
30  @ingroup g_examples
31  @author oniemann
32 */
33 
34 #include <Image/LogPolarMapping.hh>
35 #include <Base/Image/ImageIO.hh>
36 #include <Base/Debug/TimeMeasure.hh>
37 #include <Utils/Param.hh>
38 
39 using namespace BIAS;
40 using namespace std;
41 
42 
43 int main(int argc, char *argv[])
44 {
45 
46  Param *param = new Param();
47  string sourceImage;
48 
49  param->AddParamString("SourceImage",
50  "Absolute path to the source Image",
51  "",
52  'i');
53 
54  param->ParseCommandLine(argc,argv);
55 
56  //Read and load source image from parameters
57  sourceImage = *param->GetParamString("SourceImage");
58  if(sourceImage == "")
59  {
60  BIASERR(argv[0]<<" -i<image-file>");
61  return -1;
62  }
63 
64 
66  if (ImageIO::Load(sourceImage, im)!=0){
67  BIASERR("error loading "<<sourceImage);
68  return -2;
69  }
70 
72  int width = im.GetWidth();
73  int height = im.GetHeight();
74  //We want the center of rotation to be in center of the image
75 
76  mapper.SetImageCenter(width,height/2);
77 
78  cout<<"ROI of source image is "<<*im.GetROI()
79  <<" while image size is "<<width<<" x "<<height<<endl;
81  imrestrilinear(2*width,height, im.GetChannelCount());
82  imrestrilinear.SetColorModel(im.GetColorModel());
83 
84  cout<<"timing ..."<<endl<<flush;
85  TimeMeasure t1;
86 
87  t1.Start();
88  // trilinear mapping with automatic scale and pyramid size selection
89  mapper.Map(im, imrestrilinear, MapBilinear);
90  t1.Stop();
91  //if (ImageIO::Save("ImgLogPolar.mip", imrestrilinear)!=0){
92  if (ImageIO::Save("ImgLogPolar.mip", imrestrilinear)!=0){
93  BIASERR("error image");
94  }
95 
96  cout <<"Trilinear mapping took "
97  <<t1.GetUserTime()
98  <<" ms,"<<endl;
99 
100  return 0;
101 }
Maps cartesian source coordinates to log-polar sink coordinates.
void SetColorModel(EColorModel Model)
Definition: ImageBase.hh:561
void SetImageCenter(const int &x, const int &y)
set your image center before calling Map().
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
ROI * GetROI()
Returns a pointer to the roi object.
Definition: ImageBase.hh:615
std::string * GetParamString(const std::string &name) const
Definition: Param.cpp:649
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
Definition: ImageBase.hh:382
unsigned int GetHeight() const
Definition: ImageBase.hh:319
int Map(const Image< InputStorageType > &src, Image< OutputStorageType > &sink, InterpolationMethod=MapTrilinear, bool newSink=false, double SuperSampling=1.0)
backward mapping with various interpolations
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
enum EColorModel GetColorModel() const
Definition: ImageBase.hh:407
This class Param provides generic support for parameters.
Definition: Param.hh:231
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
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
double GetUserTime() const
return user time (=system usage time) in msec JW For Win32: user-time is the sum over all processes o...
class TimeMeasure contains functions for timing real time and cpu time.
Definition: TimeMeasure.hh:111