This file is indexed.

/usr/include/ossim/imaging/ossimImageData.h is in libossim-dev 1.7.21-3ubuntu2.

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
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
//*******************************************************************
//
// License:  LGPL
// 
// See LICENSE.txt file in the top level directory for more details.
//
// Author: Garrett Potts
// 
// Description: Container class for a tile of image data.
//
//*******************************************************************
// $Id: ossimImageData.h 15072 2009-08-13 18:37:43Z dburken $
#ifndef ossimImageData_HEADER
#define ossimImageData_HEADER

#include <vector>

#include <ossim/base/ossimCommon.h>
#include <ossim/base/ossimRectilinearDataObject.h>
#include <ossim/base/ossimIrect.h>
#include <ossim/base/ossimIpt.h>
#include <ossim/base/ossimRefPtr.h>

class ossimMultiBandHistogram;

class OSSIMDLLEXPORT ossimImageData : public ossimRectilinearDataObject
{
public:

   /** Definitions for the unloadBand routines. */
   enum OverwriteBandRule
   {
      /*
       * The COLOR_DISCREPANCY rule directs that the selected band of a pixel
       * of the destination buffer is to be overwritten if any one of the other 
       * bands of the same pixel have color values that deviate from the  
       * color value of the selected band. 
       */
      COLOR_DISCREPANCY = 0,
      
      /*
       * The selected band of the destination buffer is to be overwritten 
       * by the selected band of the source image data (no questions asked).
       */
      NULL_RULE = 1
   };

   /** @brief copy constructor */
   ossimImageData(const ossimImageData &rhs);

   /**
    * @brief Constructor
    * @param source The owner.  This can be null.
    * @param scalar The Scalar type like OSSIM_UINT8, OSSIM_UINT16...
    * @param bands  The number of bands.
    * 
    * @note This does not initialize the undelying data buffer.
    *       Call the initialize method to allocate storage.
    */
   ossimImageData(ossimSource* source,
                  ossimScalarType scalar,
                  ossim_uint32 bands = 1);

   /**
    * @brief Constructor
    * @param source The owner.  This can be null.
    * @param scalar The Scalar type like OSSIM_UINT8, OSSIM_UINT16...
    * @param bands  The number of bands.
    * @param width  The width or number of samples in the buffer.
    * @param height The height or numer of lines in the buffer.
    * 
    * @note This does not initialize the undelying data buffer.
    *       Call the initialize method to allocate storage.
    */
   ossimImageData(ossimSource* source,
                  ossimScalarType scalar,
                  ossim_uint32 bands,
                  ossim_uint32 width,
                  ossim_uint32 height);

   /** @brief virtual destructor */
   virtual ~ossimImageData();

   /**
    * @return The width of the data object.
    */
   virtual ossim_uint32 getWidth()const;

   /**
    * @return The height of the data object.
    */
   virtual ossim_uint32 getHeight()const;

   /**
    * @return The image rectangle relative to origin, height and width.
    */
   virtual ossimIrect getImageRectangle() const;
   virtual void getWidthHeight(ossim_uint32& w, ossim_uint32& h);
   virtual void setWidth(ossim_uint32 width);
   virtual void setHeight(ossim_uint32 height);
   virtual void setWidthHeight(ossim_uint32 w, ossim_uint32 h);
   virtual void setImageRectangleAndBands(const ossimIrect& rect,
                                          ossim_uint32 numberOfBands);
   virtual void setImageRectangle(const ossimIrect& rect);
   virtual void setOrigin(const ossimIpt& origin);   
                                    
   virtual void assign(const ossimDataObject* data);
   virtual void assign(const ossimImageData* data);
   virtual void assignBand(const ossimImageData* data,
                           ossim_uint32 source_band,
                           ossim_uint32 output_band);
   
   virtual ossimObject* dup() const;

  /**
   * Uses prime numbers as coefficients for this summation.  
   * Take the the fours bytes of each origin and multiply 
   * by the prime numbers and sum together.  This has
   * been proven by others to give nicely distributed 
   * id number.
   */
   virtual ossim_uint32 getHashId()const;
   
   virtual void setNullPix(ossim_float64 null_pix);
   virtual void setNullPix(ossim_float64 null_pix, ossim_uint32 band);
   virtual void setNullPix(const ossim_float64* nullPixArray,
                           ossim_uint32 numberOfValues);
   virtual void setMinPix(ossim_float64 min_pix);
   virtual void setMinPix(ossim_float64 min_pix, ossim_uint32 band);
   virtual void setMinPix(const ossim_float64* minPixArray,
                          ossim_uint32 numberOfValues);
   virtual void setMaxPix(ossim_float64 max_pix);
   virtual void setMaxPix(ossim_float64 max_pix, ossim_uint32 band);
   virtual void setMaxPix(const ossim_float64* maxPixArray,
                          ossim_uint32 numberOfValues);

   virtual const ossimIpt& getOrigin()const{return theOrigin;}

