/usr/include/ossim/imaging/ossimImageData.h is in libossim-dev 2.2.2-1.
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 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 | //*******************************************************************
//
// License: MIT
//
// 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 23371 2015-06-12 13:08:34Z gpotts $
#ifndef ossimImageData_HEADER
#define ossimImageData_HEADER 1
#include <vector>
#include <iosfwd> /* for ostream */
#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>
#include <ossim/base/ossimMultiResLevelHistogram.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 destination pixel have color values that
* deviate from its color.
* Deprecated in favor of COLOR_DISCREPANCY_OF_ANY_FROM_DEST.
*/
COLOR_DISCREPANCY = 0,
/*
* The COLOR_DISCREPANCY_OF_ANY_FROM_DEST 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 destination pixel have color
* values that deviate from its color.
* Same as the deprecated COLOR_DISCREPANCY.
*/
COLOR_DISCREPANCY_OF_ANY_FROM_DEST = 1,
/*
* The COLOR_DISCREPANCY_OF_ALL_FROM_DEST rule directs that the selected
* band of a pixel of the destination buffer is to be overwritten only if
* *all* of the other bands of the same destination pixel have color
* values that deviate from its color.
*/
COLOR_DISCREPANCY_OF_ALL_FROM_DEST = 2,
/*
* The COLOR_EQUALITY_OF_ANY_TO_SRC 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 destination pixel have color
* values that are equal to the color of the selected band of the source
* pixel.
*/
COLOR_EQUALITY_OF_ANY_TO_SRC = 3,
/*
* The COLOR_EQUALITY_OF_ALL_TO_SRC rule directs that the selected
* band of a pixel of the destination buffer is to be overwritten only if
* *all* of the other bands of the same destination pixel have color
* values that are equal to the color of the selected band of the source
* pixel.
*/
COLOR_EQUALITY_OF_ALL_TO_SRC = 4,
/*
* 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 = 5
};
/** @brief copy constructor */
ossimImageData(const ossimImageData &rhs);
ossimImageData();
/**
* @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();
/**
* @brief assignment operator=
* @param rhs The data to assign from.
* @param A reference to this object.
*/
virtual const ossimImageData& operator=(const ossimImageData &rhs);
/**
* @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 m_origin;}
/**
* 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) const;
/**
* @brief Scans tile for min, max, nulls.
*
* If the nullBands, 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 no
* action is performed.
*/
virtual void computeMinMaxNulPix(
std::vector<ossim_float64>& minBands,
std::vector<ossim_float64>& maxBands,
std::vector<ossim_float64>& nulBands) const;
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);
/**
* @brief Creates a step wedge for testing only.
*
* Writes line at a time of a single value, starting at scalar null,
* and going to scalar max in increments of scalar range/tile_lines.
*/
void createTestTile();
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;
template <class T> void copyTileToFloatBuffer(
T /* dummyTemplate*/, ossim_float32* buf)const
{
const ossim_uint32 SIZE = getSizePerBand();
const ossim_uint32 BANDS = getNumberOfBands();
for(ossim_uint32 band = 0; band < BANDS; ++band)
{
const T* s = (T*)getBuf(band); // source
ossim_float32* d = (ossim_float32*)(buf + (band*SIZE)); // destination
for(ossim_uint32 offset = 0; offset < SIZE; ++offset)
{
ossim_float32 p = s[offset];
d[offset] = p;
}
}
}
/**
* 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);
virtual void setHistogram(ossimRefPtr<ossimMultiResLevelHistogram> histo);
ossimRefPtr<ossimMultiResLevelHistogram> getHistogram();
/**
* @return true if alpha channel is initialized, false if not.
*/
virtual bool hasAlpha() const;
/**
* @return const ossim_uint8* to the alpha channel or null if the alpha
* channel was not computed.
*/
virtual const ossim_uint8* getAlphaBuf() const;
/**
* @return ossim_uint8* to the alpha channel or null if the alpha channel
* was not computed.
*/
virtual ossim_uint8* getAlphaBuf();
/**
* @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();
/**
* @brief Writes tile to stream.
*
* This will write the buffer to file with an associated header file.
* Assuming a contiguous buffer in BSQ format. Currently does not
* support converting to BIP or BIL or byte swapping but probably
* should add at some point.
*
* @param f File to write.
*
* @return true on success, false on error.
*/
virtual bool write(const ossimFilename& f) 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)"
*/
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 loadTileWithAlpha(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_OF_ANY_FROM_DEST 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 destination pixel have color values
* that deviate from its color. Same as the deprecated COLOR_DISCREPANCY.
*
* The COLOR_DISCREPANCY_OF_ALL_FROM_DEST rule directs that the selected
* band of a pixel of the destination buffer is to be overwritten only if
* *all* of the other bands of the same destination pixel have color values
* that deviate from its color.
*
* The COLOR_EQUALITY_OF_ANY_TO_SRC 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 destination pixel have color
* values that are equal to the color of the selected band of the source
* pixel.
*
* The COLOR_EQUALITY_OF_ALL_TO_SRC rule directs that the selected
* band of a pixel of the destination buffer is to be overwritten only if
* *all* of the other bands of the same destination pixel have color
* values that are equal to the color of the selected band of the source
* pixel.
*
* 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 'dest' buffer should have at least the same number of bands
* as the 'src' object.
*
* Currently this routine is only implemented for il_type set to OSSIM_BSQ.
*
* @param dest The destination buffer, which should have at least the
* same number of bands as the 'src' 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_OF_ANY_FROM_DEST 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 destination pixel have color values
* that deviate from its color. Same as the deprecated COLOR_DISCREPANCY.
*
* The COLOR_DISCREPANCY_OF_ALL_FROM_DEST rule directs that the selected
* band of a pixel of the destination buffer is to be overwritten only if
* *all* of the other bands of the same destination pixel have color values
* that deviate from its color.
*
* The COLOR_EQUALITY_OF_ANY_TO_SRC 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 destination pixel have color
* values that are equal to the color of the selected band of the source
* pixel.
*
* The COLOR_EQUALITY_OF_ALL_TO_SRC rule directs that the selected
* band of a pixel of the destination buffer is to be overwritten only if
* *all* of the other bands of the same destination pixel have color
* values that are equal to the color of the selected band of the source
* pixel.
*
* 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 'dest' buffer should have at least the same number of bands
* as the 'src' object.
*
* Currently this routine is only implemented for il_type set to OSSIM_BSQ.
*
* @param dest The destination buffer, which should have at least the
* same number of bands as the 'src' 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;
/**
* @param dest The destination buffer.
* @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 unloadTileToBipAlpha(void* dest,
const ossimIrect& dest_rect,
const ossimIrect& clip_rect) 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;
/**
* @brief Performs linear stretch on tile data from min/max to limits of
* scalar type.
*/
virtual void stretchMinMax();
/**
* @brief Computes the alpha channel.
*
* For each pixel if any band value is not null then alpha will be 255;
* else, 0.
*/
virtual void computeAlphaChannel();
/**
* @brief Method to copy a single line to the tile.
*
* This will copy a line to the tile. It is assumed that all bands are in
* the buffer "src". Only pixels within the tile rect will be copied.
* Note that all coordinates are relative to the tile coordinates.
* Clipping will be performed on pixels outside of the tile rectangle.
* No fill is added if a partial tile line is copied so callers
* should do a ossimImageData::makeBlank if the whole tile is not to be
* stuffed. ossimImageData::validate should be called after all lines
* are copied if in doubt of a full tile.
*
* @param src The source buffer or line to copy containing all bands.
*
* @param lineNumber Line number to copy.
*
* @param lineStartSample The start sample of the source buffer relative
* to tile coordinates.
*
* @param lineStopSample The stop sample of the source buffer relative
* to tile coordinates.
*
* @param lineInterleave Interleave of src buffer. If OSSIM_BIP assumed
* rgbrgbrgb; else, red row, green row, blue row.
*
* Usage example in method: ossimTiffTileSource::loadFromScanLine
*/
virtual void copyLine(const void* src,
ossim_int32 lineNumber,
ossim_int32 lineStartSample,
ossim_int32 lineStopSample,
ossimInterleaveType lineInterleave);
/**
* @brief Sets the indexed flag.
*
* This indicates the data contains palette indexes. Default is false.
*
* @param flag If true data is indexed.
*/
void setIndexedFlag(bool flag);
/** @return The indexed flag. */
bool getIndexedFlag() const;
/**
* Returns the percentage (0-100) of data buffer containing non-null (valid) entries.
* Undefined until validate() is called.
*/
ossim_float64 percentFull() const { return m_percentFull; }
virtual bool isEqualTo(const ossimDataObject& rhs,
bool deepTest=false)const;
virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=0)const;
virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
protected:
/** @brief Templated copy line method. */
template <class T> void copyLineTemplate(T dummyTemplate,
const void* src,
ossim_int32 lineNumber,
ossim_int32 lineStartSample,
ossim_int32 lineStopSample,
ossimInterleaveType lineInterleave);
/**
* @brief Templated stretch method.
*
* Performs linear stretches on tile data from min/max to limits of
* scalar type.
*/
template <class T> void stretchMinMax(T dummyTemplate);
/**
* @brief Templated compute alpha channel.
*
* For each pixel if any band value is not null then alpha will be 255;
* else, 0.
*/
template <class T> void computeAlphaChannel(T dummyTemplate);
/**
* 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;
void loadTileFromBip(const void* src, const ossimIrect& src_rect);
void loadTileFromBipAlpha(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) const;
template <class T>
void computeMinMaxNulPix(T dummyValue,
std::vector<ossim_float64>& minBands,
std::vector<ossim_float64>& maxBands,
std::vector<ossim_float64>& nulBands) const;
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 loadTileFromBipAlphaTemplate(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 loadTileFromBipAlphaTemplate(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 unloadTileToBipAlphaTemplate(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 Creates a test tile for scalar type for testing only.
*
* Protected template implementation of matching public createTestTile.
*/
template <class T> void createTestTile(T);
/**
* @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();
bool hasSameDimensionsAs(ossimImageData* data)const
{
bool result = false;
if(data)
{
result = ((m_spatialExtents.size() ==
data->m_spatialExtents.size())&&
(m_spatialExtents[0] == data->m_spatialExtents[0])&&
(m_spatialExtents[1] == data->m_spatialExtents[1])&&
(m_scalarType == data->m_scalarType));
}
return result;
}
/** Null pixel value for each band. */
std::vector<ossim_float64> m_nullPixelValue;
/** Min pixel value for each band. */
std::vector<ossim_float64> m_minPixelValue;
/** Max pixel value for each band. */
std::vector<ossim_float64> m_maxPixelValue;
/** Alpha channel */
std::vector<ossim_uint8> m_alpha;
ossimIpt m_origin;
/** Indicates data contains palette indexes. */
bool m_indexedFlag;
ossimRefPtr<ossimMultiResLevelHistogram> m_histogram;
/** percentage (0-100) of image tile that has valid (non-null) pixel values. This is computed
* in validate() method.
*/
mutable ossim_float64 m_percentFull;
private:
TYPE_DATA
};
inline bool ossimImageData::hasAlpha() const
{
return (m_alpha.size()?true:false);
}
inline ossimIrect ossimImageData::getImageRectangle() const
{
ossimIpt lr(m_origin.x + getWidth() - 1,
m_origin.y + getHeight() - 1);
return ossimIrect(m_origin, lr);
}
inline const ossim_float64* ossimImageData::getNullPix()const
{
return ( m_nullPixelValue.size() > 0 ? &m_nullPixelValue.front() : 0 );
}
inline const ossim_float64* ossimImageData::getMinPix()const
{
return ( m_minPixelValue.size() > 0 ? &m_minPixelValue.front() : 0 );
}
inline const ossim_float64* ossimImageData::getMaxPix()const
{
return ( m_maxPixelValue.size() > 0 ? &m_maxPixelValue.front() : 0 );
}
inline ossim_float64 ossimImageData::getNullPix(ossim_uint32 band) const
{
return ( band < m_nullPixelValue.size() ? m_nullPixelValue[band] :
ossim::defaultNull( getScalarType() ) );
}
inline ossim_float64 ossimImageData::getMinPix(ossim_uint32 band) const
{
return ( band < m_minPixelValue.size() ? m_minPixelValue[band] :
ossim::defaultMin( getScalarType() ) );
}
inline ossim_float64 ossimImageData::getMaxPix(ossim_uint32 band) const
{
return ( band < m_maxPixelValue.size() ? m_maxPixelValue[band] :
ossim::defaultMax( getScalarType() ) );
}
inline ossim_uint32 ossimImageData::getHashId()const
{
const unsigned char *bufx = (unsigned char*)(&m_origin.x);
const unsigned char *bufy = (unsigned char*)(&m_origin.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
|