OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
ossimBandMergeTool Class Reference

#include <ossimBandMergeTool.h>

Inheritance diagram for ossimBandMergeTool:
ossimChipProcTool ossimTool ossimProcessInterface ossimListenerManager ossimObject ossim::JsonInterface ossimReferenced

Public Member Functions

 ossimBandMergeTool ()
 
 ~ossimBandMergeTool ()
 
virtual void setUsage (ossimArgumentParser &ap)
 Initializes the aurgument parser with expected parameters and options. More...
 
virtual bool initialize (ossimArgumentParser &ap)
 Initial method to be ran prior to execute. More...
 
virtual void initialize (const ossimKeywordlist &kwl)
 This method is responsible for completely setting up the full processing chain according to the specifications given in the kwl passed in. More...
 
virtual ossimString getClassName () const
 
virtual void getKwlTemplate (ossimKeywordlist &kwl)
 Assigns a template keywordlist to string for initializing derived classes. More...
 
virtual bool execute ()
 Performs the actual product write. More...
 
- Public Member Functions inherited from ossimChipProcTool
 ossimChipProcTool ()
 default constructor More...
 
virtual ~ossimChipProcTool ()
 virtual destructor More...
 
virtual void clear ()
 Disconnects and clears the dem and image layers. More...
 
virtual void abort ()
 
virtual bool isChipProcessor () const
 Overrides base class implementation to indicate this class supports getChip() calls. More...
 
virtual ossimListenerManagergetManager ()
 
virtual ossimObjectgetObject ()
 
virtual const ossimObjectgetObject () const
 
virtual ossimRefPtr< ossimImageDatagetChip (const ossimIrect &img_rect)
 The meat and potatos of this class. More...
 
virtual ossimRefPtr< ossimImageDatagetChip (const ossimGrect &gnd_rect)
 
ossimRefPtr< ossimImageDatagetChip (const ossimDrect &map_bounding_rect, const ossimDpt &gsd)
 
ossimRefPtr< ossimImageDatagetChip ()
 Get chip method that assumes pre-initialized state. More...
 
const ossimFilenamegetProductFilename () const
 
- Public Member Functions inherited from ossimTool
 ossimTool ()
 
virtual ~ossimTool ()
 
virtual void loadJSON (const Json::Value &json_request)
 Reads processing params from JSON object provided. More...
 
virtual void saveJSON (Json::Value &json) const
 Fetch product as JSON object when applicable Always returns true since using exception on error. More...
 
virtual const std::string & getResponse () const
 Fetch product as string (typically JSON) when applicable, otherwise passes back empty string. More...
 
void getAPI (std::string &out) const
 Outputs a JSON representation of the Utility's API. More...
 
std::string getAPI () const
 
void getBuildDate (std::string &s) const
 Gets build date. More...
 
void getRevision (std::string &s) const
 Gets revision. More...
 
void getVersion (std::string &s) const
 Gets version. More...
 
void setOutputStream (std::ostream *os)
 Redirects any console output to the supplied stream for logging or JNI application. More...
 
bool helpRequested () const
 Returns true when the initialization detects a "--help" option, so caller can avoid subsequent execute() call. More...
 
- Public Member Functions inherited from ossimObject
 ossimObject ()
 
virtual ~ossimObject ()
 
virtual ossimObjectdup () const
 
virtual ossimString getShortName () const
 
virtual ossimString getLongName () const
 
virtual ossimString getDescription () const
 
virtual RTTItypeid getType () const
 
virtual bool canCastTo (ossimObject *obj) const
 
virtual bool canCastTo (const RTTItypeid &id) const
 
virtual bool canCastTo (const ossimString &parentClassName) const
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual std::ostream & print (std::ostream &out) const
 Generic print method. More...
 
virtual bool isEqualTo (const ossimObject &obj, ossimCompareType compareType=OSSIM_COMPARE_FULL) const
 
virtual void accept (ossimVisitor &visitor)
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 
- Public Member Functions inherited from ossim::JsonInterface
 JsonInterface ()
 
virtual ~JsonInterface ()
 
- Public Member Functions inherited from ossimProcessInterface
 ossimProcessInterface ()
 
virtual ~ossimProcessInterface ()
 
bool needsAborting () const
 
bool isAbortRequested () const
 
bool isAborted () const
 
bool isExecuting () const
 
ossimProcessStatus getProcessStatus () const
 
virtual void setProcessStatus (ossimProcessStatus processStatus)
 
virtual double getPercentComplete () const
 
virtual void setPercentComplete (double percentComplete)
 
void enableEvents ()
 