   /**
    * If the minBands and maxBands are empty or not equal to the imageData's
    * current number of bands it will erase the contents, resize, and then
    * replace the values in the passed in array with this objects min max
    * values.  If the arrays are the same size as this objects number of
    * bands it will just update the values and use the current values in the
    * arrays as initial min max values.
    *
    * If the status of this object(getDataObjectStatus()) is OSSIM_NULL or
    * OSSIM_EMPTY no action is performed.
    */
   virtual void computeMinMaxPix(std::vector<ossim_float64>& minBands,
                                 std::vector<ossim_float64>& maxBands);
   
   virtual const ossim_float64* getNullPix()const;
   virtual const ossim_float64* getMinPix()const;
   virtual const ossim_float64* getMaxPix()const;
   virtual ossim_float64        getNullPix(ossim_uint32 band) const;
   virtual ossim_float64        getMinPix(ossim_uint32 band)  const;
   virtual ossim_float64        getMaxPix(ossim_uint32 band)  const;

   /**
    * returns normalized minimum pixel value of band zero.
    */
   virtual ossim_float64   getMinNormalizedPix() const;
   virtual ossimString     getScalarTypeAsString()const;
   virtual ossim_uint32    getNumberOfBands() const;
   virtual void            setNumberOfBands(ossim_uint32 bands,
                                            bool reallocate=false);

   /**
    * Will return the pixel at location position.  Note it will first get
    * the passed in position relative to the origin or upper left
    * corner of this tile and then return the result.
    */
   virtual ossim_float64 getPix(const ossimIpt& position,
                                ossim_uint32 band=0) const;

   /**
    * Will return the pixel at offset and band number.
    */
   virtual ossim_float64 getPix(ossim_uint32 offset,
                                ossim_uint32 band = 0) const;
   
   /**
    * will fill the entire band with
    * the value.
    */
   void fill(ossim_uint32 band, ossim_float64 value);

   /**
    * will fill all bands with the passed in
    * value.
    */
   void fill(ossim_float64 value);
   bool isNull(ossim_uint32 offset)const;
   bool isNull(ossim_uint32 offset, ossim_uint32 band)const;
   void setNull(ossim_uint32 offset);
   void setNull(ossim_uint32 offset, ossim_uint32 band);

   bool isNull(const ossimIpt& pt)const;
   void setNull(const ossimIpt& pt);
   bool isNull(const ossimIpt& pt, ossim_uint32 band)const;
   void setNull(const ossimIpt& pt, ossim_uint32 band);
   
   virtual bool   isValidBand(ossim_uint32 band) const;
   virtual ossimDataObjectStatus validate() const;

   /**
    * Will take this tile and normalize it to a newly
    * allocated floating point tile.
    */
   virtual ossimRefPtr<ossimImageData> newNormalizedFloat()const;

   /**
    * will go to the band and offset and compute the
    * normalized float and return it back to the
    * caller through the result argument.
    */
   virtual void getNormalizedFloat(ossim_uint32 offset,
                                   ossim_uint32 bandNumber,
                                   ossim_float32& result)const;

   /**
    * This will assign to this object a normalized
    * value by unnormalizing to its native type.
    */
   virtual void setNormalizedFloat(ossim_uint32 offset,
                                   ossim_uint32 bandNumber,
                                   ossim_float32 input);

   /**
    * Will use the memory that you pass in to normalize
    * this data object.
    */
   virtual void convertToNormalizedFloat(ossimImageData* result)const;

   /**
    * Will take this tile and normalize it to a newly
    * allocated double point tile.
    */
   virtual ossimImageData* newNormalizedDouble()const;

   /**
    * Will use the memory that you pass in to normalize
    * this data object.
    */
   virtual void convertToNormalizedDouble(ossimImageData* result)const;

   /**
    * Will take the normalized input and convert it
    * to this tile's data type.  Example:  if this
    * tile is of type UCHAR and its input is of type
    * NORALIZED_FLOAT it will unnormalize the data by
    * doing:
    *
    * minPix + normalizedInput*(maxPix-minPix)
    *
    * on a per band basis.
    */
   virtual void unnormalizeInput(ossimImageData* normalizedInput);

   /**
    * This will compute the average value for the band.
    */
   virtual ossim_float64 computeAverageBandValue(
      ossim_uint32 bandNumber = 0) const;

   /**
    * This will call the compute average band value and then
    * use that in the calculation of:
    
    * It will then do a SUM[(Mean - Actual)^2]/width*height.
    *
    * This is the average variance from the passed in
    * mean.  
    */
   virtual ossim_float64 computeMeanSquaredError(
      ossim_float64 meanValue,
      ossim_uint32 bandNumber = 0) const;
  
   virtual void populateHistogram(ossimRefPtr<ossimMultiBandHistogram> histo);

   /**
    * @return const void* to theDataBuffer
    */
   virtual const void* getBuf() const;
   
   /**
    * @return const ossim_uint8* to theDataBuffer if scalar is of type
    * OSSIM_UCHAR; else, NULL.
    */
   virtual const ossim_uint8*    getUcharBuf()  const;

