Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleImageLoad.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  @example ExampleImageLoad.cpp
26  @relates ImageIO
27  @brief Load an arbitrary format from disk trying all availbale libraries.
28  @ingroup g_examples
29  @author woetzel
30 */
31 
32 //#include <Base/Common/LeakChecking.h>
33 #include <Base/Image/ImageBase.hh>
34 #include <Base/Image/ImageIO.hh>
35 
36 using namespace BIAS;
37 using namespace std;
38 
39 int main(int argc, char *argv[])
40 {
41  if (argc!=2){
42  cout<<"no image given\nusage: "<<argv[0]<<" <image-file>"<<endl;
43  return -1;
44  }
45 
46  ImageBase im;
47  int result = ImageIO::Load(argv[1], im);
48  if (result!=0){
49  BIASERR("error loading \n"<<argv[1]<<" with result="<<result);
50  return result; // for Dart testing
51  }
52 
53  //im.Display("im",true,false,true,1000);
54 
55  // OK, display some info about the succesfully loaded image:
56  cout<<"successfully loaded \n"<<argv[1]<<" "<<endl
57  <<im.GetWidth()<<"x"<<im.GetHeight()<<" pixel, "
58  <<im.GetChannelCount()<<" channels, "
59  <<" @"<<im.GetBitDepth()<<"bit ("<<im.GetDepth()<<"Byte)"
60  <<endl;
61 
62  cout<<"UID "<<im.GetUID()<<" ";
63  if (!im.GetUID().IsValid())
64  cout<<"invalid! ";
65  else
66  cout<<"valid ";
67  if (!im.GetUID().IsNil())
68  cout<<"(IsNil) ";
69 
70  cout<<endl;
71 
72  //if (ImageIO::Save("out_image.mip", im, false, !im.GetUID().IsValid())!=0){
73  // BIASERR("error writing out_image.mip");
74  // return 0; // for Dart testing
75  //}
76 
77  cout<<"done."<<endl;
78  return 0;
79 }
unsigned int GetDepth() const
returns the bytes per channel, which is the sizeof(StorageType) Should match GetSizeDepth(GetStorageT...
Definition: ImageBase.hh:328
bool IsNil() const
Definition: UUID.cpp:108
unsigned int GetWidth() const
Definition: ImageBase.hh:312
unsigned int GetBitDepth() const
returns the bits per channel Is not necessairily 8*sizeof(StorageType), could be fewer bits...
Definition: ImageBase.hh:344
const BIAS::UUID & GetUID() const
returns the UUID of the image
Definition: ImageBase.hh:449
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
Definition: ImageBase.hh:382
unsigned int GetHeight() const
Definition: ImageBase.hh:319
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
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
bool IsValid() const
checks whether this uuid is valid(true) or unitialized(false)
Definition: UUID.hh:210