void disableEvents ()
 
void setCurrentMessage (const ossimString &message)
 
virtual std::ostream & print (std::ostream &out) const
 
- Public Member Functions inherited from ossimListenerManager
 ossimListenerManager ()
 
virtual ~ossimListenerManager ()
 
virtual void fireEvent (ossimEvent &event)
 
virtual bool addListener (ossimListener *listener)
 
virtual bool removeListener (ossimListener *listener)
 
virtual bool findListener (ossimListener *listener)
 

Static Public Attributes

static const char * DESCRIPTION
 Used by ossimUtilityFactory. More...
 

Protected Member Functions

virtual void initProcessingChain ()
 Derived classes initialize their custom chains here. More...
 
virtual void initHistogramStretch (ossimSingleImageChain *image)
 
- Protected Member Functions inherited from ossimChipProcTool
void processRemainingArgs (ossimArgumentParser &ap)
 Intended to be called after derived class has picked off its own options from the parser, and arguments remain (such as input and output filenames). More...
 
virtual void finalizeChain ()
 Called after initProcessingChain() to append common items to the processing chain. More...
 
virtual void loadImageFiles ()
 Creates chains for image entries associated with specified keyword. More...
 
virtual void loadDemFiles ()
 Loads all DEM files specified in master KWL into the elev manager's database. More...
 
ossimRefPtr< ossimSingleImageChaincreateInputChain (const ossimFilename &image_file, ossim_uint32 entry_index=0)
 Creates the ossimSingleImageChain from image filename and populates the chain with resampler and product output projection on view-side of resampler's IVT. More...
 
void createOutputProjection ()
 Creates the output or view projection. More...
 
ossimRefPtr< ossimMapProjectionnewIdentityProjection ()
 Sets the single image chain for identity operations view to a ossimImageViewAffineTransform. More...
 
ossimRefPtr< ossimMapProjectionnewUtmProjection ()
 Convenience method to get a utm projection. More...
 
virtual void initializeProjectionGsd ()
 Initializes the projection gsd. More...
 
virtual void initializeAOI ()
 Initializes m_aoiViewRect with the output area of interest as specified in master KWL. More...
 
bool getProjectionOrigin (ossimGpt &gpt)
 Reads the KWL for origin latitude and central meridian. More...
 
ossimRefPtr< ossimImageFileWriternewWriter ()
 Creates a new writer. More...
 
void propagateGeometryToChains ()
 Loops through all chains and sets the output projection. More...
 
ossimRefPtr< ossimImageSourcecombineLayers (std::vector< ossimRefPtr< ossimSingleImageChain > > &layers) const
 When multiple input sources are present, this method instantiates a combiner and adds inputs. More...
 
void computeAdjustedViewFromGrect ()
 Initializes m_aoiViewRect given m_aoiGroundRect. More...
 
void setAoiToInputs ()
 Assigns the AOI to be the bounding rect of the union of all inputs. More...
 
void getBandList (ossim_uint32 image_idx, std::vector< ossim_uint32 > &bandList) const
 Gets the band list if BANDS keyword is set. More...
 
void setReaderProps (ossimImageHandler *ih) const
 Passes reader properties to single image handler if any. More...
 
 ossimChipProcTool (const ossimChipProcTool &obj)
 Hidden from use copy constructor. More...
 
const ossimChipProcTooloperator= (const ossimChipProcTool &)
 Hidden from use assignment operator. More...
 
ossimRefPtr< ossimGeoPolygoncreateClipPolygon () const
 
void findCenterGpt (ossimGpt &gpt)
 Tries to determine the AOI center point based on KWL entries, else returns NaNs in gpt. More...
 
ossimRefPtr< ossimImageSourcemosaicDemSources ()
 Some utilities need to work on DEMs as images. More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Member Functions inherited from ossimListenerManager
 ossimListenerManager (const ossimListenerManager &rhs)
 

Protected Attributes

bool m_stretchProduct
 
- Protected Attributes inherited from ossimChipProcTool
ossimRefPtr< ossimImageGeometrym_geom
 
ossimIrect m_aoiViewRect
 
ossimGrect m_aoiGroundRect
 
std::vector< ossimRefPtr< ossimSingleImageChain > > m_imgLayers
 
std::vector< ossimFilenamem_demSources
 
ossimRefPtr< ossimImageFileWriterm_writer
 
ossimRefPtr< ossimImageChainm_procChain
 
ossimRefPtr< ossimRectangleCutFilterm_cutRectFilter
 
bool m_projIsIdentity
 
ossimDpt m_gsd
 
bool m_geoScaled
 