   /**
    * @return const ossim_uint16* to theDataBuffer if scalar is of type
    * OSSIM_USHORT16 or USHORT11; else, NULL.
    */
   virtual const ossim_uint16*   getUshortBuf() const;

   /**
    * @return const ossim_sint16* to theDataBuffer if scalar is of type
    * OSSIM_SSHORT16; else, NULL.
    */
   virtual const ossim_sint16*   getSshortBuf() const;

   /**
    * @return const ossim_float32* to theDataBuffer if scalar is of type
    * OSSIM_FLOAT or OSSIM_NORMALIZED_FLOAT; else, NULL.
    */
   virtual const ossim_float32*  getFloatBuf()  const;

   /**
    * @return const ossim_float64* to theDataBuffer if scalar is of type
    * OSSIM_DOUBLE or OSSIM_NORMALIZED_DOUBLE; else, NULL.
    */
   virtual const ossim_float64*  getDoubleBuf() const;

   /**
    * @return void* to theDataBuffer
    */
   virtual void* getBuf();
   
   /**
    * @return ossim_uint8* to theDataBuffer if scalar is of type
    * OSSIM_UCHAR; else, NULL.
    */
   virtual ossim_uint8*    getUcharBuf();
   
   /**
    * @return ossim_uint16* to theDataBuffer if scalar is of type
    * OSSIM_USHORT16 or OSSIM_USHORT11; else, NULL.
    */
   virtual ossim_uint16*   getUshortBuf();
   
   /**
    * @return ossim_sint16* to theDataBuffer if scalar is of type
    * OSSIM_SSHORT16; else, NULL.
    */
   virtual ossim_sint16*   getSshortBuf();

   /**
    * @return ossim_float32* to theDataBuffer if scalar is of type
    * OSSIM_FLOAT or OSSIM_NORMALIZED_FLOAT; else, NULL.
    */
   virtual ossim_float32*  getFloatBuf();
   
   /**
    * @return float64* to theDataBuffer if scalar is of type OSSIM_DOUBLE or
    * OSSIM_NORMALIZED_DOUBLE; else, NULL.
    */
   virtual ossim_float64*  getDoubleBuf();

   /**
    * @param band (zero based)
    * @return void* to theDataBuffer positioned at band.
    */
   virtual const void*           getBuf(ossim_uint32 band) const;
   
   /**
    * @param band (zero based)
    * @return ossim_uint8* to theDataBuffer positioned at band if scalar is
    * of type OSSIM_UCHAR; else, NULL.
    */
   virtual const ossim_uint8*    getUcharBuf(ossim_uint32 band) const;

   /**
    * @param band (zero based)
    * @return ossim_uint16* to theDataBuffer positioned at band if scalar is
    * of type OSSIM_USHORT16 or OSSIM_USHORT11; else, NULL.
    */
   virtual const ossim_uint16*   getUshortBuf(ossim_uint32 band) const;
   
   /**
    * @param band (zero based)
    * @return ossim_sint16* to theDataBuffer positioned at band if scalar is
    * of type OSSIM_SSHORT16; else, NULL.
    */
   virtual const ossim_sint16*   getSshortBuf(ossim_uint32 band) const;
   
   /**
    * @param band (zero based)
    * @return ossim_float32* to theDataBuffer positioned at band if scalar is
    * of type OSSIM_FLOAT or OSSIM_NORMALIZED_FLOAT; else, NULL.
    */
   virtual const ossim_float32*  getFloatBuf(ossim_uint32 band) const;
   
   /**
    * @param band (zero based)
    * @return ossim_float64* to theDataBuffer positioned at band if scalar is
    * of type OSSIM_DOUBLE or OSSIM_NORMALIZED_DOUBLE; else, NULL.
    */
   virtual const ossim_float64*  getDoubleBuf(ossim_uint32 band) const;

   /**
    * @param band (zero based)
    * @return void* to theDataBuffer positioned at band.
    */
   virtual void*           getBuf(ossim_uint32 band);
   
   /**
    * @param band (zero based)
    * @return ossim_uint8* to theDataBuffer positioned at band if scalar is
    * of type OSSIM_UCHAR; else, NULL.
    */
   virtual ossim_uint8*    getUcharBuf(ossim_uint32 band);
   
   /**
    * @param band (zero based)
    * @return ossim_uint16* to theDataBuffer positioned at band if scalar is
    * of type OSSIM_USHORT16 or OSSIM_USHORT11; else, NULL.
    */
   virtual ossim_uint16*   getUshortBuf(ossim_uint32 band);
   
   /**
    * @param band (zero based)
    * @return ossim_sint16* to theDataBuffer positioned at band if scalar is
    * of type OSSIM_SSHORT16; else, NULL.
    */
   virtual ossim_sint16*   getSshortBuf(ossim_uint32 band);
   
