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

#include <ossimMultiBandHistogram.h>

Inheritance diagram for ossimMultiBandHistogram:
ossimReferenced

Classes

class  ossimProprietaryHeaderInformation
 

Public Member Functions

 ossimMultiBandHistogram ()
 
 ossimMultiBandHistogram (const ossimMultiBandHistogram &rhs)
 
 ossimMultiBandHistogram (ossim_int32 numberOfBands, ossim_int32 numberOfBuckets, float minValue, float maxValue)
 
void create (const ossimImageSource *input)
 
void create (ossim_int32 numberOfBands, ossim_int32 numberOfBuckets, float minValue, float maxValue)
 
ossim_uint32 getNumberOfBands () const
 
void create (ossim_int32 numberOfBands)
 
void setBinCount (double binNumber, double count)
 
ossimRefPtr< ossimHistogramgetHistogram (ossim_int32 band)
 
const ossimRefPtr< ossimHistogramgetHistogram (ossim_int32 band) const
 
ossimRefPtr< ossimMultiBandHistogramcreateAccumulationLessThanEqual () const
 
ossimRefPtr< ossimMultiBandHistogramcreateAccumulationGreaterThanEqual () const
 
virtual bool importHistogram (const ossimFilename &inputFile)
 
virtual bool importHistogram (std::istream &in)
 
virtual bool loadState (const ossimKeywordlist &kwl, const char *prefix=0)
 
virtual bool saveState (ossimKeywordlist &kwl, const char *prefix=0) const
 
virtual bool saveState (ossimRefPtr< ossimXmlNode > xmlNode) const
 
virtual bool loadState (const ossimRefPtr< ossimXmlNode > xmlNode)
 
- 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
 

Protected Member Functions

virtual ~ossimMultiBandHistogram ()
 
void deleteHistograms ()
 
bool parseProprietaryHistogram (std::istream &in)
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 

Protected Attributes

std::vector< ossimRefPtr< ossimHistogram > > theHistogramList
 

Detailed Description

Definition at line 23 of file ossimMultiBandHistogram.h.

Constructor & Destructor Documentation

◆ ossimMultiBandHistogram() [1/3]

ossimMultiBandHistogram::ossimMultiBandHistogram ( )

◆ ossimMultiBandHistogram() [2/3]

ossimMultiBandHistogram::ossimMultiBandHistogram ( const ossimMultiBandHistogram rhs)

Definition at line 27 of file ossimMultiBandHistogram.cpp.

References theHistogramList.

28 {
29  theHistogramList.resize(rhs.theHistogramList.size());
30 
31  for(ossim_uint32 i = 0; i < theHistogramList.size(); ++i)
32  {
33  theHistogramList[i] = rhs.theHistogramList[i].valid()?
34  new ossimHistogram(*rhs.theHistogramList[i].get()):(ossimHistogram*)0;
35  }
36 }
unsigned int ossim_uint32
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList

◆ ossimMultiBandHistogram() [3/3]

ossimMultiBandHistogram::ossimMultiBandHistogram ( ossim_int32  numberOfBands,
ossim_int32  numberOfBuckets,
float  minValue,
float  maxValue 
)

Definition at line 38 of file ossimMultiBandHistogram.cpp.

References create().

42 {
43  if(numberOfBands > 0)
44  {
45  create(numberOfBands, numberOfBuckets, minValue, maxValue);
46  }
47 }
void create(const ossimImageSource *input)

◆ ~ossimMultiBandHistogram()

ossimMultiBandHistogram::~ossimMultiBandHistogram ( )
protectedvirtual

Definition at line 22 of file ossimMultiBandHistogram.cpp.

References deleteHistograms().

Member Function Documentation

◆ create() [1/3]

void ossimMultiBandHistogram::create ( const ossimImageSource input)

Definition at line 49 of file ossimMultiBandHistogram.cpp.

References ossimImageSource::getNumberOfOutputBands(), ossimImageSource::getOutputScalarType(), OSSIM_DEFAULT_MAX_PIX_SINT16, OSSIM_DEFAULT_MAX_PIX_UCHAR, OSSIM_DEFAULT_MAX_PIX_UINT11, OSSIM_DEFAULT_MAX_PIX_UINT12, OSSIM_DEFAULT_MAX_PIX_UINT13, OSSIM_DEFAULT_MAX_PIX_UINT14, OSSIM_DEFAULT_MAX_PIX_UINT15, OSSIM_DEFAULT_MAX_PIX_UINT16, OSSIM_DEFAULT_MIN_PIX_SINT16, OSSIM_FLOAT32, OSSIM_FLOAT64, OSSIM_NORMALIZED_DOUBLE, OSSIM_NORMALIZED_FLOAT, OSSIM_SINT16, OSSIM_SINT32, OSSIM_UINT16, OSSIM_UINT32, OSSIM_UINT8, OSSIM_USHORT11, OSSIM_USHORT12, OSSIM_USHORT13, OSSIM_USHORT14, OSSIM_USHORT15, ossimNotify(), and ossimNotifyLevel_WARN.

