/usr/include/ossim/imaging/ossimHistogramRemapper.h is in libossim-dev 1.8.16-3+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 | //*******************************************************************
//
// License: See top level LICENSE.txt file.
//
// Author: David Burken
//
// Description:
//
// Histogram remapper class declaration. Derived from ossimTableRemapper.
//
// Remaps a tile based on mode and histogram clip points. This object uses
// a precomputed remap table for speed; hence, derived from the
// ossimTableRemapper
//
// NOTE on bands:
//
// - All methods take zero based bands. In other words the first
// band is band "0".
//
// - This objects band 0 is the same band 0 as it's input connection. If
// the band order was changed by a ossimBandSelector then this band 0 will
// not map to the histogram files band 0. To handle this,
// the "getOutputBandList()" method is used to get the correct histogram for
// the input band.
//
// - The "get" methods that do not take a band, simply return the average of
// all bands. This really only makes sense if all bands are the same
// but is provided for convenience.
//
//*************************************************************************
// $Id: ossimHistogramRemapper.h 21787 2012-09-30 21:27:09Z gpotts $
#ifndef ossimHistogramRemapper_HEADER
#define ossimHistogramRemapper_HEADER
#include <ossim/imaging/ossimTableRemapper.h>
#include <ossim/base/ossimMultiResLevelHistogram.h>
class OSSIMDLLEXPORT ossimHistogramRemapper : public ossimTableRemapper
{
public:
enum StretchMode
{
LINEAR_ONE_PIECE = 0,
LINEAR_1STD_FROM_MEAN = 1,
LINEAR_2STD_FROM_MEAN = 2,
LINEAR_3STD_FROM_MEAN = 3,
LINEAR_AUTO_MIN_MAX = 4,
STRETCH_UNKNOWN = 5 // Alway last as used for number of modes method.
};
/** default constructor */
ossimHistogramRemapper();
virtual ossimString getLongName() const;
virtual ossimString getShortName() const;
virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tile_rect,
ossim_uint32 resLevel=0);
virtual void initialize();
/**
* - Disables this source.
* - Sets all clip points to default.
* - Removes current table.
*/
void reset();
/**
* Sets remap mode to mode. If rebuildTableFlag is true, the table will
* be built at this time; else just the dirty flag is set.
*
* @param mode The stretch mode.
*
* @param rebuildTableFlag If the true the table will be rebuilt; else,
* just the dirty flag will be set.
*/
void setStretchMode(StretchMode mode, bool rebuildTableFlag=false);
/**
* Stretch mode values can be linear_one_piece, linear_1std_from_mean,
* linear_2std_from_mean, linear_3std_from_mean, linear_auto_min_max,
* If rebuildTableFlag is true, the table will
* be built at this time; else just the dirty flag is set.
*
* @param mode The stretch mode.
*
* @param rebuildTableFlag If the true the table will be rebuilt; else,
* just the dirty flag will be set.
*/
void setStretchModeAsString(const ossimString& mode,
bool rebuildTableFlag=false);
/**
* Returns the current enumerated node.
*/
StretchMode getStretchMode() const;
/**
* Returns the string for current remap mode.
*/
ossimString getStretchModeString() const;
/**
* Returns the number of stretch modes.
*/
ossim_uint32 getNumberOfStretchModes() const;
/**
* Returns the mode string for a given index.
* Returns "stretch_unknown" if index is out of range.
*
* NOTE:
* - If you're building gui buttons you can:
* // pseudo code...
* ossim_uint32 number_of_modes = remapper->getNumberOfModes()
* for (ossim_uint32 i = 0; i < number_of_modes; ++i)
* {
* addButton(getModeString(i).c_str());
* }
*/
ossimString getStretchModeString(ossim_uint32 index) const;
/**
* Sets the low clip point.
*
* Note on null bin:
* - The null bin is ignored when considering a percent of penetration from
* the low end.
*
* Notes on clip point:
* - If input chip source is mutiband this will set all band to same
* percentage of clip.
* - Clip points should be normalized between zero and one.
* - A low clip point of 0.0 means no penetration.
* - A low clip point of 0.02 means penetrate in two percent.
*/
void setLowNormalizedClipPoint(const ossim_float64& clip);
/**
* Sets the low clip point for band.
*
* Note on null bin:
* - The null bin is ignored when considering a percent of penetration from
* the low end.
*
* Notes on clip points:
* - Clip point should be normalized between zero and one.
* - A low clip point of 0.0 means no penetration.
* - A low clip point of 0.02 means penetrate in two percent.
*/
void setLowNormalizedClipPoint(const ossim_float64& clip,
ossim_uint32 zero_based_band);
/**
* Sets the high clip point.
*
* Notes on clip points:
* - If input chip source is mutiband this will set all band to same
* percentage of clip.
* - Clip point should be normalized between zero and one.
* - A high clip point of 1.0 means no penetration.
* - A high clip point of .98 mean a 2 % penetration from the high end.
*/
void setHighNormalizedClipPoint(const ossim_float64& clip);
/**
* Sets the high clip point.
*
* Notes on clip points:
* - Clip point should be normalized between zero and one.
* - A high clip point of 1.0 means no penetration.
* - A high clip point of .98 mean a 2 % penetration from the high end.
*/
void setHighNormalizedClipPoint(const ossim_float64& clip,
ossim_uint32 zero_based_band);
/**
* Sets the low clip point.
*
* Notes on clip point:
* - If input chip source is mutiband this will set all band to same
* percentage of clip.
* - Clip points are in DN values.
* - If histogram is not set no action is taken.
*/
void setLowClipPoint(const ossim_float64& clip);
/**
* Sets the low clip point for band.
*
* Notes on clip points:
* - Clip points are DN values.
* - If histogram is not set no action is taken.
*/
void setLowClipPoint(const ossim_float64& clip,
ossim_uint32 zero_based_band);
/**
* Sets the high clip point.
*
* Notes on clip points:
* - If input chip source is mutiband this will set all band to same
* percentage of clip.
* - Clip points are DN values.
* - If histogram is not set no action is taken.
*/
void setHighClipPoint(const ossim_float64& clip);
/**
* Sets the high clip point.
*
* Notes on clip points:
* - Clip points are DN values.
* - If histogram is not set no action is taken.
*/
void setHighClipPoint(const ossim_float64& clip,
ossim_uint32 zero_based_band);
/**
* Sets the mid clip point.
*
* Notes on clip points:
* - If input chip source is mutiband this will set all band to same
* percentage of clip.
*/
void setMidPoint(const ossim_float64& value);
/**
* Sets the mid clip point for band.
*/
void setMidPoint(const ossim_float64& value,
ossim_uint32 zero_based_band);
/**
* Sets the min output value.
*
* Notes on clip points:
* - If input chip source is mutiband this will set all band to same
* percentage of clip.
*/
void setMinOutputValue(const ossim_float64& value);
/**
* Sets the min output value for band.
*/
void setMinOutputValue(const ossim_float64& value,
ossim_uint32 zero_based_band);
/**
* Sets the max output value.
*
* Notes on clip points:
* - If input chip source is mutiband this will set all band to same
* percentage of clip.
*/
void setMaxOutputValue(const ossim_float64& value);
/**
* Sets the min output value for band.
*/
void setMaxOutputValue(const ossim_float64& value,
ossim_uint32 zero_based_band);
/**
* Returns the normalized low clip point for band.
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
* - Histogram has not been set.
*/
ossim_float64 getLowNormalizedClipPoint(ossim_uint32 zero_based_band) const;
/**
* Returns the normalized low clip point which is the average of all bands.
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
* - Histogram has not been set.
*/
ossim_float64 getLowNormalizedClipPoint() const;
/**
* Returns the normalized high clip point for band.
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
* - Histogram has not been set.
*/
ossim_float64 getHighNormalizedClipPoint(ossim_uint32 zero_based_band) const;
/**
* Returns the normalized High clip point which is the average of all bands.
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
* - Histogram has not been set.
*/
ossim_float64 getHighNormalizedClipPoint() const;
/**
* Returns the low clip point for band.
* Clip points are DN values relative to the scalar type.
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
* - Histogram has not been set.
*/
ossim_float64 getLowClipPoint(ossim_uint32 zero_based_band) const;
/**
* Returns the low clip point which is the average of all bands.
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
* - Histogram has not been set.
*/
ossim_float64 getLowClipPoint() const;
/**
* Returns the high clip point for band.
* Clip points are DN values relative to the scalar type.
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
* - Histogram has not been set.
*/
ossim_float64 getHighClipPoint(ossim_uint32 zero_based_band) const;
/**
* Returns the high clip point which is the average of all bands.
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
* - Histogram has not been set.
*/
ossim_float64 getHighClipPoint() const;
/**
* Returns the mid point for band
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
* - Histogram has not been set.
*/
ossim_float64 getMidPoint(ossim_uint32 zero_based_band) const;
/**
* Returns the mid clip point which is the average of all bands.
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
* - Histogram has not been set.
*/
ossim_float64 getMidPoint() const;
/**
* Returns the minimum output value for band.
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
*/
ossim_float64 getMinOutputValue(ossim_uint32 zero_based_band) const;
/**
* Returns the minimum output value which is the average of all bands.
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
*/
ossim_float64 getMinOutputValue() const;
/**
* Returns the maximum output value for band.
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
*/
ossim_float64 getMaxOutputValue(ossim_uint32 zero_based_band) const;
/**
* Returns the maximum output value which is the average of all bands.
*
* Will return OSSIM_DBL_NAN if:
* - Band is out of range.
* - Connection is not complete.
*/
ossim_float64 getMaxOutputValue() const;
/**
* Sets the histogram.
* If (own_histogram == true) this object will delete theHistogram
* on destruction.
*/
void setHistogram(ossimRefPtr<ossimMultiResLevelHistogram> histogram);
ossimRefPtr<ossimMultiResLevelHistogram> getHistogram();
ossimRefPtr<const ossimMultiResLevelHistogram> getHistogram()const;
/**
* Returns pointer to histogram for band and reduced res level.
* - Band is zero based relative to the input connection. This will be
* remapped to the histogram band using the "getOutputBandList()" to
* get the correct histogram band.
*
* Will return NULL if:
* - band is out range
* - res_level is out of range
* - theHistogram has not been initialized yet.
*/
ossimRefPtr<ossimHistogram> getHistogram(ossim_uint32 zero_based_band,
ossim_uint32 res_level=0) const;
/**
* Open the histogram file.
* With this method the histogram is owned by this object.
* Returns true on success, false on error.
*/
bool openHistogram(const ossimFilename& histogram_file);
/**
* Returns the currently opened histogram.
* Returns ossimFilename::NIL if no histogram is loaded.
*/
ossimFilename getHistogramFile() const;
/**
* Method to the save the state to a keyword list.
* Returns true if ok or false on error.
*/
virtual bool saveState(ossimKeywordlist& kwl,
const char* prefix=0)const;
void buildTable();
/**
* Method to the load (recreate) the state of an object from a keyword
* list.
* Returns true if ok or false on error.
*/
virtual bool loadState(const ossimKeywordlist& kwl,
const char* prefix=0);
virtual ostream& print(ostream& os) const;
friend ostream& operator <<(ostream& os, const ossimHistogramRemapper& hr);
/**
* Returns the min pixel of the band.
*/
virtual double getMinPixelValue(ossim_uint32 band=0)const;
/**
* Returns the max pixel of the band.
*/
virtual double getMaxPixelValue(ossim_uint32 band=0)const;
/**
* Will test for the input being a ossimHistogramSource and allow pulling the histogram
* from a histogram source.
*/
bool canConnectMyInputTo(ossim_int32 inputIndex,
const ossimConnectableObject* object)const;
protected:
/** virtual destructor */
virtual ~ossimHistogramRemapper();
private:
// Do not allow copy constructor, operator=.
ossimHistogramRemapper(const ossimHistogramRemapper& hr);
ossimHistogramRemapper& operator=(const ossimHistogramRemapper& hr);
void buildLinearTable();
void buildAutoLinearMinMaxTable();
template <class T> void buildLinearTable(T dummy);
template <class T> void buildAutoLinearMinMaxTableTemplate(T dummy);
/**
* Sets clip points using mean and standard deviations then calls
* buildLinearTable method.
*/
void buildLinearTableStdFromMean();
/**
* Uses getNumberOfInputBands() to determine BANDS then calls
* initializeClips(BANDS)
*/
void initializeClips();
/**
* Initializes data members to some default state and size.
*/
void initializeClips(ossim_uint32 bands);
/*
* Sets the count of the null bin to 0 so that clips from the low end
* ignore the null bin.
*/
void setNullCount();
void initializeMinMaxOutput();
/**
* Initialized base class (ossimTableRemapper) values:
* - theTableBinCount
* - theTableBandCount
* - theTableType
* - theTable (resizes if not correct size.
*/
void setupTable();
/**
* This set theBypassFlag. This is an internally used flag to signal that
* there is nothing to do in this filter; hence, bypass.
*/
void verifyEnabled();
/**
* Returns the histogram band that maps to the input band.
* Note:
* - This uses the current band list from "getOutputBandList()".
*/
ossim_uint32 getHistogramBand(ossim_uint32 input_band) const;
/**
* Sets theBypassFlag. If the start changes from bypassed to not bypassed
* this will set theDirtyFlag to true.
*/
void setBypassFlag(bool flag);
/**
* If we are dirty then it will init what it needs and then set
* the dirty back to false;
*/
void makeClean();
StretchMode theStretchMode;
bool theDirtyFlag;
mutable ossimRefPtr<ossimMultiResLevelHistogram> theHistogram;
vector<ossim_float64> theNormalizedLowClipPoint;
vector<ossim_float64> theNormalizedHighClipPoint;
vector<ossim_float64> theMidPoint;
vector<ossim_float64> theMinOutputValue;
vector<ossim_float64> theMaxOutputValue;
// Maps zero based band to histogram band.
vector<ossim_uint32> theBandList;
// Internally bypassed flag.
bool theBypassFlag;
bool theResetBandIndicesFlag;
TYPE_DATA
};
#endif /* #ifndef ossimHistogramRemapper_HEADER */
|