   /**
    * @param band (zero based)
    * @return ossim_float32* to theDataBuffer positioned at band if scalar is
    * of type OSSIM_FLOAT or OSSIM_NORMALIZED_FLOAT; else, NULL.
    */
   virtual ossim_float32*  getFloatBuf(ossim_uint32 band);
   
   /**
    * @param band (zero based)
    * @return ossim_float64* to theDataBuffer positioned at band if scalar is
    * of type OSSIM_DOUBLE or OSSIM_NORMALIZED_DOUBLE; else, NULL.
    */
   virtual ossim_float64*  getDoubleBuf(ossim_uint32 band);
   
   /**
    *  Returns the total number of pixels in a tile for all bands.
    *  Note:  This is not in bytes but in pixels.
    */
   virtual ossim_uint32 getSize() const;

   /**
    *  Returns the number of pixels in a single band in a tile.
    *  Note:  This is not in bytes but in pixels.
    */
   virtual ossim_uint32 getSizePerBand()const;

   /**
    *  Returns the number of bytes in single band of the tile.
    */
   virtual ossim_uint32 getSizePerBandInBytes() const;

   virtual ossim_uint32 getDataSizeInBytes()const;

   /**
    * Returns the total number of bytes for all bands.
    */
   virtual ossim_uint32  getSizeInBytes() const;

   /**
    *  Initializes data to null pixel values.
    */
   virtual void makeBlank();

   /**
    *  Initialize the data buffer.
    */
   virtual void initialize();

   /**
    * Copies entire tile to buf passed in.  Data put in buf is normalized.
    * The "buf" passed to method is assumed to be at least as big as:
    * "getSize() * sizeof(double)"
    */
   virtual void copyTileToNormalizedBuffer(ossim_float64* buf) const;
   virtual void copyTileToNormalizedBuffer(ossim_float32* buf)const;

   /**
    * Will copy this tiles specified band number to the normalized buffer.
    * if the band is out of range then nothing is done and returns.
    *
    * @param band Zero based band to copy.
    *
    * @param buf Buffer to copy to.
    */
   virtual void copyTileBandToNormalizedBuffer(ossim_uint32 band,
                                               ossim_float64* buf) const;
   
   /**
    * Will copy this tiles specified band number to the normalized buffer.
    * if the band is out of range then nothing is done and returns.
    *
    * @param band Zero based band to copy.
    *
    * @param buf Buffer to copy to.
    */
   virtual void copyTileBandToNormalizedBuffer(ossim_uint32 band,
                                               ossim_float32* buf)const;

   /**
    * Copies buf passed in to tile.  Data is unnormalized to the tile's
    * scalar type.
    * The "buf" passed to method is assumed to be at least as big as the tiles:
    * "getSize() * sizeof(double)"
    */
   virtual void copyNormalizedBufferToTile(ossim_float64* buf);
   virtual void copyNormalizedBufferToTile(ossim_float32* buf);

   /**
    * Will copy the normalized buffer to this tiles
    * specified band.  If band is out of range then nothing
    *
    * is done and returns.
    */
   virtual void copyNormalizedBufferToTile(ossim_uint32 band,
                                           ossim_float64* buf);
   virtual void copyNormalizedBufferToTile(ossim_uint32 band,
                                           ossim_float32* buf);

   virtual bool isWithin(ossim_int32 x, ossim_int32 y);
   virtual void setValue(ossim_int32 x, ossim_int32 y, ossim_float64 color);

   virtual void loadBand(const void* src,
                         const ossimIrect& src_rect,
                         ossim_uint32 band);

   virtual void loadBand(const void* src,
                         const ossimIrect& src_rect,
                         const ossimIrect& clip_rect,
                         ossim_uint32 band);
   
   virtual void loadTile(const void* src,
                         const ossimIrect& src_rect,
                         ossimInterleaveType il_type);

   virtual void loadTile(const void* src,
                         const ossimIrect& src_rect,
                         const ossimIrect& clip_rect,                         
                         ossimInterleaveType il_type);

   virtual void nullTileAlpha(const ossim_uint8* src,
                              const ossimIrect& src_rect,
                              bool mutliplyAlphaFlag=false);
   virtual void nullTileAlpha(const ossim_uint8* src,
                              const ossimIrect& src_rect,
                              const ossimIrect& clip_rect,
                              bool multiplyAlphaFlag=false);
   /**
    * Will load a tile of different types.  If they
    * are the same then it will call loadTile(void*...)
    * method.  Note if they are of different types we
    * will have to go through a much slower assign
    * process by normalizing the right side and then
    * unnormalizing to the destination type. For this
    * method to work they both must have the same
    * number of bands.
    */
   virtual void loadTile(const ossimImageData* src);
   
   virtual void loadTileFrom1Band(const ossimImageData* data);

   virtual void loadTileFrom1Band(const void* src,
                                  const ossimIrect& src_rect);
   /**
    * Specialized to load a tile from a short (16 bit scalar type) buffer.
    * Performs byte swapping if swap_bytes is set to true.
    */
   virtual void loadShortBand(const void* src,
                              const ossimIrect& src_rect,
                              ossim_uint32 band,
                              bool swap_bytes=false);