Referenced by ossimImageHistogramSource::computeFastModeHistogram(), ossimHistogramRemapper::computeHistogram(), ossimImageHistogramSource::computeNormalModeHistogram(), ossimImageSourceSequencer::getTile(), ossimOverviewSequencer::initialize(), and ossimMultiBandHistogram().

50 {
51  if (input)
52  {
53  ossim_uint32 bands = input->getNumberOfOutputBands();;
54  ossim_uint32 numberOfBins = 0;
55  ossim_float64 minValue = 0.0;
56  ossim_float64 maxValue = 0.0;
57 
58  switch(input->getOutputScalarType())
59  {
60  case OSSIM_UINT8:
61  {
62  minValue = 0;
63  maxValue = OSSIM_DEFAULT_MAX_PIX_UCHAR;
64  numberOfBins = 256;
65  break;
66  }
67  case OSSIM_USHORT11:
68  {
69  minValue = 0;
71  numberOfBins = OSSIM_DEFAULT_MAX_PIX_UINT11 + 1;
72  break;
73  }
74  case OSSIM_USHORT12:
75  {
76  minValue = 0;
78  numberOfBins = OSSIM_DEFAULT_MAX_PIX_UINT12 + 1;
79  break;
80  }
81  case OSSIM_USHORT13:
82  {
83  minValue = 0;
85  numberOfBins = OSSIM_DEFAULT_MAX_PIX_UINT13 + 1;
86  break;
87  }
88  case OSSIM_USHORT14:
89  {
90  minValue = 0;
92  numberOfBins = OSSIM_DEFAULT_MAX_PIX_UINT14 + 1;
93  break;
94  }
95  case OSSIM_USHORT15:
96  {
97  minValue = 0;
99  numberOfBins = OSSIM_DEFAULT_MAX_PIX_UINT15 + 1;
100  break;
101  }
102  case OSSIM_UINT16:
103  case OSSIM_UINT32:
104  {
105  minValue = 0;
106  maxValue = OSSIM_DEFAULT_MAX_PIX_UINT16;
107  numberOfBins = OSSIM_DEFAULT_MAX_PIX_UINT16 + 1;
108  break;
109  }
110  case OSSIM_SINT16:
111  case OSSIM_SINT32:
112  case OSSIM_FLOAT32:
113  case OSSIM_FLOAT64:
114  {
115  //---
116  // Special case to handle DTED which has a null of -32767 and SRTM
117  // which has null of -32768. Set the min to -32766 which is OK for
118  // both types. Basically we don't want to count the null values as
119  // a valid pixel. drb - 04 Feb. 2016
120  //
121  // NOTE: OSSIM_DEFAULT_MIN_PIX_SINT16 = -32767
122  //---
123  minValue = OSSIM_DEFAULT_MIN_PIX_SINT16+1;
124  maxValue = OSSIM_DEFAULT_MAX_PIX_SINT16;
126  break;
127  }
130  {
131  minValue = 0;
132  maxValue = 1.0;
133  numberOfBins = OSSIM_DEFAULT_MAX_PIX_UINT16+1;
134  break;
135  }
136  default:
137  {
139  << "Unsupported scalar type in ossimMultiBandHistogram::create()"
140  << std::endl;
141  return;
142  }
143 
144  } // switch(input->getOutputScalarType())
145 
146  create(bands, numberOfBins, minValue, maxValue);
147 
148  } // if (input)
149 }
16 bit unsigned integer (15 bits used)
#define OSSIM_DEFAULT_MAX_PIX_UINT16
64 bit floating point
16 bit unsigned integer
virtual ossim_uint32 getNumberOfOutputBands() const
Returns the number of bands in a tile returned from this TileSource.
#define OSSIM_DEFAULT_MAX_PIX_UCHAR
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
double ossim_float64
#define OSSIM_DEFAULT_MAX_PIX_UINT12
#define OSSIM_DEFAULT_MIN_PIX_SINT16
32 bit signed integer
#define OSSIM_DEFAULT_MAX_PIX_UINT15
unsigned int ossim_uint32
32 bit normalized floating point
#define OSSIM_DEFAULT_MAX_PIX_UINT13
#define OSSIM_DEFAULT_MAX_PIX_SINT16
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.
#define OSSIM_DEFAULT_MAX_PIX_UINT14
#define OSSIM_DEFAULT_MAX_PIX_UINT11
8 bit unsigned integer
void create(const ossimImageSource *input)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
16 bit unsigned integer (12 bits used)

