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

#include <ossimOverviewSequencer.h>

Inheritance diagram for ossimOverviewSequencer:
ossimReferenced ossimErrorStatusInterface ossimMpiMasterOverviewSequencer ossimMpiSlaveOverviewSequencer

Public Member Functions

 ossimOverviewSequencer ()
 default constructor More...
 
ossim_uint32 getNumberOfTiles () const
 
ossim_uint32 getNumberOfTilesHorizontal () const
 
ossim_uint32 getNumberOfTilesVertical () const
 
virtual void getOutputImageRectangle (ossimIrect &rect) const
 Gets the zero-based image rectangle for the output reduced resolution data set (rrds). More...
 
void setImageHandler (ossimImageHandler *input)
 Sets the input source or connection. More...
 
void setBitMaskObjects (ossimBitMaskWriter *mask_writer, ossimMaskFilter *mask_filter)
 Enabled the generation of an alpha (bit) mask such that any full or partial null pixels will be masked out. More...
 
void setSourceLevel (ossim_uint32 level)
 Sets the input source resolution to decimate from. More...
 
ossimHistogramMode getHistogramMode () const
 Gets the histogram accumulation mode. More...
 
void setHistogramMode (ossimHistogramMode mode)
 Sets the histogram accumulation mode. More...
 
void writeHistogram ()
 Write histogram method. More...
 
void writeHistogram (const ossimFilename &file)
 Write histogram method that takes a file name. More...
 
virtual void initialize ()
 This must be called. More...
 
virtual void setToStartOfSequence ()
 Will set the internal pointers to the upperleft tile number. More...
 
virtual ossimRefPtr< ossimImageDatagetNextTile ()
 Will allow you to get the next tile in the sequence. More...
 
virtual void slaveProcessTiles ()
 This implementation does nothing. More...
 
virtual bool isMaster () const
 
ossimIpt getTileSize () const
 
void setTileSize (const ossimIpt &pt)
 updated the tile size. More...
 
void setResampleType (ossimFilterResampler::ossimFilterResamplerType resampleType)
 Sets the resampling type. More...
 
void setScanForMinMax (bool flag)
 Turn on/off scan for min max flag. More...
 
bool getScanForMinMax () const
 
void setScanForMinMaxNull (bool flag)
 Turn on/off scan for min, max, null flag. More...
 
bool getScanForMinMaxNull () const
 
bool writeOmdFile (const std::string &file)
 Writes an ossim metadata(omd) file with min, max, null values. More...
 
- 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 ossimErrorStatusInterface
 ossimErrorStatusInterface ()
 
virtual ~ossimErrorStatusInterface ()
 
virtual ossimErrorCode getErrorStatus () const
 
virtual ossimString getErrorStatusString () const
 
virtual void setErrorStatus (ossimErrorCode error_status) const
 
virtual void setErrorStatus () const
 
virtual void clearErrorStatus () const
 
bool hasError () const
 
virtual std::ostream & print (std::ostream &out) const
 Outputs theErrorStatus as an ossimErrorCode and an ossimString. More...
 

Protected Member Functions

virtual ~ossimOverviewSequencer ()
 virtual destructor More...
 
void getInputTileRectangle (ossimIrect &inputRect) const
 Gets the image rectangle for the input tile for theCurrentTileNumber. More...
 
void getOutputTileRectangle (ossimIrect &outputRect) const
 Gets the image rectangle for the output tile for theCurrentTileNumber. More...
 
void updateTileDimensions ()
 Updates theNumberOfTilesHorizontal and theNumberOfTilesVertical. More...
 
void resampleTile (const ossimImageData *inputTile)
 Resamples a patch of data. More...
 
template<class T >
void resampleTile (const ossimImageData *inputTile, T dummy)
 
void clearMinMaxNullArrays ()
 Clears out the arrays from a scan for min, max, nulls. More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

ossimRefPtr< ossimImageHandlerm_imageHandler
 
ossimRefPtr< ossimBitMaskWriterm_maskWriter
 
ossimRefPtr< ossimMaskFilterm_maskFilter
 
ossimRefPtr< ossimImageDatam_tile
 
ossimIrect m_areaOfInterest
 
ossimIpt m_tileSize
 
ossim_uint32 m_numberOfTilesHorizontal
 
ossim_uint32 m_numberOfTilesVertical
 
ossim_uint32 m_currentTileNumber
 
ossim_uint32 m_sourceResLevel
 This is the resolution level to build overviews from. More...
 
bool m_dirtyFlag
 Dirty flag - if true, this object is not initialized. More...
 
ossim_int32 m_decimationFactor
 TODO make this handle any decimation. More...
 
ossimFilterResampler::ossimFilterResamplerType m_resampleType
 Currently only handles NEAREST_NEIGHBOR and BOX (default = BOX) More...
 
ossimRefPtr< ossimMultiBandHistogramm_histogram
 
ossimHistogramMode m_histoMode
 
ossim_uint32 m_histoTileIndex
 Used to determine which tiles to accumulate a histogram from. More...
 
bool m_scanForMinMax
 Control flags for min, max, null scanning. More...
 
bool m_scanForMinMaxNull
 
std::vector< ossim_float64m_minValues
 Arrays o hold the min value for each band for scan min/max methods. More...
 
std::vector< ossim_float64m_maxValues
 
std::vector< ossim_float64m_nulValues
 
- Protected Attributes inherited from ossimErrorStatusInterface
ossimErrorCode theErrorStatus
 

Detailed Description

Definition at line 30 of file ossimOverviewSequencer.h.

Constructor & Destructor Documentation

◆ ossimOverviewSequencer()

ossimOverviewSequencer::ossimOverviewSequencer ( )

default constructor

Definition at line 31 of file ossimOverviewSequencer.cpp.

References m_areaOfInterest, and ossimIrect::makeNan().

32  :
35  m_imageHandler(0),
36  m_maskWriter(0),
37  m_maskFilter(0),
38  m_tile(0),
45  m_dirtyFlag(true),
48  m_histogram(0),
51  m_scanForMinMax(false),
52  m_scanForMinMaxNull(false),
53  m_minValues(0),
54  m_maxValues(0),
55  m_nulValues(0)
56 {
58 
59  if (traceDebug())
60  {
62  << "ossimOverviewSequencer::ossimOverviewSequencer entered..."
63  << "\nmpi rank: "<< ossimMpi::instance()->getRank()
64  << std::endl;
65 #ifdef OSSIM_ID_ENABLED
66  ossimNotify(ossimNotifyLevel_DEBUG)<< "OSSIM_ID: " << OSSIM_ID
67  << std::endl;
68 #endif
69  }
70 }
std::vector< ossim_float64 > m_maxValues
ossim_int32 m_decimationFactor
TODO make this handle any decimation.
ossim_uint32 m_histoTileIndex
Used to determine which tiles to accumulate a histogram from.
ossimRefPtr< ossimImageData > m_tile
ossimRefPtr< ossimImageHandler > m_imageHandler
ossimRefPtr< ossimBitMaskWriter > m_maskWriter
std::vector< ossim_float64 > m_nulValues
std::vector< ossim_float64 > m_minValues
Arrays o hold the min value for each band for scan min/max methods.
#define OSSIM_DEFAULT_TILE_WIDTH
ossimFilterResampler::ossimFilterResamplerType m_resampleType
Currently only handles NEAREST_NEIGHBOR and BOX (default = BOX)
bool m_dirtyFlag
Dirty flag - if true, this object is not initialized.
ossimRefPtr< ossimMaskFilter > m_maskFilter
bool m_scanForMinMax
Control flags for min, max, null scanning.
ossimRefPtr< ossimMultiBandHistogram > m_histogram
ossim_uint32 m_sourceResLevel
This is the resolution level to build overviews from.
int getRank() const
Definition: ossimMpi.cpp:140
void makeNan()
Definition: ossimIrect.h:329
#define OSSIM_DEFAULT_TILE_HEIGHT
ossimHistogramMode m_histoMode
static ossimMpi * instance()
Definition: ossimMpi.cpp:27
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ ~ossimOverviewSequencer()