   /**
    * This routine is designed for overwriting a selected band of the 
    * destination buffer 'dest' by an independent selected band of the
    * source buffer according to a user-selected rule, defined by 
    * OverwriteBandRule.
    *
    * Currently the rules available in OverwriteBandRule are: 
    *
    * The COLOR_DISCREPANCY rule directs that the selected band of a pixel
    * of the destination buffer is to be overwritten if any one of the other 
    * bands of the same pixel have color values that deviate from the  
    * color value of the selected band. 
    *
    * The NULL_RULE rule directs that the selected band of the 
    * destination buffer is to be overwritten by the selected band of the 
    * source image data (no questions asked).
    *
    * @note The src object should have at least the same number of bands as 
    * the 'dest' buffer. 
    *
    * Currently this routine is only implemented for il_type set to OSSIM_BSQ.
    *
    * @param dest The destination buffer with at least the same number of bands
    * as the src (this) object.
    * @param src_band  The 0-based band of the source image data.
    * @param dest_band The 0-based band of the dest buffer.
    * @param dest_rect The rectangle of the destination buffer.
    * @param il_type   The interleave type. Only OSSIM_BSQ available.
    * @param ow_type   The rule for overwriting the destination buffer.
    */
   virtual void unloadBand( void* dest,
                            ossim_uint32 src_band,
                            ossim_uint32 dest_band,
                            const ossimIrect& dest_rect,
                            ossimInterleaveType il_type=OSSIM_BSQ,
                            OverwriteBandRule ow_type=NULL_RULE ) const;

   /**
    * This routine is designed for overwriting a selected band of the 
    * destination buffer 'dest' by an independent selected band of the
    * source buffer according to a user-selected rule, defined by 
    * OverwriteBandRule.
    *
    * Currently the rules available in OverwriteBandRule are: 
    *
    * The COLOR_DISCREPANCY rule directs that the selected band of a pixel
    * of the destination buffer is to be overwritten if any one of the other 
    * bands of the same pixel have color values that deviate from the  
    * color value of the selected band. 
    *
    * The NULL_RULE rule directs that the selected band of the 
    * destination buffer is to be overwritten by the selected band of the 
    * source image data (no questions asked).
    *
    * Note: The src object should have at least the same number of bands as 
    * the 'dest' buffer. 
    *
    * Currently this routine is only implemented for il_type set to OSSIM_BSQ.
    *
    * @param dest The destination buffer with at least the same number of bands
    * as the src (this) object.
    * @param src_band  The 0-based band of the source image data.
    * @param dest_band The 0-based band of the dest buffer.
    * @param dest_rect The rectangle of the destination buffer.
    * @param clip_rect Only data within will be copied.
    * @param il_type   The interleave type. Only OSSIM_BSQ available.
    * @param ow_type   The rule for overwriting the destination buffer.
    */
   virtual void unloadBand( void* dest,
                            ossim_uint32 src_band,
                            ossim_uint32 dest_band,
                            const ossimIrect& dest_rect,
                            const ossimIrect& clip_rect,
                            ossimInterleaveType il_type=OSSIM_BSQ,
                            OverwriteBandRule ow_type=NULL_RULE ) const;

   /**
    * @param dest The destination buffer.  It is assumed this is a single band
    * and the size of dest_rect.
    * @param dest_rect The rectangle of the destination buffer.
    * @param src_band The band to copy (unload) from the tile.
    */
   virtual void unloadBand(void* dest,
                           const ossimIrect& dest_rect,
                           ossim_uint32 src_band) const;

   /**
    * @param dest The destination buffer.  It is assumed this is a single band
    * and the size of dest_rect.
    * @param dest_rect The rectangle of the destination buffer.
    * param clip_rect Only data within the clip_rect will be copied.
    * @param src_band The band to copy (unload) from the tile.
    */
   virtual void unloadBand(void* dest,
                           const ossimIrect& dest_rect,
                           const ossimIrect& clip_rect,
                           ossim_uint32 src_band) const;
   
   virtual void unloadTile(void* dest,
                           const ossimIrect& dest_rect,
                           ossimInterleaveType il_type ) const;

   virtual void unloadTile(void* dest,
                           const ossimIrect& dest_rect,
                           const ossimIrect& clip_rect,
                           ossimInterleaveType il_type) const;
   
   virtual bool isPointWithin(const ossimIpt& point)const;
   virtual bool isPointWithin(ossim_int32 x,
                              ossim_int32 y)const;

   virtual std::ostream& print(std::ostream& out) const;
   
protected:

   ossimImageData();

   /**
    * Templated validate method.
    *
    * @return The status of the ossimImageDataMethod.
    *
    * @note See ossimConstants.h for ossimDataObjectStatus enumerations.
    */
   template <class T> ossimDataObjectStatus validate(T dummyTemplate) const;

   /**
    * Templated makeBlank method.
    */
   template <class T> void makeBlank(T dummyTemplate);