◆ create() [2/3]

void ossimMultiBandHistogram::create ( ossim_int32  numberOfBands,
ossim_int32  numberOfBuckets,
float  minValue,
float  maxValue 
)

Definition at line 151 of file ossimMultiBandHistogram.cpp.

References deleteHistograms(), and theHistogramList.

155 {
156  // Make sure we clear our internal lists before we start.
158 
159  if(numberOfBands > 0)
160  {
161  numberOfBuckets = numberOfBuckets>0?numberOfBuckets:1;
162 
163  for(ossim_int32 bands = 0; bands < numberOfBands; ++bands)
164  {
165  theHistogramList.push_back(new ossimHistogram(numberOfBuckets,
166  minValue,
167  maxValue));
168  }
169  }
170 }
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList
int ossim_int32

◆ create() [3/3]

void ossimMultiBandHistogram::create ( ossim_int32  numberOfBands)

Definition at line 172 of file ossimMultiBandHistogram.cpp.

References deleteHistograms(), and theHistogramList.

173 {
175  for(ossim_int32 bands = 0; bands < numberOfBands; ++bands)
176  {
177  theHistogramList.push_back(new ossimHistogram);
178  }
179 }
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList
int ossim_int32

◆ createAccumulationGreaterThanEqual()

ossimRefPtr< ossimMultiBandHistogram > ossimMultiBandHistogram::createAccumulationGreaterThanEqual ( ) const

Definition at line 245 of file ossimMultiBandHistogram.cpp.

References ossimMultiBandHistogram(), and theHistogramList.

246 {
248 
249  if(theHistogramList.size() > 0)
250  {
251  result = new ossimMultiBandHistogram;
252 
253  for(ossim_uint32 idx = 0; idx < theHistogramList.size(); ++idx)
254  {
255  if(theHistogramList[idx].valid())
256  {
257  result->theHistogramList[idx] = theHistogramList[idx]->CumulativeGreaterThanEqual();
258  }
259  else
260  {
261  result->theHistogramList[idx] = 0;
262  }
263  }
264  }
265 
266  return result;
267 }
unsigned int ossim_uint32
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList

◆ createAccumulationLessThanEqual()

ossimRefPtr< ossimMultiBandHistogram > ossimMultiBandHistogram::createAccumulationLessThanEqual ( ) const

Definition at line 220 of file ossimMultiBandHistogram.cpp.

References ossimMultiBandHistogram(), and theHistogramList.

221 {
223 
224  if(theHistogramList.size() > 0)
225  {
226  result = new ossimMultiBandHistogram;
227  result->theHistogramList.resize(theHistogramList.size());
228 
229  for(ossim_uint32 idx = 0; idx < theHistogramList.size(); ++idx)
230  {
231  if(theHistogramList[idx].valid())
232  {
233  result->theHistogramList[idx] = theHistogramList[idx]->CumulativeLessThanEqual();
234  }
235  else
236  {
237  result->theHistogramList[idx] = 0;
238  }
239  }
240  }
241 
242  return result;
243 }
unsigned int ossim_uint32
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList

◆ deleteHistograms()

void ossimMultiBandHistogram::deleteHistograms ( )
protected

Definition at line 269 of file ossimMultiBandHistogram.cpp.

References theHistogramList.

Referenced by create(), importHistogram(), loadState(), and ~ossimMultiBandHistogram().

270 {
271  theHistogramList.clear();
272 }
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList

◆ getHistogram() [1/2]

ossimRefPtr< ossimHistogram > ossimMultiBandHistogram::getHistogram ( ossim_int32  band)

◆ getHistogram() [2/2]

const ossimRefPtr< ossimHistogram > ossimMultiBandHistogram::getHistogram ( ossim_int32  band) const

Definition at line 196 of file ossimMultiBandHistogram.cpp.

References theHistogramList.

197 {
198  if((band >=0) && (band < (ossim_int32)theHistogramList.size()))
199  {
200  return theHistogramList[band];
201  }
202 
203  return 0;
204 }
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList
int ossim_int32

◆ getNumberOfBands()

ossim_uint32 ossimMultiBandHistogram::getNumberOfBands ( ) const

◆ importHistogram() [1/2]

bool ossimMultiBandHistogram::importHistogram ( const ossimFilename inputFile)
virtual

Imports a text file that has histogram data