ossimOverviewSequencer::~ossimOverviewSequencer ( )
protectedvirtual

virtual destructor

Definition at line 72 of file ossimOverviewSequencer.cpp.

References m_histogram, m_imageHandler, m_maskFilter, m_maskWriter, and m_tile.

73 {
74  m_imageHandler = 0;
75  m_maskFilter = 0;
76  m_maskWriter = 0;
77  m_tile = 0;
78  m_histogram = 0;
79 
80  if (traceDebug())
81  {
83  << "ossimOverviewSequencer::~ossimOverviewSequencer entered..."
84  << "\nmpi rank: " << ossimMpi::instance()->getRank()
85  << std::endl;
86  }
87 }
ossimRefPtr< ossimImageData > m_tile
ossimRefPtr< ossimImageHandler > m_imageHandler
ossimRefPtr< ossimBitMaskWriter > m_maskWriter
ossimRefPtr< ossimMaskFilter > m_maskFilter
ossimRefPtr< ossimMultiBandHistogram > m_histogram
int getRank() const
Definition: ossimMpi.cpp:140
static ossimMpi * instance()
Definition: ossimMpi.cpp:27
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

Member Function Documentation

◆ clearMinMaxNullArrays()

void ossimOverviewSequencer::clearMinMaxNullArrays ( )
protected

Clears out the arrays from a scan for min, max, nulls.

Definition at line 457 of file ossimOverviewSequencer.cpp.

References m_maxValues, m_minValues, and m_nulValues.

458 {
459  m_minValues.clear();
460  m_maxValues.clear();
461  m_nulValues.clear();
462 }
std::vector< ossim_float64 > m_maxValues
std::vector< ossim_float64 > m_nulValues
std::vector< ossim_float64 > m_minValues
Arrays o hold the min value for each band for scan min/max methods.

◆ getHistogramMode()

ossimHistogramMode ossimOverviewSequencer::getHistogramMode ( ) const

Gets the histogram accumulation mode.

Returns
mode UNKNOWN, NORMAL or FAST.

Definition at line 151 of file ossimOverviewSequencer.cpp.

References m_histoMode.

152 {
153  return m_histoMode;
154 }
ossimHistogramMode m_histoMode

◆ getInputTileRectangle()

void ossimOverviewSequencer::getInputTileRectangle ( ossimIrect inputRect) const
protected

Gets the image rectangle for the input tile for theCurrentTileNumber.

Parameters
inputRectThe rectangle to initialize.

Definition at line 774 of file ossimOverviewSequencer.cpp.

References getOutputTileRectangle(), m_decimationFactor, and m_imageHandler.

Referenced by getNextTile().

775 {
776  if (!m_imageHandler) return;
777 
778  getOutputTileRectangle(inputRect);
779  inputRect = inputRect * m_decimationFactor;
780 
781 #if 0
782  if (traceDebug())
783  {
785  << "ossimOverviewSequencer::getInputTileRectangle DEBUG:"
786  << "input rect: " << inputRect << std::endl;
787  }
788 #endif
789 }
ossim_int32 m_decimationFactor
TODO make this handle any decimation.
ossimRefPtr< ossimImageHandler > m_imageHandler
void getOutputTileRectangle(ossimIrect &outputRect) const
Gets the image rectangle for the output tile for theCurrentTileNumber.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ getNextTile()

ossimRefPtr< ossimImageData > ossimOverviewSequencer::getNextTile ( )
virtual

Will allow you to get the next tile in the sequence.

Note the last tile returned will be an invalid ossimRefPtr<ossimImageData>. Callers should be able to do:

ossimRefPtr<ossimImageData> id = sequencer->getNextTile(); while (id.valid()) { doSomething; id = sequencer->getNextTile(); }

Reimplemented in ossimMpiMasterOverviewSequencer.

Definition at line 306 of file ossimOverviewSequencer.cpp.

References ossimImageData::computeMinMaxNulPix(), ossimImageData::computeMinMaxPix(), getInputTileRectangle(), getOutputTileRectangle(), ossimImageSource::getTile(), ossimMaskFilter::getTile(), ossimErrorStatusInterface::hasError(), m_currentTileNumber, m_dirtyFlag, m_histoMode, m_histoTileIndex, m_imageHandler, m_maskFilter, m_maxValues, m_minValues, m_nulValues, m_scanForMinMax, m_scanForMinMaxNull, m_sourceResLevel, m_tile, ossimImageData::makeBlank(), OSSIM_HISTO_MODE_UNKNOWN, ossimNotify(), ossimNotifyLevel_WARN, ossimErrorStatusInterface::setErrorStatus(), ossimImageData::setImageRectangle(), and ossimRefPtr< T >::valid().

Referenced by ossimMpiMasterOverviewSequencer::getNextTile(), and ossimMpiSlaveOverviewSequencer::slaveProcessTiles().

307 {
308  if ( m_dirtyFlag )
309  {
311  }
312 
313  // Get the rectangle to grab from the image.
314  ossimIrect inputRect;
315  getInputTileRectangle(inputRect);
316 
317  // Get the output rectangle.
318  ossimIrect outputRect;
319  getOutputTileRectangle(outputRect);
320 
321  // Capture the output rectangle.
322  m_tile->setImageRectangle(outputRect);
323 
324  // Start with a blank tile.
325  m_tile->makeBlank();
326 
327  // Grab the input tile.
328  ossimRefPtr<ossimImageData> inputTile;
329  if (m_maskFilter.valid())
330  {
331  inputTile = m_maskFilter->getTile(inputRect, m_sourceResLevel);
332 
333  // Check for errors reading tile and set our error status for callers.
334  if ( m_maskFilter->hasError() )
335  {
336  setErrorStatus();
337  }
338  }
339  else
340  {
341  inputTile = m_imageHandler->getTile(inputRect, m_sourceResLevel);
342 
343  // Check for errors reading tile and set our error status for callers.
344  if ( m_imageHandler->hasError() )
345  {
346  setErrorStatus();
347  }
348  }
349 
350  if ( hasError() )
351  {
353  << "ossimOverviewSequencer::getNextTile ERROR:"
354  << "\nError set reading tile: " << m_currentTileNumber << std::endl;
355  if ( inputTile.valid() )
356  {
357  inputTile->makeBlank();
358  }
359  }
360  else if ( inputTile.valid() )
361  {
362  if ( m_scanForMinMaxNull )
363  {
365  }
366  else if ( m_scanForMinMax )
367  {
369  }
370 
373  {
374  if (traceDebug())
375  {
377  << "ossimOverviewSequencer::getNextTile DEBUG:"
378  << "\npopulating histogram for tile: " << m_currentTileNumber
379  << "\n";
380  }
381  inputTile->populateHistogram(m_histogram);
382  }
383 
384  if ( (inputTile->getDataObjectStatus() == OSSIM_PARTIAL) ||
385  (inputTile->getDataObjectStatus() == OSSIM_FULL ) )
386  {
387  // Resample the tile.
388  resampleTile(inputTile.get());
389  m_tile->validate();
390 
391  // Scan the resampled pixels for bogus values to be masked out (if masking enabled)
392  if (m_maskWriter.valid())
394  }
395  }
396  else
397  {
399  << "ossimOverviewSequencer::getNextTile DEBUG:"
400  << "\nRequest failed for input rect: " << inputRect
401  << "\nRes level: " << m_sourceResLevel << std::endl;
402  }
403 
404  // Increment the tile index.
406 
407  return m_tile;
408 }
std::vector< ossim_float64 > m_maxValues
virtual void setImageRectangle(const ossimIrect &rect)
ossim_uint32 m_histoTileIndex
Used to determine which tiles to accumulate a histogram from.
virtual void populateHistogram(ossimRefPtr< ossimMultiBandHistogram > histo)
virtual void computeMinMaxPix(std::vector< ossim_float64 > &minBands, std::vector< ossim_float64 > &maxBands) const
If the minBands and maxBands are empty or not equal to the imageData&#39;s current number of bands it wil...
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimImageData > m_tile
ossimRefPtr< ossimImageHandler > m_imageHandler
ossimRefPtr< ossimBitMaskWriter > m_maskWriter
std::vector< ossim_float64 > m_nulValues
std::vector< ossim_float64 > m_minValues
Arrays o hold the min value for each band for scan min/max methods.
virtual ossimDataObjectStatus getDataObjectStatus() const
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &rect, ossim_uint32 resLevel=0)
Main entry point for the algorithm.
virtual void computeMinMaxNulPix(std::vector< ossim_float64 > &minBands, std::vector< ossim_float64 > &maxBands, std::vector< ossim_float64 > &nulBands) const
Scans tile for min, max, nulls.
bool m_dirtyFlag
Dirty flag - if true, this object is not initialized.
ossimRefPtr< ossimMaskFilter > m_maskFilter
void resampleTile(const ossimImageData *inputTile)
Resamples a patch of data.
virtual ossimDataObjectStatus validate() const
bool m_scanForMinMax
Control flags for min, max, null scanning.
ossimRefPtr< ossimMultiBandHistogram > m_histogram
ossim_uint32 m_sourceResLevel
This is the resolution level to build overviews from.
void generateMask(ossimRefPtr< ossimImageData > tile, ossim_uint32 rLevel)
Given a source&#39;s tile, derives the alpha mask and saves it in buffer for later writing to disk...
virtual void makeBlank()
Initializes data to null pixel values.
void getInputTileRectangle(ossimIrect &inputRect) const
Gets the image rectangle for the input tile for theCurrentTileNumber.
ossimHistogramMode m_histoMode
void getOutputTileRectangle(ossimIrect &outputRect) const
Gets the image rectangle for the output tile for theCurrentTileNumber.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
virtual ossimRefPtr< ossimImageData > getTile(const ossimIpt &origin, ossim_uint32 resLevel=0)