   /**
    * Templated computeMeanSquaredError method.
    */
   template <class T>
      ossim_float64 computeMeanSquaredError(T dummyTemplate,
                                            ossim_float64 meanValue,
                                            ossim_uint32 bandNumber) const;

   /**
    * Templated computeAverageBandValue method.
    */
   template <class T>
      ossim_float64 computeAverageBandValue(T dummyTemplate,
                                            ossim_uint32 bandNumber) const;
   
   /**
    *  
    *  Takes normPix, unnormalizes and initializes pixel.
    *  "band" is used as index to get the min/max/null values.
    */
   void getPixFromNorm(ossim_int32& pixel,
                       ossim_float32  normPix,
                       ossim_uint32 band) const;

   
   /**
    *  Takes normPix, unnormalizes and initializes pixel.
    *  "band" is used as index to get the min/max/null values.
    */
   void getPixFromNorm(ossim_int32& pixel,
                       ossim_float64 normPix,
                       ossim_uint32 band) const;

   /**
    *  Take pixel, normalizes and initializes normPix.
    *  "band" is used as index to get the min/max/null values.
    */
   void getNormFromPix  (ossim_int32  pixel,
                         ossim_float32& normPix,
                         ossim_uint32 band) const;

   /**
    *  Take pixel, normalizes and initializes normPix.
    *  "band" is used as index to get the min/max/null values.
    */
   void getNormFromPix (ossim_int32  pixel,
                        ossim_float64& normPix,
                        ossim_uint32 band) const;

   void loadTileFromBip(const void* src, const ossimIrect& src_rect);
   void loadTileFromBil(const void* src, const ossimIrect& src_rect);
   void loadTileFromBsq(const void* src, const ossimIrect& src_rect);

   void loadTileFromBip(const void* src,
                        const ossimIrect& src_rect,
                        const ossimIrect& clip_rect);
   void loadTileFromBil(const void* src,
                        const ossimIrect& src_rect,
                        const ossimIrect& clip_rect);
   void loadTileFromBsq(const void* src,
                        const ossimIrect& src_rect,
                        const ossimIrect& clip_rect);

   void unloadTileToBip(void* dest,
                        const ossimIrect& dest_rect,
                        const ossimIrect& clip_rect) const;
   void unloadTileToBil(void* dest,
                        const ossimIrect& dest_rect,
                        const ossimIrect& clip_rect) const;
   void unloadTileToBsq(void* dest,
                        const ossimIrect& dest_rect,
                        const ossimIrect& clip_rect) const;

   /**
    * Called from public unloadBand() routines that have an 
    * OverwriteBandRule interface.
    *
    * @param dest      The destination buffer.
    * @param src_band  The 0-based band of the source image data.
    * @param dest_band The 0-based band of the destination buffer.
    * @param dest_rect The rectangle of the destination buffer.
    * @param clip_rect Only data within will be copied.
    * @param ow_type   The rule for overwriting the destination buffer.
    */
   virtual void unloadBandToBsq( void* dest,
                                 ossim_uint32 src_band,
                                 ossim_uint32 dest_band,
                                 const ossimIrect& dest_rect,
                                 const ossimIrect& clip_rect,
                                 OverwriteBandRule ow_type=NULL_RULE ) const;

   /**
    * Copies entire tile to buf passed in.  Data put in buf is normalized.
    * The "buf" passed to method is assumed to be at least as big as:
    * "getSize() * sizeof(double)"
    */
   template <class T>
   void copyTileToNormalizedBuffer(T dummyTemplate,
                                   ossim_float64* buf) const;
   template <class T>
   void copyTileToNormalizedBuffer(T dummyTemplate,
                                   ossim_float32* buf)const;

   /**
    * Will copy this tiles specified band number to the normalized buffer.
    * if the band is out of range then nothing is done and returns.
    */
   template <class T>
   void copyTileToNormalizedBuffer(T dummyTemplate,
                                   ossim_uint32 band, ossim_float64* buf) const;
   template <class T>
   void copyTileToNormalizedBuffer(T dummyTemplate,
                                   ossim_uint32 band, ossim_float32* buf)const;

   /**
    * Copies buf passed in to tile.  Data is unnormalized to the tile's
    * scalar type.
    * The "buf" passed to method is assumed to be at least as big as the tiles:
    * "getSize() * sizeof(double)"
    */
   template <class T>
   void copyNormalizedBufferToTile(T dummyTemplate,
                                   ossim_float64* buf);
   template <class T>
   void copyNormalizedBufferToTile(T dummyTemplate,
                                   ossim_float32* buf);
   template <class T>
   void copyNormalizedBufferToTile(T dummyTemplate,
                                   ossim_uint32 band,
                                   ossim_float64* buf);
   template <class T>
   void copyNormalizedBufferToTile(T dummyTemplate,
                                   ossim_uint32 band,
                                   ossim_float32* buf);

   
   template <class T> void computeMinMaxPix(T dummyValue,
                                            std::vector<ossim_float64>& minBands,
                                            std::vector<ossim_float64>& maxBands);
   
