OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Functions
image_open.cpp File Reference
#include <iostream>
#include "base/common/ossimCommon.h"
#include "base/data_types/ossimFilename.h"
#include "base/misc/lookup_tables/ossimScalarTypeLut.h"
#include "imaging/factory/ossimImageHandlerRegistry.h"
#include "imaging/formats/ossimImageHandler.h"
#include "init/ossimInit.h"

Go to the source code of this file.

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 50 of file image_open.cpp.

References ossimInit::finalize(), ossimImageHandler::getBoundingRect(), ossimObject::getClassName(), ossimLookUpTable::getEntryString(), ossimImageHandler::getFilename(), ossimImageHandler::getNumberOfDecimationLevels(), ossimImageSource::getOutputScalarType(), ossimIrect::height(), ossimInit::initialize(), ossimScalarTypeLut::instance(), ossimInit::instance(), ossimImageHandlerRegistry::instance(), ossimImageHandlerRegistry::open(), and ossimIrect::width().

51 {
52  ossimInit::instance()->initialize(argc, argv);
53 
54  if(argc == 2)
55  {
56  // call the registries open and let it traverse through all registered
57  // factories to open up an image.
58  //
60 
61  if(handler)
62  {
63  // includes full resolution so if there are no overviews this value should be
64  // 1. Note: resolution levels or overviews or indexed from 0 being full
65  // resolution to (number of decimations or overviews -1..
66  //
67  // Overviews are very import for resampling images to different resolutions efficiently.
68  // The overviews are generally power of 2 decimations. Assume we have an image that has
69  // full resolution of 1024x1024 in size. When we are talking about resolution 0 then
70  // we are talking about the full res 1024x1024, but when we are talking
71  // about resolution level 1 then we are looking at the start of the overview and referes to
72  // a decimation of 2^1 which is 512x512 image. So when we ask for resolution level N then
73  // we are talking about a decimation of 2^N
74  //
75  // So again, when we query the number of decimation levels this includes resolution layer 0.
76  //
77  int overviews = handler->getNumberOfDecimationLevels();
78 
79  // the image bounds can take an argument to specify which resolution I would like to get
80  // the bounding rect of. By default if no argument is given it assumes full resolution or
81  // resolution 0.
82  //
83  ossimIrect bounds = handler->getBoundingRect(0);
84 
85 
86  // scalar type cooresponds to the pixel radiometry type. The pixel can be of precision
87  // float, double, unsigned char, unsigned short, signed short data values. Look at
88  // ossimScalarType enumeration found in base/common/ossimConstants.h for supporting types
89  //
90  ossimScalarType scalarType = handler->getOutputScalarType();
91 
92  // This is a utility class that maps enumeration values to strings. So we will use this
93  // when we query the scalar type from the image and wish to print the text version of it.
94  //
95  //
97 
98  cout <<"filename = " << handler->getFilename() << endl
99  << "width = " << bounds.width() << endl
100  << "height = " << bounds.height() << endl
101  << "overview count = " << (overviews-1) << endl
102  << "scalar type = " << lut->getEntryString(handler->getOutputScalarType()) << endl
103 
104  // ossimGetScalarSizeInBytes is a utility functions found in base/common/ossimCommon.h
105  // it will return the byte size of the scalar type.
106  //
107  << "pixel size = " << ossimGetScalarSizeInBytes(scalarType) << " byte(s)" <<endl
108  << "Handler used = " << handler->getClassName() << endl;
109 
110  delete handler;
111  }
112  else
113  {
114  cout << "Unable to open image = " << argv[1] << endl;
115  }
116  }
117  else
118  {
119  cout << "usage: open_image <file name>" << endl;
120  }
121 
122  // call the finalize so the ossim can cleanup if needed.
124 
125  return 0;
126 }
void initialize(int &argc, char **argv)
Definition: ossimInit.cpp:119
virtual ossimImageHandler * open(const ossimFilename &fileName, bool trySuffixFirst=true, bool openOverview=true) const
open that takes a filename.
virtual ossimString getEntryString(ossim_int32 entry_number) const
ossim_uint32 height() const
Definition: ossimIrect.h:487
virtual ossimString getClassName() const
Definition: ossimObject.cpp:64
void finalize()
Definition: ossimInit.cpp:261
virtual ossim_uint32 getNumberOfDecimationLevels() const
This returns the total number of decimation levels.
static ossimScalarTypeLut * instance()
Returns the static instance of an ossimScalarTypeLut object.
virtual const ossimFilename & getFilename() const
Returns the filename.
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossimScalarType
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
Used to convert from scalar type enumeration to strings and vice versa.
This class defines an abstract Handler which all image handlers(loaders) should derive from...
static ossimInit * instance()
Definition: ossimInit.cpp:89
static ossimImageHandlerRegistry * instance()
virtual ossimIrect getBoundingRect(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.