◆ getNumberOfTiles()

ossim_uint32 ossimOverviewSequencer::getNumberOfTiles ( ) const
Returns
The number of tiles within the area of interest.

Definition at line 89 of file ossimOverviewSequencer.cpp.

References m_numberOfTilesHorizontal, and m_numberOfTilesVertical.

Referenced by ossimMpiMasterOverviewSequencer::getNextTile(), initialize(), and ossimMpiSlaveOverviewSequencer::slaveProcessTiles().

◆ getNumberOfTilesHorizontal()

ossim_uint32 ossimOverviewSequencer::getNumberOfTilesHorizontal ( ) const
Returns
The number of tiles along the x or horizontal direction.

Definition at line 94 of file ossimOverviewSequencer.cpp.

References m_numberOfTilesHorizontal.

95 {
97 }

◆ getNumberOfTilesVertical()

ossim_uint32 ossimOverviewSequencer::getNumberOfTilesVertical ( ) const
Returns
The number of tiles along the y or vertical direction.

Definition at line 99 of file ossimOverviewSequencer.cpp.

References m_numberOfTilesVertical.

100 {
102 }

◆ getOutputImageRectangle()

void ossimOverviewSequencer::getOutputImageRectangle ( ossimIrect rect) const
virtual

Gets the zero-based image rectangle for the output reduced resolution data set (rrds).

Parameters
rectThe rectangle to initialize.

Definition at line 104 of file ossimOverviewSequencer.cpp.

References ossimIrect::hasNans(), ossimIrect::height(), m_areaOfInterest, m_decimationFactor, ossimIrect::makeNan(), and ossimIrect::width().

Referenced by updateTileDimensions().

105 {
107  {
108  rect.makeNan(); // not initialized...
109  }
110  else
111  {
114 
115  //---
116  // NOTE:
117  // This will add a sample or line if there is a remainder like:
118  // 1025 / 2 = 512 will then become 513. It will be up to the resample
119  // tile method to fill the extra sample correctly.
120  //---
122  {
123  ++width;
124  }
126  {
127  ++height;
128  }
129 
130  rect = ossimIrect(0, 0, width-1, height-1);
131  }
132 }
ossim_int32 m_decimationFactor
TODO make this handle any decimation.
ossim_uint32 height() const
Definition: ossimIrect.h:487
ossim_uint32 width() const
Definition: ossimIrect.h:500
void makeNan()
Definition: ossimIrect.h:329
bool hasNans() const
Definition: ossimIrect.h:337
int ossim_int32

◆ getOutputTileRectangle()

void ossimOverviewSequencer::getOutputTileRectangle ( ossimIrect outputRect) const
protected

Gets the image rectangle for the output tile for theCurrentTileNumber.

Parameters
outputRectThe rectangle to initialize.

Definition at line 791 of file ossimOverviewSequencer.cpp.

References m_currentTileNumber, m_numberOfTilesHorizontal, m_tileSize, ossimIrect::set_lr(), ossimIrect::set_ul(), ossimIpt::x, and ossimIpt::y.

Referenced by getInputTileRectangle(), ossimMpiMasterOverviewSequencer::getNextTile(), and getNextTile().

793 {
794  // Get the row and column.
797 
798  ossimIpt pt;
799 
800  // Set the upper left.
801  pt.y = row * m_tileSize.y;
802  pt.x = col * m_tileSize.x;
803  outputRect.set_ul(pt);
804 
805  // Set the lower right.
806  pt.y = pt.y + m_tileSize.y - 1;
807  pt.x = pt.x + m_tileSize.x - 1;
808  outputRect.set_lr(pt);
809 
810 #if 0
811  if (traceDebug())
812  {
814  << "ossimOverviewSequencer::getOutputTileRectangle DEBUG:"
815  << "output rect: " << outputRect << std::endl;
816  }
817 #endif
818 }
void set_ul(const ossimIpt &pt)
Definition: ossimIrect.h:589
void set_lr(const ossimIpt &pt)
Definition: ossimIrect.h:623
ossim_int32 y
Definition: ossimIpt.h:142
ossim_int32 x
Definition: ossimIpt.h:141
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32

◆ getScanForMinMax()

bool ossimOverviewSequencer::getScanForMinMax ( ) const
Returns
scan for min max flag.

Definition at line 442 of file ossimOverviewSequencer.cpp.

References m_scanForMinMax.

443 {
444  return m_scanForMinMax;
445 }
bool m_scanForMinMax
Control flags for min, max, null scanning.

◆ getScanForMinMaxNull()

bool ossimOverviewSequencer::getScanForMinMaxNull ( ) const
Returns
scan for min max flag.

Definition at line 452 of file ossimOverviewSequencer.cpp.

References m_scanForMinMaxNull.

453 {
454  return m_scanForMinMaxNull;
455 }

◆ getTileSize()

ossimIpt ossimOverviewSequencer::getTileSize ( ) const
Returns
The tile size.

Definition at line 419 of file ossimOverviewSequencer.cpp.

References m_tileSize.

420 {
421  return m_tileSize;
422 }

◆ initialize()

void ossimOverviewSequencer::initialize ( )
virtual

This must be called.

We can only initialize this object completely if we know all connections are valid. Some other object drives this and so the connection's initialize will be called after. The job of this connection is to set up the sequence. It will default to the bounding rect. The area of interest can be set to some other rectagle (use setAreaOfInterest).

Reimplemented in ossimMpiSlaveOverviewSequencer, and ossimMpiMasterOverviewSequencer.

Definition at line 182 of file ossimOverviewSequencer.cpp.