Definition at line 349 of file ossimMultiBandHistogram.cpp.

References ossimString::c_str(), and ossimFilename::exists().

Referenced by ossimMultiResLevelHistogram::importHistogram().

350 {
351  if(file.exists())
352  {
353  std::ifstream input(file.c_str());
354 
355  return importHistogram(input);
356  }
357 
358  return false;
359 }
std::basic_ifstream< char > ifstream
Class for char input file streams.
Definition: ossimIosFwd.h:44
virtual bool importHistogram(const ossimFilename &inputFile)

◆ importHistogram() [2/2]

bool ossimMultiBandHistogram::importHistogram ( std::istream &  in)
virtual

Definition at line 275 of file ossimMultiBandHistogram.cpp.

References deleteHistograms(), ossimString::find(), getline(), ossimMultiBandHistogram::ossimProprietaryHeaderInformation::getNumberOfBands(), ossimHistogram::importHistogram(), ossimMultiBandHistogram::ossimProprietaryHeaderInformation::parseStream(), ossimString::substr(), theHistogramList, and ossimString::toUInt32().

276 {
277  ossimProprietaryHeaderInformation header;
279 
280  if(header.parseStream(in))
281  {
282  ossim_int32 numberOfBands = header.getNumberOfBands();
283 
284  if(numberOfBands)
285  {
286  theHistogramList.resize(numberOfBands);
287 
288  for(ossim_int32 counter = 0; counter < (ossim_int32)theHistogramList.size(); ++counter)
289  {
290  theHistogramList[counter] = 0;
291  }
292  ossimString bandBuffer;
293  ossimString buffer;
294 
295  for(ossim_int32 idx = 0; idx < numberOfBands; ++idx)
296  {
297  getline(in, buffer);
298  if(buffer.find("Band") != string::npos)
299  {
300  string::size_type offset = buffer.find(":");
301  if(offset != string::npos)
302  {
303  bandBuffer = buffer.substr(offset+1);
304  }
305  else
306  {
308  return false;
309  }
310  }
311  else
312  {
314  return false;
315  }
316  ossim_uint32 bandIdx = bandBuffer.toUInt32();
317 
318  if(bandIdx < theHistogramList.size())
319  {
320  if(!theHistogramList[bandIdx].valid())
321  {
323  if(histogram->importHistogram(in))
324  {
325  theHistogramList[bandIdx] = histogram;
326  }
327  else
328  {
330  return false;
331  }
332  }
333  }
334  else
335  {
337  return false;
338  }
339  }
340  }
341  else
342  {
343  return false;
344  }
345  }
346  return true;
347 }
ossim_uint32 toUInt32() const
std::istream & getline(std::istream &is, ossimString &str, char delim)
Definition: ossimString.h:916
unsigned int ossim_uint32
virtual bool importHistogram(const ossimFilename &inputFile)
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList
std::string substr(std::string::size_type pos=0, std::string::size_type n=std::string::npos) const
Equivalent to basic_string(*this, pos, n).
Definition: ossimString.h:910
std::string::size_type find(const std::string &s, std::string::size_type pos=0) const
Searches for s as a substring of *this, beginning at character pos of *this.
Definition: ossimString.h:753
int ossim_int32

◆ loadState() [1/2]

bool ossimMultiBandHistogram::loadState ( const ossimKeywordlist kwl,
const char *  prefix = 0 
)
virtual

Definition at line 465 of file ossimMultiBandHistogram.cpp.

References ossimString::c_str(), deleteHistograms(), ossimKeywordlist::find(), ossimHistogram::loadState(), theHistogramList, ossimString::toString(), and ossimString::toUInt32().

467 {
469  const char* number_of_bands = kwl.find(prefix, "number_of_bands");
470  if(number_of_bands)
471  {
472  ossim_uint32 numberOfBands = ossimString(number_of_bands).toUInt32();
473 
474  if(numberOfBands>0)
475  {
476  ossimString newPrefix;
477  for(ossim_uint32 idx = 0; idx < numberOfBands; ++idx)
478  {
479  ossimHistogram* histo = new ossimHistogram;
480 
481  newPrefix = prefix;
482  newPrefix += "band";
483  newPrefix += ossimString::toString(idx);
484  newPrefix += ".";
485 
486  histo->loadState(kwl, newPrefix.c_str());
487 
488  theHistogramList.push_back(histo);
489  }
490  }
491  }
492 
493  return true;
494 }
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
const char * find(const char *key) const
static ossimString toString(bool aValue)
Numeric to string methods.
ossim_uint32 toUInt32() const
unsigned int ossim_uint32
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList
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

◆ loadState() [2/2]

bool ossimMultiBandHistogram::loadState ( const ossimRefPtr< ossimXmlNode xmlNode)
virtual

Definition at line 521 of file ossimMultiBandHistogram.cpp.

References ossimXmlNode::getChildNodes(), ossimHistogram::loadState(), size, and theHistogramList.

522 {
523  theHistogramList.clear();
524  const vector<ossimRefPtr<ossimXmlNode> >& childNodes = xmlNode->getChildNodes();
525 
526  ossim_uint32 idx = 0;
527  ossim_uint32 maxCount = (ossim_uint32)childNodes.size();
528  for(idx = 0; idx < maxCount; ++idx)
529  {
530  if(childNodes[idx]->getTag() == "Band")
531  {
532  if(childNodes[idx]->getChildNodes().size())
533  {
535  histo->loadState(childNodes[idx]->getChildNodes()[0]);
536  theHistogramList.push_back(histo);
537  }
538  }
539  }
540 
541  return true;
542 }
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
const ossimXmlNode::ChildListType & getChildNodes() const
yy_size_t size
unsigned int ossim_uint32
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList

◆ parseProprietaryHistogram()

bool ossimMultiBandHistogram::parseProprietaryHistogram ( std::istream &  in)
protected

◆ saveState() [1/2]

bool ossimMultiBandHistogram::saveState ( ossimKeywordlist kwl,
const char *  prefix = 0 
) const
virtual

Definition at line 438 of file ossimMultiBandHistogram.cpp.

References ossimKeywordlist::add(), ossimString::c_str(), theHistogramList, and ossimString::toString().

440 {
441  kwl.add(prefix,
442  "type",
443  "ossimMultiBandHistogram",
444  true);
445  kwl.add(prefix,
446  "number_of_bands",
447  static_cast<ossim_uint32>(theHistogramList.size()),
448  true);
449 
450  for(ossim_uint32 idx = 0; idx < theHistogramList.size(); ++idx)
451  {
452  ossimString band = ossimString(prefix) + "band";
453  band += (ossimString::toString(idx) + ".");
454  if(theHistogramList[idx].valid())
455  {
456  ossimString newPrefix = (ossimString(prefix) + ossimString::toString(idx) + ".");
457 
458  theHistogramList[idx]->saveState(kwl, band.c_str());
459  }
460  }
461 
462  return true;
463 }
static ossimString toString(bool aValue)
Numeric to string methods.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
unsigned int ossim_uint32
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList
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

◆ saveState() [2/2]

bool ossimMultiBandHistogram::saveState ( ossimRefPtr< ossimXmlNode xmlNode) const
virtual

Definition at line 496 of file ossimMultiBandHistogram.cpp.

References ossimXmlNode::addAttribute(), ossimXmlNode::addChildNode(), ossimRefPtr< T >::get(), ossimXmlNode::setTag(), theHistogramList, and ossimString::toString().

497 {
498  xmlNode->setTag("ossimMutliBandHistogram");
499  for(ossim_uint32 idx = 0; idx < theHistogramList.size(); ++idx)
500  {
503 
504  band->setTag("Band");
505  band->addAttribute("idx", ossimString::toString(idx));
506  band->addChildNode(newNode.get());
507  if(theHistogramList[idx].valid())
508  {
509  theHistogramList[idx]->saveState(newNode);
510  }
511  else
512  {
513  newNode->setTag("ossimHistogram");
514  }
515  xmlNode->addChildNode(band.get());
516  }
517 
518  return true;
519 }
void setTag(const ossimString &tag)
static ossimString toString(bool aValue)
Numeric to string methods.
unsigned int ossim_uint32
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList
void addAttribute(ossimRefPtr< ossimXmlAttribute > attribute)
void addChildNode(ossimRefPtr< ossimXmlNode > node)

◆ setBinCount()

void ossimMultiBandHistogram::setBinCount ( double  binNumber,
double  count 
)

Definition at line 206 of file ossimMultiBandHistogram.cpp.

References theHistogramList.

207 {
208  if(theHistogramList.size() > 0)
209  {
210  for(ossim_uint32 idx = 0; idx < theHistogramList.size(); ++idx)
211  {
212  if(theHistogramList[idx].valid())
213  {
214  theHistogramList[idx]->SetCount(binNumber, count);
215  }
216  }
217  }
218 }
unsigned int ossim_uint32
std::vector< ossimRefPtr< ossimHistogram > > theHistogramList

Member Data Documentation

◆ theHistogramList

std::vector<ossimRefPtr<ossimHistogram> > ossimMultiBandHistogram::theHistogramList
protected

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