   template <class T> void loadBandTemplate(T, // dummy template variable
                                            const void* src,
                                            const ossimIrect& src_rect,
                                            ossim_uint32 band);

   template <class T> void loadBandTemplate(T, // dummy template variable
                                            const void* src,
                                            const ossimIrect& src_rect,
                                            const ossimIrect& clip_rect,
                                            ossim_uint32 band);

   template <class T> void nullTileAlphaTemplate(T,
                                                 const ossim_uint8* src,
                                                 const ossimIrect& src_rect,
                                                 const ossimIrect& clip_rect,
                                                 bool multiplyAlphaFlag=false);
   
   template <class T> void loadTileFromBipTemplate(T, // dummy template variable
                                                   const void* src,
                                                   const ossimIrect& src_rect);

   template <class T> void loadTileFromBipTemplate(T, // dummy template variable
                                                   const void* src,
                                                   const ossimIrect& src_rect,
                                                   const ossimIrect& clip_rect);
   
   template <class T> void loadTileFromBilTemplate(T, // dummy template variable
                                                   const void* src,
                                                   const ossimIrect& src_rect);
   
   template <class T> void loadTileFromBilTemplate(T, // dummy template variable
                                                   const void* src,
                                                   const ossimIrect& src_rect,
                                                   const ossimIrect& clip_rect);
   
   template <class T> void loadTileFromBsqTemplate(T, // dummy template variable
                                                   const void* src,
                                                   const ossimIrect& src_rect);
   
   template <class T> void loadTileFromBsqTemplate(T, // dummy template variable
                                                   const void* src,
                                                   const ossimIrect& src_rect,
                                                   const ossimIrect& clip_rect);
   
   template <class T> void unloadTileToBipTemplate(T, // dummy template variable
                                                   void* dest,
                                                   const ossimIrect& dest_rect,
                                                   const ossimIrect& clip_rect) const;

   template <class T> void unloadTileToBilTemplate(T, // dummy template variable
                                                   void* dest,
                                                   const ossimIrect& dest_rect,
                                                   const ossimIrect& clip_rect) const;

   template <class T> void unloadTileToBsqTemplate(T, // dummy template variable
                                                   void* dest,
                                                   const ossimIrect& dest_rect,
                                                   const ossimIrect& clip_rect) const;

   template <class T> void unloadBandTemplate(T, // dummy template variable
                                              void* dest,
                                              const ossimIrect& dest_rect,
                                              const ossimIrect& clip_rect,
                                              ossim_uint32 band) const;

   template <class T> void unloadBandToBsqTemplate(T, // dummy template variable
                                                   void* dest,
                                                   ossim_uint32 src_band,
                                                   ossim_uint32 dest_band,
                                                   const ossimIrect& dest_rect,
                                                   const ossimIrect& clip_rect,
                                                   OverwriteBandRule ow_type=NULL_RULE) const;

   /**
    * @brief initializeDefaults() Resizes and sets min/max/null arrays to
    * number of bands and some default value for scalar type.
    */
   virtual void initializeDefaults();

   /**
    * @brief initializeMinDefault() Resizes theMinPixelValue array to number
    * of bands and initializes to the default min for scalar type.
    */
   virtual void initializeMinDefault();

   /**
    * @brief initializeMaxDefault() Resizes theMaxPixelValue array to number
    * of bands and initializes to the default max for scalar type.
    */
   virtual void initializeMaxDefault();

   /**
    * @brief initializeNullDefault() Resizes theNullPixelValue array to number
    * of bands and initializes to the default null for scalar type.
    */
   virtual void initializeNullDefault();

   virtual bool isEqualTo(const ossimDataObject& rhs,
                          bool deepTest=false)const;
   
   bool hasSameDimensionsAs(ossimImageData* data)const
   {
      if(!data) return false;
      return ((theNumberOfSpatialComponents ==
               data->theNumberOfSpatialComponents)&
              (theSpatialExtents[0] == data->theSpatialExtents[0])&&
              (theSpatialExtents[1] == data->theSpatialExtents[1])&&
              (theScalarType == data->theScalarType));
   }
   
   /**
    * Have a null pixel value per band.
    */
   std::vector<ossim_float64> theNullPixelValue;

   /**
    * Have a min pixel value per band.
    */
   std::vector<ossim_float64> theMinPixelValue;

   /**
    * Have a max pixel value per band.
    */
   std::vector<ossim_float64> theMaxPixelValue;
   
   ossimIpt       theOrigin;

private:
   /**
    * @note disallow 
    */
   const ossimImageData& operator=(const ossimImageData &rhs);
   
TYPE_DATA
};