References ossimMultiBandHistogram::create(), ossimRefPtr< T >::get(), ossimImageHandler::getImageRectangle(), ossimImageSource::getNumberOfOutputBands(), getNumberOfTiles(), ossimImageSource::getTileHeight(), ossimImageSource::getTileWidth(), ossimIpt::hasNans(), ossimIrect::hasNans(), ossimImageData::initialize(), ossimImageDataFactory::instance(), m_areaOfInterest, m_currentTileNumber, m_dirtyFlag, m_histogram, m_histoMode, m_histoTileIndex, m_imageHandler, m_maskFilter, m_sourceResLevel, m_tile, m_tileSize, OSSIM_HISTO_MODE_NORMAL, OSSIM_HISTO_MODE_UNKNOWN, ossimImageData::setWidthHeight(), updateTileDimensions(), ossimRefPtr< T >::valid(), ossimIpt::x, and ossimIpt::y.

Referenced by ossimMpiMasterOverviewSequencer::initialize(), and ossimMpiSlaveOverviewSequencer::initialize().

183 {
184  if ( m_dirtyFlag == false )
185  {
186  return; // Already initialized.
187  }
188 
189  if ( !m_imageHandler )
190  {
191  return;
192  }
193 
194  ossimImageSource* imageSource = m_imageHandler.get();
195  if (m_maskFilter.valid())
196  imageSource = m_maskFilter.get();
197 
198  // Check the area of interest and set from image if needed.
199  if ( m_areaOfInterest.hasNans() )
200  {
202  }
203 
204  // Check the tile size and set from image if needed.
205  if ( m_tileSize.hasNans() )
206  {
207  m_tileSize.x = imageSource->getTileWidth();
208  m_tileSize.y = imageSource->getTileHeight();
209  }
210 
211  // Update m_numberOfTilesHorizontal and m_numberOfTilesVertical.
213 
214  // Start on first tile.
216 
217  // Use this factory constructor as it copies the min/max/nulls from the image handler.
219  create( 0, imageSource->getNumberOfOutputBands(), imageSource);
220 
221  if(m_tile.valid())
222  {
223  // Set the width and height.
224  m_tile->setWidthHeight(static_cast<ossim_uint32>(m_tileSize.x),
225  static_cast<ossim_uint32>(m_tileSize.y) );
226  // Initialize tile buffer.
227  m_tile->initialize();
228  }
229 
231  {
233 
234  m_histogram->create(imageSource);
235 
237  {
238  m_histoTileIndex = 1; // Sample every tile.
239  }
240  else
241  {
242  const ossim_float64 PIXEL_TO_SAMPLE = 100.0 * 256.0 * 256.0; // 100 256x256 tiles.
244 
245  if (traceDebug())
246  {
248  << "pixels: " << pixels << "\n"
249  << "PIXEL_TO_SAMPLE: " << PIXEL_TO_SAMPLE << "\n";
250  }
251 
252  if (pixels > PIXEL_TO_SAMPLE)
253  {
254  m_histoTileIndex = ossim::round<ossim_uint32>(pixels/PIXEL_TO_SAMPLE);
255  }
256  else
257  {
258  m_histoTileIndex = 1; // Sample every tile.
259  }
260  }
261  }
262  else
263  {
264  m_histogram = 0;
265  }
266 
267 
269  {
270  //---
271  // The methods ossimImageData::computeMinMaxNullPix and computeMinMaxPix
272  // will resize and set min to max, max to min and null to max if the arrays passed in
273  // are empty.
274  //---
276  }
277 
278  m_dirtyFlag = false;
279 
280  if (traceDebug())
281  {
283  << "aoi: " << m_areaOfInterest
284  << "\ntile size: " << m_tileSize
285  << "\ntiles wide: " << m_numberOfTilesHorizontal
286  << "\ntiles high: " << m_numberOfTilesVertical
287  << "\nsource rlevel: " << m_sourceResLevel
288  << "\ndecimation factor: " << m_decimationFactor
289  << "\nresamp type: " << m_resampleType
290  << "\nscan for min max: " << (m_scanForMinMax?"true\n":"false\n")
291  << "\nscan for min, max null: " << (m_scanForMinMaxNull?"true\n":"false\n")
292  << "\nhisto mode: " << m_histoMode << "\n";
294  {
296  << "Sampling every " << m_histoTileIndex << " tile(s) for histogram.\n";
297  }
298  }
299 }
ossim_int32 m_decimationFactor
TODO make this handle any decimation.
ossim_uint32 m_histoTileIndex
Used to determine which tiles to accumulate a histogram from.
virtual void setWidthHeight(ossim_uint32 w, ossim_uint32 h)
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimImageData > m_tile
ossimRefPtr< ossimImageHandler > m_imageHandler
virtual ossim_uint32 getTileHeight() const
Returns the default processing tile height.
ossim_uint32 getNumberOfTiles() const
virtual void initialize()
Initialize the data buffer.
virtual ossim_uint32 getTileWidth() const
Returns the default processing tile width.
ossimFilterResampler::ossimFilterResamplerType m_resampleType
Currently only handles NEAREST_NEIGHBOR and BOX (default = BOX)
double ossim_float64
bool m_dirtyFlag
Dirty flag - if true, this object is not initialized.
ossimRefPtr< ossimMaskFilter > m_maskFilter
void updateTileDimensions()
Updates theNumberOfTilesHorizontal and theNumberOfTilesVertical.
static ossimImageDataFactory * instance()
bool m_scanForMinMax
Control flags for min, max, null scanning.
ossimRefPtr< ossimMultiBandHistogram > m_histogram
ossim_uint32 m_sourceResLevel
This is the resolution level to build overviews from.
virtual ossimIrect getImageRectangle(ossim_uint32 resLevel=0) const
Returns zero-based bounding rectangle of the image.
void clearMinMaxNullArrays()
Clears out the arrays from a scan for min, max, nulls.
ossim_int32 y
Definition: ossimIpt.h:142
ossimHistogramMode m_histoMode
bool hasNans() const
Definition: ossimIrect.h:337
ossim_int32 x
Definition: ossimIpt.h:141
bool hasNans() const
Definition: ossimIpt.h:58
void create(const ossimImageSource *input)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ isMaster()

bool ossimOverviewSequencer::isMaster ( ) const
virtual
Returns
Always true for this implementation.

Reimplemented in ossimMpiSlaveOverviewSequencer.

Definition at line 414 of file ossimOverviewSequencer.cpp.

415 {
416  return true;
417 }

◆ resampleTile() [1/2]

void ossimOverviewSequencer::resampleTile ( const ossimImageData inputTile)
protected

Resamples a patch of data.

Definition at line 850 of file ossimOverviewSequencer.cpp.

References ossimImageSource::getOutputScalarType(), m_imageHandler, OSSIM_FLOAT32, OSSIM_FLOAT64, OSSIM_NORMALIZED_DOUBLE, OSSIM_SINT16, OSSIM_SINT32, OSSIM_UINT16, OSSIM_UINT32, OSSIM_UINT8, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, ossimNotify(), and ossimNotifyLevel_WARN.

851 {
853  {
854  case OSSIM_UINT8:
855  {
856  resampleTile(inputTile, ossim_uint8(0));
857  break;
858  }
859 
860  case OSSIM_USHORT11:
861  case OSSIM_USHORT12:
862  case OSSIM_USHORT13:
863  case OSSIM_USHORT14:
864  case OSSIM_USHORT15:
865  case OSSIM_UINT16:
866  {
867  resampleTile(inputTile, ossim_uint16(0));
868  break;
869  }
870  case OSSIM_SINT16:
871  {
872  resampleTile(inputTile, ossim_sint16(0));
873  break;
874  }
875 
876  case OSSIM_UINT32:
877  {
878  resampleTile(inputTile, ossim_uint32(0));
879  break;
880  }
881 
882  case OSSIM_SINT32:
883  {
884  resampleTile(inputTile, ossim_sint32(0));
885  break;
886  }
887 
888  case OSSIM_FLOAT32:
889  {
890  resampleTile(inputTile, ossim_float32(0.0));
891  break;
892  }
893 
895  case OSSIM_FLOAT64:
896  {
897  resampleTile(inputTile, ossim_float64(0.0));
898  break;
899  }
900  default:
902  << "ossimOverviewSequencer::resampleTile Unknown pixel type!"
903  << std::endl;
904  return;
905 
906  } // End of "switch(m_imageHandler->getOutputScalarType())"
907 }
16 bit unsigned integer (15 bits used)
64 bit floating point
16 bit unsigned integer
float ossim_float32
ossimRefPtr< ossimImageHandler > m_imageHandler
16 bit signed integer
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
32 bit floating point
unsigned short ossim_uint16
32 bit unsigned integer
double ossim_float64
void resampleTile(const ossimImageData *inputTile)
Resamples a patch of data.
signed short ossim_sint16
32 bit signed integer
unsigned int ossim_uint32
signed int ossim_sint32
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
8 bit unsigned integer
unsigned char ossim_uint8
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
16 bit unsigned integer (12 bits used)