ossimFilename m_productFilename
 
ossimScalarType m_productScalarType
 
bool m_needCutRect
 
- Protected Attributes inherited from ossimTool
ossimKeywordlist m_kwl
 
std::ostream * m_consoleStream
 
bool m_helpRequested
 
std::string m_response
 
- Protected Attributes inherited from ossimProcessInterface
double thePercentComplete
 
ossimProcessStatus theProcessStatus
 
ossimString theMessage
 
bool theEventFlag
 
- Protected Attributes inherited from ossimListenerManager
std::list< ossimListener * > theListenerList
 
bool theEnabledFlag
 
std::list< ossimListener * > theDelayedAdd
 
std::list< ossimListener * > theDelayedRemove
 
bool theFireEventFlag
 

Additional Inherited Members

- Public Types inherited from ossimProcessInterface
enum  ossimProcessStatus {
  PROCESS_STATUS_UNKNOWN = 0, PROCESS_STATUS_EXECUTING = 1, PROCESS_STATUS_ABORTED = 2, PROCESS_STATUS_ABORT_REQUEST = 3,
  PROCESS_STATUS_NOT_EXECUTING = 4
}
 

Detailed Description

Class for determining the active image corner vertices inside larger null-filled image rectangle.

Definition at line 18 of file ossimBandMergeTool.h.

Constructor & Destructor Documentation

◆ ossimBandMergeTool()

ossimBandMergeTool::ossimBandMergeTool ( )

Definition at line 29 of file ossimBandMergeTool.cpp.

30 : m_stretchProduct(false)
31 {
32 }

◆ ~ossimBandMergeTool()

ossimBandMergeTool::~ossimBandMergeTool ( )

Definition at line 34 of file ossimBandMergeTool.cpp.

35 {
36 }

Member Function Documentation

◆ execute()

bool ossimBandMergeTool::execute ( )
virtual

Performs the actual product write.

Note
Throws ossimException on error.

Reimplemented from ossimChipProcTool.

Definition at line 166 of file ossimBandMergeTool.cpp.

References ossimChipProcTool::execute().

167 {
169 }
virtual bool execute()
Performs the actual product write.

◆ getClassName()

virtual ossimString ossimBandMergeTool::getClassName ( ) const
inlinevirtual

Reimplemented from ossimTool.

Definition at line 30 of file ossimBandMergeTool.h.

30 { return "ossimBandMergeUtil"; }

◆ getKwlTemplate()

void ossimBandMergeTool::getKwlTemplate ( ossimKeywordlist kwl)
virtual

Assigns a template keywordlist to string for initializing derived classes.

Reimplemented from ossimTool.

Definition at line 171 of file ossimBandMergeTool.cpp.

References ossimKeywordlist::add(), ossimString::chars(), ossimTool::getKwlTemplate(), and ossimKeywordNames::IMAGE_FILE_KW.

172 {
174 
176  ossimString key = keybase + "0";
177  kwl.add(key.chars(), "<red-band>", true);
178  key = keybase + "1";
179  kwl.add(key.chars(), "<green-band>", true);
180  key = keybase + "2";
181  kwl.add(key.chars(), "<blue-band>", true);
182 
183  kwl.add(HISTO_STRETCH_KW.c_str(), "true|false", true);
184 }
virtual void getKwlTemplate(ossimKeywordlist &kwl)
Assigns a template keywordlist to string for initializing derived classes.
Definition: ossimTool.cpp:100
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
const char * chars() const
For backward compatibility.
Definition: ossimString.h:77
static const char * IMAGE_FILE_KW

◆ initHistogramStretch()

void ossimBandMergeTool::initHistogramStretch ( ossimSingleImageChain image)
protectedvirtual

Definition at line 140 of file ossimBandMergeTool.cpp.

References ossimImageChain::add(), ossimRefPtr< T >::get(), ossimSingleImageChain::getImageHandler(), ossimImageHandler::getImageHistogram(), ossimHistogramRemapper::LINEAR_AUTO_MIN_MAX, ossimSource::setEnableFlag(), ossimHistogramRemapper::setHistogram(), ossimHistogramRemapper::setStretchMode(), and ossimRefPtr< T >::valid().

Referenced by initProcessingChain().