inline void ossimImageData::getPixFromNorm(ossim_int32& pixel,
                                           ossim_float32 normPix,
                                           ossim_uint32 band) const
{
   // If norm pix is 0.0 or negative make if null.
   ossim_float32 p = theNullPixelValue[band]; 
   
   if (normPix > 0.0)
   {
      // un-normalize...
      p = normPix * (theMaxPixelValue[band]-theMinPixelValue[band]+1.0);
      
      // handle negative min values.
      p = p + theMinPixelValue[band] - 1.0;  
      
      // Clamp to  max.
      if (p > theMaxPixelValue[band]) p = theMaxPixelValue[band];
   
      //***
      // If p is less than min, make it min as it wasn't a null before.
      // Add or subtract 0.5 to p otherwise as it will be cast to an
      // int for proper rounding.
      //***
      p = p > theMinPixelValue[band] ?
          ( p<0.0 ? p-0.5 : p+0.5 ) :
          theMinPixelValue[band];
   }

   // Cast back to an int.
   pixel = static_cast<ossim_int32>(p);
}

inline void ossimImageData::getPixFromNorm(ossim_int32& pixel,
                                           ossim_float64 normPix,
                                           ossim_uint32 band) const
{
   // If norm pix is 0.0 or negative make if null.
   ossim_float64 p = theNullPixelValue[band]; 
   
   if (normPix > 0.0)
   {
      // un-normalize...
      p = normPix * (theMaxPixelValue[band]-theMinPixelValue[band]+1.0);
      
      // handle negative min values.
      p = p + theMinPixelValue[band] - 1.0;  
      
      // Clamp to  max.
      if (p > theMaxPixelValue[band]) p = theMaxPixelValue[band];
   
      //***
      // If p is less than min, make it min as it wasn't a null before.
      // Add or subtract 0.5 to p otherwise as it will be cast to an
      // int for proper rounding.
      //***
      p = p > theMinPixelValue[band] ?
          ( p<0.0 ? p-0.5 : p+0.5 ) :
          theMinPixelValue[band];
   }

   // Cast back to an int.
   pixel = static_cast<ossim_int32>(p);
}

inline void ossimImageData::getNormFromPix(ossim_int32 pixel,
                                           ossim_float32&  normPix,
                                           ossim_uint32 band) const
{
   if      (pixel == theNullPixelValue[band]) normPix = 0.0;
   else if (pixel >= theMaxPixelValue[band])  normPix = 1.0;

   //***
   // Normalize...
   // Note that this will shift any negatives to positive prior to dividing.
   //***
   else normPix = ( (pixel-theMinPixelValue[band]+1) /
                    (theMaxPixelValue[band] - theMinPixelValue[band] + 1.0) );
}

inline void ossimImageData::getNormFromPix(ossim_int32  pixel,
                                           ossim_float64&   normPix,
                                           ossim_uint32 band) const
{
   if      (pixel == theNullPixelValue[band]) normPix = 0.0;
   else if (pixel >= theMaxPixelValue[band])  normPix = 1.0;

   //***
   // Normalize...
   // Note that this will shift any negatives to positive prior to dividing.
   //***
   else normPix = ( (pixel-theMinPixelValue[band]+1) /
                    (theMaxPixelValue[band] - theMinPixelValue[band] + 1.0) );
}

inline ossimIrect ossimImageData::getImageRectangle() const
{
   ossimIpt lr(theOrigin.x + getWidth()  - 1,
               theOrigin.y + getHeight() - 1);
   
   return ossimIrect(theOrigin, lr);
}

inline const ossim_float64* ossimImageData::getNullPix()const
{
   return ( theNullPixelValue.size() > 0 ? &theNullPixelValue.front() : 0 );
}

inline const ossim_float64* ossimImageData::getMinPix()const
{
   return ( theMinPixelValue.size() > 0 ? &theMinPixelValue.front() : 0 );
}

inline const ossim_float64* ossimImageData::getMaxPix()const
{
   return ( theMaxPixelValue.size() > 0 ? &theMaxPixelValue.front() : 0 );
}

inline ossim_float64 ossimImageData::getNullPix(ossim_uint32 band) const
{
   return ( band < theNullPixelValue.size() ? theNullPixelValue[band] :
            ossim::defaultNull( getScalarType() ) );
}
      
inline ossim_float64 ossimImageData::getMinPix(ossim_uint32 band) const
{
   return ( band < theMinPixelValue.size() ? theMinPixelValue[band] :
            ossim::defaultMin( getScalarType() ) );
}

inline ossim_float64 ossimImageData::getMaxPix(ossim_uint32 band) const
{
   return ( band < theMaxPixelValue.size() ? theMaxPixelValue[band] :
            ossim::defaultMax( getScalarType() ) );
}

inline ossim_uint32 ossimImageData::getHashId()const
{
   const unsigned char *bufx = (unsigned char*)(&theOrigin.x);
   const unsigned char *bufy = (unsigned char*)(&theOrigin.y);
   return (ossim_uint32)(bufx[0]*101 + bufx[1]*103 +
                         bufx[2]*107 + bufx[3]*109 +
                         bufy[0]*139 + bufy[1]*149 +
                         bufy[2]*151 + bufy[3]*157);
}

#endif