◆ resampleTile() [2/2]

template<class T >
void ossimOverviewSequencer::resampleTile ( const ossimImageData inputTile,
dummy 
)
protected

Definition at line 910 of file ossimOverviewSequencer.cpp.

911 {
912 #if 0
913  if (traceDebug())
914  {
916  << "ossimOverviewSequencer::resampleTile DEBUG: "
917  << "\ncurrent tile: " << m_currentTileNumber
918  << "\ninput tile:\n" << *inputTile
919  << "output tile:\n" << *(m_tile.get())
920  << endl;
921  }
922 #endif
923 
924  const ossim_uint32 BANDS = m_tile->getNumberOfBands();
925  const ossim_uint32 LINES = m_tile->getHeight();
926  const ossim_uint32 SAMPS = m_tile->getWidth();
927  const ossim_uint32 INPUT_WIDTH = m_decimationFactor*m_tileSize.x;
928 
929  T nullPixel = 0;
930  ossim_float64 weight = 0.0;
931  ossim_float64 value = 0.0;
932  ossim_uint32 sampOffset = 0;
933 
935  {
936  for (ossim_uint32 band=0; band<BANDS; ++band)
937  {
938  const T* s = static_cast<const T*>(inputTile->getBuf(band)); // source
939  T* d = static_cast<T*>(m_tile->getBuf(band)); // destination
940 
941  nullPixel = static_cast<T>(inputTile->getNullPix(band));
942  weight = 0.0;
943  value = 0.0;
944 
945  for (ossim_uint32 i=0; i<LINES; ++i)
946  {
947  for (ossim_uint32 j=0; j<SAMPS; ++j)
948  {
949  sampOffset = j*m_decimationFactor;
950 
951  weight = 1.0;
952  value = *(s + i*m_decimationFactor*INPUT_WIDTH + sampOffset);
953 
954  if(weight)
955  {
956  d[j] = static_cast<T>( value/weight );
957  }
958  else
959  {
960  d[j] = nullPixel;
961  }
962 
963  } // End of sample loop.
964 
965  d += m_tileSize.x;
966 
967  } // End of line loop.
968 
969  } // End of band loop.
970 
971  }
972  else // ossimFilterResampler::ossimFilterResampler_BOX
973  {
974  ossim_uint32 lineOffset1 = 0;
975  ossim_uint32 lineOffset2 = 0;
976  ossim_float64 ul = 0.0;
977  ossim_float64 ur = 0.0;
978  ossim_float64 ll = 0.0;
979  ossim_float64 lr = 0.0;
980 
981  for (ossim_uint32 band=0; band<BANDS; ++band)
982  {
983  const T* s = static_cast<const T*>(inputTile->getBuf(band)); // source
984  T* d = static_cast<T*>(m_tile->getBuf(band)); // destination
985 
986  nullPixel = static_cast<T>(inputTile->getNullPix(band));
987  weight = 0.0;
988  value = 0.0;
989 
990  for (ossim_uint32 i=0; i<LINES; ++i)
991  {
992  lineOffset1 = i*m_decimationFactor*INPUT_WIDTH;
993  lineOffset2 = (i*m_decimationFactor+1)*INPUT_WIDTH;
994 
995  for (ossim_uint32 j=0; j<SAMPS; ++j)
996  {
997  sampOffset = j*m_decimationFactor;
998 
999  weight = 0.0;
1000  value = 0.0;
1001 
1002  //---
1003  // Grab four pixels from the source, average, and assign
1004  // to output.
1005  //---
1006  ul = *(s + lineOffset1 + sampOffset);
1007  ur = *(s + lineOffset1 + sampOffset + 1);
1008  ll = *(s + lineOffset2 + sampOffset);
1009  lr = *(s + lineOffset2 + sampOffset + 1);
1010 
1011  if(ul != nullPixel)
1012  {
1013  ++weight;
1014  value += ul;
1015  }
1016  if(ur != nullPixel)
1017  {
1018  ++weight;
1019  value += ur;
1020  }
1021  if(ll != nullPixel)
1022  {
1023  ++weight;
1024  value += ll;
1025  }
1026  if(lr != nullPixel)
1027  {
1028  ++weight;
1029  value += lr;
1030  }
1031 
1032  if(weight)
1033  {
1034  d[j] = static_cast<T>( value/weight );
1035  }
1036  else
1037  {
1038  d[j] = nullPixel;
1039  }
1040 
1041  } // End of sample loop.
1042 
1043  d += m_tileSize.x;
1044 
1045  } // End of line loop.
1046 
1047  } // End of band loop.
1048  }
1049 }
virtual ossim_uint32 getWidth() const
ossim_int32 m_decimationFactor
TODO make this handle any decimation.
virtual ossim_uint32 getNumberOfBands() const
ossimRefPtr< ossimImageData > m_tile
virtual ossim_uint32 getHeight() const
ossimFilterResampler::ossimFilterResamplerType m_resampleType
Currently only handles NEAREST_NEIGHBOR and BOX (default = BOX)
double ossim_float64
unsigned int ossim_uint32
virtual const ossim_float64 * getNullPix() const
virtual const void * getBuf() const
ossim_int32 x
Definition: ossimIpt.h:141
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ setBitMaskObjects()

void ossimOverviewSequencer::setBitMaskObjects ( ossimBitMaskWriter mask_writer,
ossimMaskFilter mask_filter 
)

Enabled the generation of an alpha (bit) mask such that any full or partial null pixels will be masked out.

A mask file will be written to the source image directory with the image file name and extension ".mask"

Definition at line 1051 of file ossimOverviewSequencer.cpp.

References m_maskFilter, and m_maskWriter.

1053 {
1054  m_maskWriter = mask_writer;
1055  m_maskFilter = mask_filter;
1056 }
ossimRefPtr< ossimBitMaskWriter > m_maskWriter
ossimRefPtr< ossimMaskFilter > m_maskFilter

◆ setHistogramMode()

void ossimOverviewSequencer::setHistogramMode ( ossimHistogramMode  mode)

Sets the histogram accumulation mode.

Parameters
modeNONE, NORMAL or FAST.

Definition at line 156 of file ossimOverviewSequencer.cpp.

References m_dirtyFlag, and m_histoMode.

157 {
158  m_histoMode = mode;
159  m_dirtyFlag = true;
160 }
bool m_dirtyFlag
Dirty flag - if true, this object is not initialized.
ossimHistogramMode m_histoMode

◆ setImageHandler()

void ossimOverviewSequencer::setImageHandler ( ossimImageHandler input)

Sets the input source or connection.

Parameters
inputPointer to ossimImageHandler.
Note
This object does not own the image handler.

Definition at line 134 of file ossimOverviewSequencer.cpp.

References ossimBitMaskWriter::connectMyInputTo(), ossimRefPtr< T >::get(), m_areaOfInterest, m_dirtyFlag, m_imageHandler, m_maskWriter, ossimIrect::makeNan(), and ossimRefPtr< T >::valid().