141 {
142  ostringstream errMsg;
143 
144  // Check if this image already has a histogram file associated with it:
146  if (!handler.valid())
147  {
148  errMsg<<"ERROR ossimBandMergeUtil:"<<__LINE__<<" Bad handler returned for image chain.";
149  throw ossimException(errMsg.str());
150  }
151 
153  if (!histogram.valid())
154  {
155  errMsg<<"ERROR ossimBandMergeUtil:"<<__LINE__<<" Bad histogram returned from image handler.";
156  throw ossimException(errMsg.str());
157  }
158 
160  histogramRemapper->setEnableFlag(true);
162  histogramRemapper->setHistogram(histogram);
163  image->add(histogramRemapper.get());
164 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
ossimRefPtr< const ossimImageHandler > getImageHandler() const
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimMultiResLevelHistogram > getImageHistogram() const
Fetches the current entry image&#39;s histogram.
void setStretchMode(StretchMode mode, bool rebuildTableFlag=false)
Sets remap mode to mode.
virtual bool add(ossimConnectableObject *source)
Will return true or false if an image source was added to the chain.
virtual void setEnableFlag(bool flag)
Definition: ossimSource.cpp:99
void setHistogram(ossimRefPtr< ossimMultiResLevelHistogram > histogram)
Sets the histogram.

◆ initialize() [1/2]

bool ossimBandMergeTool::initialize ( ossimArgumentParser ap)
virtual

Initial method to be ran prior to execute.

Intended for command-line app usage.

Parameters
apArg parser to initialize from.
Returns
FALSE if –help option requested or no params provided, so that derived classes can
Note
Throws ossimException on error.
A throw with an error message of "usage" is used to get out when a usage is printed.

Reimplemented from ossimChipProcTool.

Definition at line 58 of file ossimBandMergeTool.cpp.

References ossimKeywordlist::addPair(), ossimKeywordNames::IMAGE_FILE_KW, ossimChipProcTool::initialize(), ossimTool::m_helpRequested, ossimTool::m_kwl, ossimNotify(), ossimNotifyLevel_NOTICE, and ossimArgumentParser::read().

59 {
61  return false;
62  if (m_helpRequested)
63  return true;
64 
65  ostringstream xmsg;
66 
67  std::string ts1;
69  int band_count = 0;
70 
71  if ( ap.read("--red", sp1))
72  {
73  ostringstream key;
75  m_kwl.addPair( key.str(), ts1 );
76  ++band_count;
77  }
78  if ( ap.read("--green", sp1))
79  {
80  ostringstream key;
82  m_kwl.addPair( key.str(), ts1 );
83  ++band_count;
84  }
85  if ( ap.read("--blue", sp1))
86  {
87  ostringstream key;
89  m_kwl.addPair( key.str(), ts1 );
90  ++band_count;
91  }
92  if (band_count != 3)
93  {
94  ossimNotify(ossimNotifyLevel_NOTICE)<<"ossimBandMergeUtil:"<<__LINE__
95  <<" Must supply three band filenames."<<endl;
96  return false;
97  }
98 
99  if ( ap.read("--stretch"))
100  {
101  m_kwl.addPair(HISTO_STRETCH_KW, string("true") );
102  }
103 
105  return true;
106 }
virtual bool initialize(ossimArgumentParser &ap)
Initial method to be ran prior to execute.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
bool m_helpRequested
Definition: ossimTool.h:150
bool read(const std::string &str)
search for an occurance of a string in the argument list, on sucess remove that occurance from the li...
ossimKeywordlist m_kwl
Definition: ossimTool.h:148
void addPair(const std::string &key, const std::string &value, bool overwrite=true)
void processRemainingArgs(ossimArgumentParser &ap)
Intended to be called after derived class has picked off its own options from the parser...
static const char * IMAGE_FILE_KW
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ initialize() [2/2]

void ossimBandMergeTool::initialize ( const ossimKeywordlist kwl)
virtual

This method is responsible for completely setting up the full processing chain according to the specifications given in the kwl passed in.

If the utility is run from a command line, the initialize(ossimArgumentParser) will assign the member master KWL and pass it to this method. Web service calls will fill a KWL and pass it.

This base class implementation should be called by the derived class implementation (assuming the derived class needs to pull some parameters out of the KWL before the chains are set up.

This method will instantiate the output projection and define the output bounding rect and product size in pixels. The processing chain (stored in m_procChain) will be completely initialized and ready for calls to getTile(). Then either getChip() or execute() can be called depending on usage to fetch product.

Note
Throws ossimException on error.

Reimplemented from ossimChipProcTool.

Definition at line 108 of file ossimBandMergeTool.cpp.

References ossimKeywordlist::getBoolKeywordValue(), and m_stretchProduct.

109 {
110  kwl.getBoolKeywordValue(m_stretchProduct, HISTO_STRETCH_KW.c_str());
111 
112  m_kwl.add( ossimKeywordNames::PROJECTION_KW, "input", false );
114 }
virtual bool initialize(ossimArgumentParser &ap)
Initial method to be ran prior to execute.
static const char * PROJECTION_KW
ossimKeywordlist m_kwl
Definition: ossimTool.h:148
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
bool getBoolKeywordValue(bool &rtn_val, const char *keyword, const char *prefix=0) const
[OLK, Aug/2008] Sets the boolean <rtn_val> depending on value associated with keyword for values = (y...

◆ initProcessingChain()

void ossimBandMergeTool::initProcessingChain ( )
protectedvirtual

Derived classes initialize their custom chains here.

Implements ossimChipProcTool.

Definition at line 116 of file ossimBandMergeTool.cpp.

References ossimImageChain::add(), ossimRefPtr< T >::get(), initHistogramStretch(), ossimChipProcTool::m_imgLayers, ossimChipProcTool::m_procChain, and m_stretchProduct.

117 {
118  if (m_imgLayers.size() != 3)
119  {
120  ostringstream errMsg;
121  errMsg<<"ERROR ossimBandMergeUtil:"<<__LINE__<<" Expected 3 input layers but found "
122  <<m_imgLayers.size() <<". Cannot continue. "<<ends;
123  throw ossimException(errMsg.str());
124  }
125 
127  for (int band=0; band<3; band++)
128  {
129  ossimSingleImageChain* band_image = m_imgLayers[band].get();
130  bandList.push_back(band_image);
131 
132  // If performing histo stretch, try using existing histogram files before creating new ones:
133  if (m_stretchProduct)
134  initHistogramStretch(band_image);
135  }
137  m_procChain->add(combiner.get());
138 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
virtual void initHistogramStretch(ossimSingleImageChain *image)
Single image chain class.
ossimRefPtr< ossimImageChain > m_procChain
std::vector< ossimRefPtr< ossimConnectableObject > > ConnectableObjectList
std::vector< ossimRefPtr< ossimSingleImageChain > > m_imgLayers
virtual bool add(ossimConnectableObject *source)
Will return true or false if an image source was added to the chain.

◆ setUsage()

void ossimBandMergeTool::setUsage ( ossimArgumentParser ap)
virtual

Initializes the aurgument parser with expected parameters and options.

It does not output anything. To see the usage, the caller will need to do something like:

ap.getApplicationUsage()->write(<ostream>);

This base class has some common arguments to add. The derived class should call this implementation in addition to setting its own arguments.

Reimplemented from ossimChipProcTool.

Definition at line 38 of file ossimBandMergeTool.cpp.

References ossimApplicationUsage::addCommandLineOption(), DESCRIPTION, ossimArgumentParser::getApplicationName(), ossimArgumentParser::getApplicationUsage(), ossimApplicationUsage::setCommandLineUsage(), ossimApplicationUsage::setDescription(), and ossimChipProcTool::setUsage().

39 {
40  // Add options.
42  ossimString usageString = ap.getApplicationName();
43  usageString += " bandmerge --red <red_band> --green <green_band> --blue <blue_band> [--stretch] <output-rgb-image>";
44  au->setCommandLineUsage(usageString);
45 
46  // Set the command line options:
48 
49  // Base class has its own:
51 
52  au->addCommandLineOption("--red", "<filename> Filename of red band. ");
53  au->addCommandLineOption("--green", "<filename> Filename of green band. ");
54  au->addCommandLineOption("--blue", "<filename> Filename of blue band. ");
55  au->addCommandLineOption("--stretch", "Optionally histogram-stretch the product image. ");
56 }
std::string getApplicationName() const
return the application name, as specified by argv[0]
void addCommandLineOption(const ossimString &option, const ossimString &explanation)
static const char * DESCRIPTION
Used by ossimUtilityFactory.
void setCommandLineUsage(const ossimString &explanation)
ossimApplicationUsage * getApplicationUsage()
virtual void setUsage(ossimArgumentParser &ap)
Initializes the aurgument parser with expected parameters and options.
void setDescription(const ossimString &desc)

Member Data Documentation

◆ DESCRIPTION

const char * ossimBandMergeTool::DESCRIPTION
static
Initial value:
=
"Merges multiple band files into a single RGB image."

Used by ossimUtilityFactory.

Definition at line 37 of file ossimBandMergeTool.h.

Referenced by ossimToolFactory::getCapabilities(), and setUsage().

◆ m_stretchProduct

bool ossimBandMergeTool::m_stretchProduct
protected

Definition at line 43 of file ossimBandMergeTool.h.

Referenced by initialize(), and initProcessingChain().


The documentation for this class was generated from the following files: