OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimHistogramRemapper.h
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: David Burken
6 //
7 // Description:
8 //
9 // Histogram remapper class declaration. Derived from ossimTableRemapper.
10 //
11 // Remaps a tile based on mode and histogram clip points. This object uses
12 // a precomputed remap table for speed; hence, derived from the
13 // ossimTableRemapper
14 //
15 // NOTE on bands:
16 //
17 // - All methods take zero based bands. In other words the first
18 // band is band "0".
19 //
20 // - This objects band 0 is the same band 0 as it's input connection. If
21 // the band order was changed by a ossimBandSelector then this band 0 will
22 // not map to the histogram files band 0. To handle this,
23 // the "getOutputBandList()" method is used to get the correct histogram for
24 // the input band.
25 //
26 // - The "get" methods that do not take a band, simply return the average of
27 // all bands. This really only makes sense if all bands are the same
28 // but is provided for convenience.
29 //
30 //*************************************************************************
31 // $Id: ossimHistogramRemapper.h 22746 2014-04-23 16:16:28Z gpotts $
32 #ifndef ossimHistogramRemapper_HEADER
33 #define ossimHistogramRemapper_HEADER 1
34 
37 
38 
40 {
41 public:
43  {
44  LINEAR_ONE_PIECE = 0,
45  LINEAR_1STD_FROM_MEAN = 1,
46  LINEAR_2STD_FROM_MEAN = 2,
47  LINEAR_3STD_FROM_MEAN = 3,
48  LINEAR_AUTO_MIN_MAX = 4,
49  LINEAR_AUTO_PERCENTILE = 5,
50  STRETCH_UNKNOWN = 6 // Alway last as used for number of modes method.
51  };
52 
55 
56 
57  virtual ossimString getLongName() const;
58  virtual ossimString getShortName() const;
59 
60  virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tile_rect,
61  ossim_uint32 resLevel=0);
62 
63  virtual void initialize();
69  void reset();
70 
80  void setStretchMode(StretchMode mode, bool rebuildTableFlag=false);
81 
93  void setStretchModeAsString(const ossimString& mode,
94  bool rebuildTableFlag=false);
95 
99  StretchMode getStretchMode() const;
100 
104  ossimString getStretchModeString() const;
105 
109  ossim_uint32 getNumberOfStretchModes() const;
110 
124  ossimString getStretchModeString(ossim_uint32 index) const;
125 
140  void setLowNormalizedClipPoint(const ossim_float64& clip);
141 
154  void setLowNormalizedClipPoint(const ossim_float64& clip,
155  ossim_uint32 zero_based_band);
156 
167  void setHighNormalizedClipPoint(const ossim_float64& clip);
168 
177  void setHighNormalizedClipPoint(const ossim_float64& clip,
178  ossim_uint32 zero_based_band);
179 
189  void setLowClipPoint(const ossim_float64& clip);
190 
198  void setLowClipPoint(const ossim_float64& clip,
199  ossim_uint32 zero_based_band);
200 
210  void setHighClipPoint(const ossim_float64& clip);
211 
219  void setHighClipPoint(const ossim_float64& clip,
220  ossim_uint32 zero_based_band);
221 
229  void setMidPoint(const ossim_float64& value);
230 
234  void setMidPoint(const ossim_float64& value,
235  ossim_uint32 zero_based_band);
236 
244  void setMinOutputValue(const ossim_float64& value);
245 
249  void setMinOutputValue(const ossim_float64& value,
250  ossim_uint32 zero_based_band);
251 
259  void setMaxOutputValue(const ossim_float64& value);
260 
264  void setMaxOutputValue(const ossim_float64& value,
265  ossim_uint32 zero_based_band);
266 
274  ossim_float64 getLowNormalizedClipPoint(ossim_uint32 zero_based_band) const;
275 
284  ossim_float64 getLowNormalizedClipPoint() const;
285 
294  ossim_float64 getHighNormalizedClipPoint(ossim_uint32 zero_based_band) const;
303  ossim_float64 getHighNormalizedClipPoint() const;
304 
314  ossim_float64 getLowClipPoint(ossim_uint32 zero_based_band) const;
315 
324  ossim_float64 getLowClipPoint() const;
325 
335  ossim_float64 getHighClipPoint(ossim_uint32 zero_based_band) const;
336 
345  ossim_float64 getHighClipPoint() const;
346 
347 
356  ossim_float64 getMidPoint(ossim_uint32 zero_based_band) const;
357 
366  ossim_float64 getMidPoint() const;
367 
375  ossim_float64 getMinOutputValue(ossim_uint32 zero_based_band) const;
376 
384  ossim_float64 getMinOutputValue() const;
385 
393  ossim_float64 getMaxOutputValue(ossim_uint32 zero_based_band) const;
394 
402  ossim_float64 getMaxOutputValue() const;
403 
409  void setHistogram(ossimRefPtr<ossimMultiResLevelHistogram> histogram);
410 
413 
425  ossimRefPtr<ossimHistogram> getHistogram(ossim_uint32 zero_based_band,
426  ossim_uint32 res_level=0) const;
427 
433  bool openHistogram(const ossimFilename& histogram_file);
434 
442  bool computeHistogram(const ossimIrect& roi);
443 
448  ossimFilename getHistogramFile() const;
449 
454  virtual bool saveState(ossimKeywordlist& kwl,
455  const char* prefix=0)const;
456 
457 
463  virtual bool loadState(const ossimKeywordlist& kwl,
464  const char* prefix=0);
465 
466 
467  virtual ostream& print(ostream& os) const;
468 
472  virtual double getMinPixelValue(ossim_uint32 band=0)const;
473 
477  virtual double getMaxPixelValue(ossim_uint32 band=0)const;
478 
483  bool canConnectMyInputTo(ossim_int32 inputIndex,
484  const ossimConnectableObject* object)const;
485 
486 protected:
488  virtual ~ossimHistogramRemapper();
489 
490 private:
491  // Do not allow copy constructor, operator=.
494 
495  void buildTable();
496  void buildLinearTable();
497  void buildAutoLinearMinMaxTable();
498  void buildAutoLinearPercentileTable();
499  template <class T> void buildLinearTable(T dummy);
500  template <class T> void buildAutoLinearMinMaxTableTemplate(T dummy);
501  template <class T> void buildAutoLinearPercentileTableTemplate(T dummy);
502 
507  void buildLinearTableStdFromMean();
508 
513  void initializeClips();
514 
518  void initializeClips(ossim_uint32 bands);
519 
520  /*
521  * Sets the count of the null bin to 0 so that clips from the low end
522  * ignore the null bin.
523  */
524  void setNullCount();
525 
526  void initializeMinMaxOutput();
527 
535  void setupTable();
536 
541  void verifyEnabled();
542 
548  ossim_uint32 getHistogramBand(ossim_uint32 input_band) const;
549 
554  void setBypassFlag(bool flag);
555 
560  void makeClean();
561 
562  template <class T> void applyLinearStretch(
563  T dummy,
564  ossimRefPtr<ossimImageData>& inputTile);
565 
566 
570  vector<ossim_float64> theNormalizedLowClipPoint;
571  vector<ossim_float64> theNormalizedHighClipPoint;
572  vector<ossim_float64> theMidPoint;
573  vector<ossim_float64> theMinOutputValue;
574  vector<ossim_float64> theMaxOutputValue;
575 
576  // Maps zero based band to histogram band.
577  vector<ossim_uint32> theBandList;
578 
579  // Internally bypassed flag.
582 
583  TYPE_DATA
584 };
585 
586 #endif /* #ifndef ossimHistogramRemapper_HEADER */
ossimTableRemapper & operator=(const ossimTableRemapper &tr)
virtual ostream & print(ostream &os) const
Outputs theErrorStatus as an ossimErrorCode and an ossimString.
vector< ossim_float64 > theNormalizedLowClipPoint
#define OSSIMDLLEXPORT
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save the state of an object to a keyword list.
virtual ossimRefPtr< ossimImageData > getTile(const ossimIrect &tile_rect, ossim_uint32 resLevel=0)
Represents serializable keyword/value map.
ossimRefPtr< ossimMultiResLevelHistogram > theHistogram
vector< ossim_uint32 > theBandList
vector< ossim_float64 > theNormalizedHighClipPoint
virtual ossimString getShortName() const
Definition: ossimObject.cpp:48
virtual void initialize()
virtual double getMinPixelValue(ossim_uint32 band=0) const
Returns the min pixel of the band.
double ossim_float64
vector< ossim_float64 > theMinOutputValue
bool canConnectMyInputTo(ossim_int32 inputIndex, const ossimConnectableObject *object) const
required to be overriden by derived classes
#define TYPE_DATA
Definition: ossimRtti.h:339
unsigned int ossim_uint32
virtual ossimString getLongName() const
Definition: ossimObject.cpp:53
vector< ossim_float64 > theMaxOutputValue
virtual double getMaxPixelValue(ossim_uint32 band=0) const
Returns the max pixel of the band.
vector< ossim_float64 > theMidPoint
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
Method to the load (recreate) the state of an object from a keyword list.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
int ossim_int32