135 {
136  m_imageHandler = input;
138  m_dirtyFlag = true;
139 
140  if (m_maskWriter.valid())
142 }
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimImageHandler > m_imageHandler
ossimRefPtr< ossimBitMaskWriter > m_maskWriter
bool m_dirtyFlag
Dirty flag - if true, this object is not initialized.
virtual ossim_int32 connectMyInputTo(ossimConnectableObject *inputObject, bool makeOutputConnection=true, bool createEventFlag=true)
Will try to connect this objects input to the passed in object.
void makeNan()
Definition: ossimIrect.h:329

◆ setResampleType()

void ossimOverviewSequencer::setResampleType ( ossimFilterResampler::ossimFilterResamplerType  resampleType)

Sets the resampling type.

Supports BOX or NEAREST NEIGHBOR. When indexed you should probably use nearest neighbor. default = ossimFilterResampler::ossimFilterResampler_BOX

Parameters
resampleTypeThe resampling method to use.

Definition at line 431 of file ossimOverviewSequencer.cpp.

References m_resampleType.

433 {
434  m_resampleType = resampleType;
435 }
ossimFilterResampler::ossimFilterResamplerType m_resampleType
Currently only handles NEAREST_NEIGHBOR and BOX (default = BOX)

◆ setScanForMinMax()

void ossimOverviewSequencer::setScanForMinMax ( bool  flag)

Turn on/off scan for min max flag.

This method assumes the null is known.

Parameters
flagtrue turns scan on, false off. Default=off.

Definition at line 437 of file ossimOverviewSequencer.cpp.

References m_scanForMinMax.

438 {
439  m_scanForMinMax = flag;
440 }
bool m_scanForMinMax
Control flags for min, max, null scanning.

◆ setScanForMinMaxNull()

void ossimOverviewSequencer::setScanForMinMaxNull ( bool  flag)

Turn on/off scan for min, max, null flag.

Attempts to find null, min and max where null is the minimum value found, min is the second most min and max is max.

Parameters
flagtrue turns scan on, false off. Default=off.

Definition at line 447 of file ossimOverviewSequencer.cpp.

References m_scanForMinMaxNull.

448 {
449  m_scanForMinMaxNull = flag;
450 }

◆ setSourceLevel()

void ossimOverviewSequencer::setSourceLevel ( ossim_uint32  level)

Sets the input source resolution to decimate from.

Parameters
levelThe level to decimate.

Definition at line 144 of file ossimOverviewSequencer.cpp.

References m_areaOfInterest, m_dirtyFlag, m_sourceResLevel, and ossimIrect::makeNan().

145 {
146  m_sourceResLevel = level;
148  m_dirtyFlag = true;
149 }
bool m_dirtyFlag
Dirty flag - if true, this object is not initialized.
ossim_uint32 m_sourceResLevel
This is the resolution level to build overviews from.
void makeNan()
Definition: ossimIrect.h:329

◆ setTileSize()

void ossimOverviewSequencer::setTileSize ( const ossimIpt pt)

updated the tile size.

This will update the number of horizontal and vertical tiles.

Parameters
ptThe tile size. pt.x = width, pt.y = height
heightThe tile height.

Definition at line 424 of file ossimOverviewSequencer.cpp.

References m_dirtyFlag, m_tileSize, and updateTileDimensions().

425 {
426  m_tileSize = tileSize;
428  m_dirtyFlag = true;
429 }
bool m_dirtyFlag
Dirty flag - if true, this object is not initialized.
void updateTileDimensions()
Updates theNumberOfTilesHorizontal and theNumberOfTilesVertical.

◆ setToStartOfSequence()

void ossimOverviewSequencer::setToStartOfSequence ( )
virtual

Will set the internal pointers to the upperleft tile number.

To go to the next tile in the sequence just call getNextTile.

Reimplemented in ossimMpiSlaveOverviewSequencer, and ossimMpiMasterOverviewSequencer.

Definition at line 301 of file ossimOverviewSequencer.cpp.

References m_currentTileNumber.

302 {
304 }

◆ slaveProcessTiles()

void ossimOverviewSequencer::slaveProcessTiles ( )
virtual

This implementation does nothing.

Derived slave would use this as a trigger to start resampling tiles.

Reimplemented in ossimMpiSlaveOverviewSequencer.

Definition at line 410 of file ossimOverviewSequencer.cpp.

411 {
412 }

◆ updateTileDimensions()

void ossimOverviewSequencer::updateTileDimensions ( )
protected

Updates theNumberOfTilesHorizontal and theNumberOfTilesVertical.

This required theAreaOfInterest and theTileSize to be set.

Definition at line 820 of file ossimOverviewSequencer.cpp.

References getOutputImageRectangle(), ossimIpt::hasNans(), ossimIrect::hasNans(), ossimIrect::height(), m_areaOfInterest, m_dirtyFlag, m_numberOfTilesHorizontal, m_numberOfTilesVertical, m_tileSize, ossimIrect::width(), ossimIpt::x, and ossimIpt::y.

Referenced by initialize(), and setTileSize().

821 {
823  {
826  m_dirtyFlag = true;
827  }
828  else
829  {
830  // Get the output rectangle.
831  ossimIrect rect;
833 
835  static_cast<ossim_uint32>( rect.width() / m_tileSize.x );
837  static_cast<ossim_uint32>( rect.height() / m_tileSize.y );
838 
839  if (rect.width() % m_tileSize.x)
840  {
842  }
843  if (rect.height() % m_tileSize.y)
844  {
846  }
847  }
848 }
ossim_uint32 height() const
Definition: ossimIrect.h:487
virtual void getOutputImageRectangle(ossimIrect &rect) const
Gets the zero-based image rectangle for the output reduced resolution data set (rrds).
bool m_dirtyFlag
Dirty flag - if true, this object is not initialized.
unsigned int ossim_uint32
ossim_uint32 width() const
Definition: ossimIrect.h:500
ossim_int32 y
Definition: ossimIpt.h:142
bool hasNans() const
Definition: ossimIrect.h:337
ossim_int32 x
Definition: ossimIpt.h:141
bool hasNans() const
Definition: ossimIpt.h:58

◆ writeHistogram() [1/2]

void ossimOverviewSequencer::writeHistogram ( )

Write histogram method.

Definition at line 162 of file ossimOverviewSequencer.cpp.

References ossimImageHandler::getFilenameWithThisExtension(), m_histogram, m_imageHandler, and ossimRefPtr< T >::valid().

163 {
164  if ( m_histogram.valid() && m_imageHandler.valid() )
165  {
167  }
168 }
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimImageHandler > m_imageHandler
void writeHistogram()
Write histogram method.
ossimRefPtr< ossimMultiBandHistogram > m_histogram
ossimFilename getFilenameWithThisExtension(const ossimString &ext, bool set_e0_prefix=false) const
Returns the image file with extension set using supplentary directory for dirname if set...

◆ writeHistogram() [2/2]

void ossimOverviewSequencer::writeHistogram ( const ossimFilename file)

Write histogram method that takes a file name.

Parameters
fileFile to write to.

Definition at line 170 of file ossimOverviewSequencer.cpp.

References ossimMultiResLevelHistogram::addHistogram(), ossimString::c_str(), ossimRefPtr< T >::get(), m_histogram, ossimMultiResLevelHistogram::saveState(), ossimRefPtr< T >::valid(), and ossimKeywordlist::write().

171 {
172  if ( m_histogram.valid() )
173  {
175  histo->addHistogram( m_histogram.get() );
176  ossimKeywordlist kwl;
177  histo->saveState(kwl);
178  kwl.write(file.c_str());
179  }
180 }
Represents serializable keyword/value map.
bool valid() const
Definition: ossimRefPtr.h:75
virtual bool write(const char *file, const char *comment=0) const
Methods to dump the ossimKeywordlist to a file on disk.
ossimRefPtr< ossimMultiBandHistogram > m_histogram
virtual void addHistogram(ossimMultiBandHistogram *histo)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const

◆ writeOmdFile()

bool ossimOverviewSequencer::writeOmdFile ( const std::string &  file)

Writes an ossim metadata(omd) file with min, max, null values.

Writes omd file to disk with min, max, null values. If file existed previously it will be ingested into keyword list prior to addition of the min, max, nulls computed in this method.

Note that prior to writing a sanity check is performed on the values as a scan for null value might actually pick up the min if the image is full.

Parameters
fileto write.

Definition at line 464 of file ossimOverviewSequencer.cpp.

465 {
466  static const char M[] = "ossimOverviewSequencer::writeOmdFile";
467  if ( traceDebug() )
468  {
469  ossimNotify(ossimNotifyLevel_DEBUG) << M << " entered...\nfile: " << file << endl;
470  }
471 
472  //---
473  // This method writes an omd file to disk. Typically called after sequencing trough tile that
474  // were scanned for min, max, and potentially null values.
475  // Since this can be called without a scan there is extra logic in here to initialize values
476  // if so. Also there are sanity checks for cases where there is no null value, i.e. a
477  // full tile, in which case assumptions have to be made...
478  //---
479 
480  bool result = false;
481  if ( file.size() && m_imageHandler.valid() )
482  {
485  const ossim_float64 DEFAULT_NULL = ossim::defaultNull(SCALAR);
486 
487  if ( traceDebug() )
488  {
490  << "Original array values:\n";
491  std::vector<ossim_float64>::const_iterator i = m_minValues.begin();
492  ossim_int32 band = 0;
493  while ( i < m_minValues.end() )
494  {
496  << "min[" << band++ << "]: " << *i << "\n";
497  ++i;
498  }
499  i = m_maxValues.begin();
500  band = 0;
501  while ( i < m_maxValues.end() )
502  {
504  << "max[" << band++ << "]: " << *i << "\n";
505  ++i;
506  }
507  i = m_nulValues.begin();
508  band = 0;
509  while ( i < m_nulValues.end() )
510  {
512  << "nul[" << band++ << "]: " << *i << "\n";
513  ++i;
514  }
515  }
516 
517  if ( (m_scanForMinMax == true) || (m_nulValues.size() != BANDS) )
518  {
519  // Only scanned for min and max so set the null.
520  if (m_nulValues.size() != BANDS)
521  {
522  m_nulValues.resize(BANDS);
523  }
524  for (ossim_uint32 band = 0; band < BANDS; ++band)
525  {
527  }
528  }
529  else if ( m_scanForMinMaxNull == true )
530  {
531  //---
532  // The arrays (sizes) should be set if we did the scan.
533  // Note that scanning for null only works if there IS a null in the image; hence, the
534  // extra sanity checks as if there are no null then the null gets set to the real min.
535  //
536  // This is very dangerous code as it makes assumptions (drb)...
537  //---
538  if ( (m_minValues.size() == BANDS) &&
539  (m_maxValues.size() == BANDS) &&
540  (m_nulValues.size() == BANDS) )
541  {
542  switch(SCALAR)
543  {
544  case OSSIM_UINT8:
545  case OSSIM_SINT8:
546  case OSSIM_UINT16:
547  case OSSIM_USHORT11:
548  case OSSIM_USHORT12:
549  case OSSIM_USHORT13:
550  case OSSIM_USHORT14:
551  case OSSIM_USHORT15:
552  case OSSIM_UINT32:
553  {
554  // All of these should have a null of 0.
555  for (ossim_uint32 band = 0; band < BANDS; ++band)
556  {
557  if ( m_nulValues[band] > DEFAULT_NULL )
558  {
559  if ( m_nulValues[band] < m_minValues[band] )
560  {
561  m_minValues[band] = m_nulValues[band];
562  }
563  m_nulValues[band] = DEFAULT_NULL;
564  }
565  }
566  break;
567  }
568  case OSSIM_SINT16:
569  {
570  for (ossim_uint32 band = 0; band < BANDS; ++band)
571  {
572  if ( ( m_nulValues[band] != DEFAULT_NULL ) && // -32768
573  ( m_nulValues[band] != -32767.0 ) &&
574  ( m_nulValues[band] != -32766.0 ) &&
575  ( m_nulValues[band] != -9999.0 ) )
576  {
577  if ( ( m_nulValues[band] > -9999.0 ) &&
578  ( m_nulValues[band] < m_minValues[band] ) )
579  {
580  m_minValues[band] = m_nulValues[band];
581  }
582  m_nulValues[band] = DEFAULT_NULL;
583  }
584  }
585  break;
586  }
587  case OSSIM_SINT32:
588  {
589  for (ossim_uint32 band = 0; band < BANDS; ++band)
590  {
591  if ( ( m_nulValues[band] != DEFAULT_NULL ) &&
592  ( m_nulValues[band] != -32768.0 ) && // Common null
593  ( m_nulValues[band] != -32767.0 ) && // The other common null.
594  ( m_nulValues[band] != -32766.0 ) &&
595  ( m_nulValues[band] != -9999.0 ) &&
596  ( m_nulValues[band] != -99999.0 ) )
597  {
598  if ( ( m_nulValues[band] > -9999.0 ) &&
599  ( m_nulValues[band] < m_minValues[band] ) )
600  {
601  m_minValues[band] = m_nulValues[band];
602  }
603  m_nulValues[band] = DEFAULT_NULL;
604  }
605  }
606  break;
607  }
608  case OSSIM_FLOAT32:
609  case OSSIM_FLOAT64:
610  {
611  for (ossim_uint32 band = 0; band < BANDS; ++band)
612  {
613  if ( ( m_nulValues[band] != DEFAULT_NULL ) &&
614  ( m_nulValues[band] != -32768.0 ) &&
615  ( m_nulValues[band] != -32767.0 ) &&
616  ( m_nulValues[band] != -32766.0 ) &&
617  ( m_nulValues[band] != -9999.0 ) &&
618  ( m_nulValues[band] != -99999.0 ) )
619  {
620  if ( ( m_nulValues[band] > -9999 ) &&
621  ( m_nulValues[band] < m_minValues[band] ) )
622  {
623  m_minValues[band] = m_nulValues[band];
624  }
625  m_nulValues[band] = DEFAULT_NULL;
626  }
627  }
628  break;
629  }
632  {
633  for (ossim_uint32 band = 0; band < BANDS; ++band)
634  {
635  if ( ( m_nulValues[band] != DEFAULT_NULL ) &&
636  ( m_nulValues[band] > 0.0) )
637  {
638  if ( m_nulValues[band] < m_minValues[band] )
639  {
640  m_minValues[band] = m_nulValues[band];
641  }
642  m_nulValues[band] = 0.0;
643  }
644  }
645  break;
646  }
648  default:
649  {
650  if(traceDebug())
651  {
653  << __FILE__ << ":" << __LINE__
654  << " " << M << "\nUnhandled scalar type: " << SCALAR << std::endl;
655  }
656  break;
657  }
658 
659  } // End: switch(SCALAR)
660 
661  } // Matches: if ( (m_minValues.size() == BANDS) &&...
662  else
663  {
664  // ERROR!
666  << M << "ERROR:\nMin, max and null array sizes bad! No omd file will be written."
667  << std::endl;
668  }
669 
670  } // Matches: else if ( m_scanForMinMaxNull == true )
671  else
672  {
673  // Get the values from the image handler.
674  if (m_minValues.size() != BANDS)
675  {
676  m_minValues.resize(BANDS);
677  for (ossim_uint32 band = 0; band < BANDS; ++band)
678  {
680  }
681  }
682  if (m_maxValues.size() != BANDS)
683  {
684  m_maxValues.resize(BANDS);
685  for (ossim_uint32 band = 0; band < BANDS; ++band)
686  {
688  }
689  }
690  if (m_nulValues.size() != BANDS)
691  {
692  m_nulValues.resize(BANDS);
693  for (ossim_uint32 band = 0; band < BANDS; ++band)
694  {
696  }
697  }
698  }
699 
700  // Last size check as the m_scanForMinMaxNull block could have failed.
701  if ( ( m_minValues.size() == BANDS ) &&
702  ( m_maxValues.size() == BANDS ) &&
703  ( m_nulValues.size() == BANDS ) )
704  {
705  // Write the omd file:
706  ossimKeywordlist kwl;
707  if( ossimFilename(file).exists())
708  {
709  // Pick up existing omd file.
710  kwl.addFile(file.c_str());
711  }
712  ossimImageMetaData metaData(SCALAR, BANDS);
713  for(ossim_uint32 band = 0; band < BANDS; ++band)
714  {
715  metaData.setMinPix(band, m_minValues[band]);
716  metaData.setMaxPix(band, m_maxValues[band]);
717  metaData.setNullPix(band, m_nulValues[band]);
718  }
719  // Save to keyword list.
720  metaData.saveState(kwl);
721 
722  // Write to disk.
723  result = kwl.write(file.c_str());
724  if ( result )
725  {
726  ossimNotify(ossimNotifyLevel_NOTICE) << "Wrote file: " << file << "\n";
727  }
728  else
729  {
730  ossimNotify(ossimNotifyLevel_WARN) << "ERROR writing file: " << file << "\n";
731  }
732  }
733 
734  if ( traceDebug() )
735  {
737  << "Final array values:\n";
738  std::vector<ossim_float64>::const_iterator i = m_minValues.begin();
739  ossim_int32 band = 0;
740  while ( i < m_minValues.end() )
741  {
743  << "min[" << band++ << "]: " << *i << "\n";
744  ++i;
745  }
746  i = m_maxValues.begin();
747  band = 0;
748  while ( i < m_maxValues.end() )
749  {
751  << "max[" << band++ << "]: " << *i << "\n";
752  ++i;
753  }
754  i = m_nulValues.begin();
755  band = 0;
756  while ( i < m_nulValues.end() )
757  {
759  << "nul[" << band++ << "]: " << *i << "\n";
760  ++i;
761  }
762  }
763 
764  } // Matches: if ( file && m_imageHandler.valid() )
765 
766  if ( traceDebug() )
767  {
768  ossimNotify(ossimNotifyLevel_DEBUG) << M << " exit status" << (result?"true\n":"false\n");
769  }
770 
771  return result;
772 }
16 bit unsigned integer (15 bits used)
8 bit signed integer
std::vector< ossim_float64 > m_maxValues
64 bit floating point
16 bit unsigned integer
Represents serializable keyword/value map.
bool addFile(const char *file)
bool valid() const
Definition: ossimRefPtr.h:75
ossimRefPtr< ossimImageHandler > m_imageHandler
std::vector< ossim_float64 > m_nulValues
std::vector< ossim_float64 > m_minValues
Arrays o hold the min value for each band for scan min/max methods.
16 bit signed integer
16 bit unsigned integer (14 bits used)
16 bit unsigned integer (13 bits used)
32 bit floating point
32 bit unsigned integer
virtual bool write(const char *file, const char *comment=0) const
Methods to dump the ossimKeywordlist to a file on disk.
virtual double getMinPixelValue(ossim_uint32 band=0) const
Retuns the min pixel value.
double ossim_float64
bool exists() const
32 bit signed integer
OSSIM_DLL double defaultNull(ossimScalarType scalarType)
bool m_scanForMinMax
Control flags for min, max, null scanning.
unsigned int ossim_uint32
32 bit normalized floating point
ossimScalarType
64 bit normalized floating point
16 bit unsigned integer (11 bits used)
virtual ossimScalarType getOutputScalarType() const
This will be used to query the output pixel type of the tile source.
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
8 bit unsigned integer
virtual ossim_uint32 getNumberOfInputBands() const =0
virtual double getNullPixelValue(ossim_uint32 band=0) const
Each band has a null pixel associated with it.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32
16 bit unsigned integer (12 bits used)

Member Data Documentation

◆ m_areaOfInterest

ossimIrect ossimOverviewSequencer::m_areaOfInterest
protected

◆ m_currentTileNumber

ossim_uint32 ossimOverviewSequencer::m_currentTileNumber
protected

◆ m_decimationFactor

ossim_int32 ossimOverviewSequencer::m_decimationFactor
protected

TODO make this handle any decimation.

Right now hard coded to two.

Definition at line 263 of file ossimOverviewSequencer.h.

Referenced by getInputTileRectangle(), and getOutputImageRectangle().

◆ m_dirtyFlag

bool ossimOverviewSequencer::m_dirtyFlag
protected

◆ m_histogram

ossimRefPtr<ossimMultiBandHistogram> ossimOverviewSequencer::m_histogram
protected

Definition at line 268 of file ossimOverviewSequencer.h.

Referenced by initialize(), writeHistogram(), and ~ossimOverviewSequencer().

◆ m_histoMode

ossimHistogramMode ossimOverviewSequencer::m_histoMode
protected

◆ m_histoTileIndex

ossim_uint32 ossimOverviewSequencer::m_histoTileIndex
protected

Used to determine which tiles to accumulate a histogram from.

If set to 1 every tile is accumulated, 2 every other tile, 3 every 3rd tile, and so on. Set in initialize method based on mode and image size.

Definition at line 277 of file ossimOverviewSequencer.h.

Referenced by getNextTile(), and initialize().

◆ m_imageHandler

ossimRefPtr<ossimImageHandler> ossimOverviewSequencer::m_imageHandler
protected

◆ m_maskFilter

ossimRefPtr<ossimMaskFilter> ossimOverviewSequencer::m_maskFilter
protected

◆ m_maskWriter

ossimRefPtr<ossimBitMaskWriter> ossimOverviewSequencer::m_maskWriter
protected

◆ m_maxValues

std::vector<ossim_float64> ossimOverviewSequencer::m_maxValues
protected

Definition at line 285 of file ossimOverviewSequencer.h.

Referenced by clearMinMaxNullArrays(), and getNextTile().

◆ m_minValues

std::vector<ossim_float64> ossimOverviewSequencer::m_minValues
protected

Arrays o hold the min value for each band for scan min/max methods.

Definition at line 284 of file ossimOverviewSequencer.h.

Referenced by clearMinMaxNullArrays(), and getNextTile().

◆ m_nulValues

std::vector<ossim_float64> ossimOverviewSequencer::m_nulValues
protected

Definition at line 286 of file ossimOverviewSequencer.h.

Referenced by clearMinMaxNullArrays(), and getNextTile().

◆ m_numberOfTilesHorizontal

ossim_uint32 ossimOverviewSequencer::m_numberOfTilesHorizontal
protected

◆ m_numberOfTilesVertical

ossim_uint32 ossimOverviewSequencer::m_numberOfTilesVertical
protected

◆ m_resampleType

ossimFilterResampler::ossimFilterResamplerType ossimOverviewSequencer::m_resampleType
protected

Currently only handles NEAREST_NEIGHBOR and BOX (default = BOX)

Definition at line 266 of file ossimOverviewSequencer.h.

Referenced by setResampleType().

◆ m_scanForMinMax

bool ossimOverviewSequencer::m_scanForMinMax
protected

Control flags for min, max, null scanning.

Definition at line 280 of file ossimOverviewSequencer.h.

Referenced by getNextTile(), getScanForMinMax(), and setScanForMinMax().

◆ m_scanForMinMaxNull

bool ossimOverviewSequencer::m_scanForMinMaxNull
protected

◆ m_sourceResLevel

ossim_uint32 ossimOverviewSequencer::m_sourceResLevel
protected

This is the resolution level to build overviews from.

Definition at line 257 of file ossimOverviewSequencer.h.

Referenced by getNextTile(), initialize(), and setSourceLevel().

◆ m_tile

ossimRefPtr<ossimImageData> ossimOverviewSequencer::m_tile
protected

◆ m_tileSize

ossimIpt ossimOverviewSequencer::m_tileSize
protected

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