00001 /* 00002 * The information in this file is 00003 * Copyright(c) 2007 Ball Aerospace & Technologies Corporation 00004 * and is subject to the terms and conditions of the 00005 * GNU Lesser General Public License Version 2.1 00006 * The license text is available from 00007 * http://www.gnu.org/licenses/lgpl.html 00008 */ 00009 00010 #ifndef STATISTICS_H 00011 #define STATISTICS_H 00012 00013 #include "Serializable.h" 00014 #include "ComplexData.h" 00015 00016 #include <vector> 00017 00018 /** 00019 * Statistics for raster elements. 00020 * 00021 * The Statistics class is used to maintain the information specific for a 00022 * spatial dimension of a data set. A separate Statistics object is available 00023 * for each band of a RasterElement object. 00024 * 00025 * The data used in the calculation of the statistics is set automatically by 00026 * the RasterElement. The values are not calculated until one of the get 00027 * methods are called. If the specific statistics values for the data are 00028 * known, the set methods can be called to avoid calculating the 00029 * values, which could take some time. All values in the object need to be 00030 * set to avoid calculations when calling one of the get methods. Typically 00031 * the values would only be directly set by an importer. 00032 * 00033 * @warning Be careful when dealing with RasterElements that have NaN(Not a number) 00034 * values. Before doing anything with the dataset, be sure to sanitize the data 00035 * first. Failure to do this may lead to Opticks crashing when you attempt to 00036 * calculate the statistics. 00037 * 00038 * @see RasterElement::getStatistics() 00039 */ 00040 class Statistics : public Serializable 00041 { 00042 public: 00043 /** 00044 * Sets the minimum value for the data. 00045 * 00046 * Calling this method and the set methods for the other statistics values, 00047 * calculations will not be performed when calling the get methods, which 00048 * could save some time. 00049 * 00050 * @param dMin 00051 * The minimum value for the data. 00052 */ 00053 virtual void setMin(double dMin) = 0; 00054 00055 /** 00056 * Sets the minimum value for the data. 00057 * 00058 * Calling this method and the set methods for the other statistics values, 00059 * calculations will not be performed when calling the get methods, which 00060 * could save some time. 00061 * 00062 * @param dMin 00063 * The minimum value for the data. 00064 * @param component 00065 * The complex data component represented by the given minimum. 00066 */ 00067 virtual void setMin(double dMin, ComplexComponent component) = 0; 00068 00069 /** 00070 * Returns the minimum value for the data. 00071 * 00072 * @return The minimum value detected in the data, or -99999.9 if the 00073 * statistics could not be calculated successfully. 00074 */ 00075 virtual double getMin() = 0; 00076 00077 /** 00078 * Returns the minimum value for the data. 00079 * 00080 * @param component 00081 * The complex data component for which to get its minimum value. 00082 * 00083 * @return The minimum value detected in the data, or -99999.9 if the 00084 * statistics could not be calculated successfully. 00085 */ 00086 virtual double getMin(ComplexComponent component) = 0; 00087 00088 /** 00089 * Sets the maximum value for the data. 00090 * 00091 * Calling this method and the set methods for the other statistics values, 00092 * calculations will not be performed when calling the get methods, which 00093 * could save some time. 00094 * 00095 * @param dMax 00096 * The maximum value for the data. 00097 */ 00098 virtual void setMax(double dMax) = 0; 00099 00100 /** 00101 * Sets the maximum value for the data. 00102 * 00103 * Calling this method and the set methods for the other statistics values, 00104 * calculations will not be performed when calling the get methods, which 00105 * could save some time. 00106 * 00107 * @param dMax 00108 * The maximum value for the data. 00109 * @param component 00110 * The complex data component represented by the given maximum. 00111 */ 00112 virtual void setMax(double dMax, ComplexComponent component) = 0; 00113 00114 /** 00115 * Returns the maximum value for the data. 00116 * 00117 * @return The maximum value detected in the data, or -99999.9 if the 00118 * statistics could not be calculated successfully. 00119 */ 00120 virtual double getMax() = 0; 00121 00122 /** 00123 * Returns the maximum value for the data. 00124 * 00125 * @param component 00126 * The complex data component for which to get its maximum value. 00127 * 00128 * @return The maximum value detected in the data, or -99999.9 if the 00129 * statistics could not be calculated successfully. 00130 */ 00131 virtual double getMax(ComplexComponent component) = 0; 00132 00133 /** 00134 * Sets the average value for the data. 00135 * 00136 * Calling this method and the set methods for the other statistics values, 00137 * calculations will not be performed when calling the get methods, which 00138 * could save some time. 00139 * 00140 * @param dAverage 00141 * The average value for the data. 00142 */ 00143 virtual void setAverage(double dAverage) = 0; 00144 00145 /** 00146 * Sets the average value for the data. 00147 * 00148 * Calling this method and the set methods for the other statistics values, 00149 * calculations will not be performed when calling the get methods, which 00150 * could save some time. 00151 * 00152 * @param dAverage 00153 * The average value for the data. 00154 * @param component 00155 * The complex data component represented by the given average. 00156 */ 00157 virtual void setAverage(double dAverage, ComplexComponent component) = 0; 00158 00159 /** 00160 * Returns the average value for the data. 00161 * 00162 * @return The average of all values in the data, or -99999.9 if the 00163 * statistics could not be calculated successfully. 00164 */ 00165 virtual double getAverage() = 0; 00166 00167 /** 00168 * Returns the average value for the data. 00169 * 00170 * @param component 00171 * The complex data component for which to get its average value. 00172 * 00173 * @return The average of all values in the data, or -99999.9 if the 00174 * statistics could not be calculated successfully. 00175 */ 00176 virtual double getAverage(ComplexComponent component) = 0; 00177 00178 /** 00179 * Sets the standard deviation value for the data. 00180 * 00181 * Calling this method and the set methods for the other statistics values, 00182 * calculations will not be performed when calling the get methods, which 00183 * could save some time. 00184 * 00185 * @param dStdDev 00186 * The standard deviation value for the data. 00187 */ 00188 virtual void setStandardDeviation(double dStdDev) = 0; 00189 00190 /** 00191 * Sets the standard deviation value for the data. 00192 * 00193 * Calling this method and the set methods for the other statistics values, 00194 * calculations will not be performed when calling the get methods, which 00195 * could save some time. 00196 * 00197 * @param dStdDev 00198 * The standard deviation value for the data. 00199 * @param component 00200 * The complex data component represented by the given standard 00201 * deviation. 00202 */ 00203 virtual void setStandardDeviation(double dStdDev, ComplexComponent component) = 0; 00204 00205 /** 00206 * Returns the standard deviation value for the data. 00207 * 00208 * @return The standard deviation of all values in the band, or -99999.9 00209 * if the statistics could not be calculated successfully. 00210 */ 00211 virtual double getStandardDeviation() = 0; 00212 00213 /** 00214 * Returns the standard deviation value for the data. 00215 * 00216 * @param component 00217 * The complex data component for which to get its standard 00218 * deviation value. 00219 * 00220 * @return The standard deviation of all values in the data, or -99999.9 00221 * if the statistics could not be calculated successfully. 00222 */ 00223 virtual double getStandardDeviation(ComplexComponent component) = 0; 00224 00225 /** 00226 * Sets the percentile values for the data. 00227 * 00228 * Calling this method and the set methods for the other statistics values, 00229 * calculations will not be performed when calling the get methods, which 00230 * could save some time. 00231 * 00232 * @param pPercentiles 00233 * The percentile values for the data. 00234 */ 00235 virtual void setPercentiles(const double* pPercentiles) = 0; 00236 00237 /** 00238 * Sets the percentile values for the data. 00239 * 00240 * Calling this method and the set methods for the other statistics values, 00241 * calculations will not be performed when calling the get methods, which 00242 * could save some time. 00243 * 00244 * @param pPercentiles 00245 * The percentile values for the data. 00246 * @param component 00247 * The complex data component represented by the given 00248 * percentiles. 00249 */ 00250 virtual void setPercentiles(const double* pPercentiles, ComplexComponent component) = 0; 00251 00252 /** 00253 * Returns the percentile boundaries for the data. 00254 * 00255 * @return An array of 1001 values that contain the percentile boundaries 00256 * for this band, or \b NULL if the statistics could not be 00257 * calculated successfully. 00258 */ 00259 virtual const double* getPercentiles() = 0; 00260 00261 /** 00262 * Returns the percentile boundaries for the data. 00263 * 00264 * @param component 00265 * The complex data component for which to get its percentile 00266 * values. 00267 * 00268 * @return An array of 1001 values that contain the percentile boundaries 00269 * for the data, or \b NULL if the statistics could not be 00270 * calculated successfully. 00271 */ 00272 virtual const double* getPercentiles(ComplexComponent component) = 0; 00273 00274 /** 00275 * Sets the histogram values for the data. 00276 * 00277 * Calling this method and the set methods for the other statistics values, 00278 * calculations will not be performed when calling the get methods, which 00279 * could save some time. 00280 * 00281 * @param pBinCenters 00282 * The bin center values for the histogram. 00283 * @param pHistogramCounts 00284 * The histogram values for the data. 00285 */ 00286 virtual void setHistogram(const double* pBinCenters, const unsigned int* pHistogramCounts) = 0; 00287 00288 /** 00289 * Sets the histogram values for the data. 00290 * 00291 * Calling this method and the set methods for the other statistics values, 00292 * calculations will not be performed when calling the get methods, which 00293 * could save some time. 00294 * 00295 * @param pBinCenters 00296 * The bin center values for the histogram. 00297 * @param pHistogramCounts 00298 * The histogram values for the data. 00299 * @param component 00300 * The complex data component represented by the given histogram. 00301 */ 00302 virtual void setHistogram(const double* pBinCenters, const unsigned int* pHistogramCounts, 00303 ComplexComponent component) = 0; 00304 00305 /** 00306 * Returns the histogram values for the data. 00307 * 00308 * @param pBinCenters 00309 * Populated with an array of 256 values that specify the center 00310 * location of the histogram bins. This value is set to \b NULL 00311 * if the histogram cannot be computed successfully. 00312 * @param pHistogramCounts 00313 * Populated with an array of 256 values that specify the number 00314 * of values contained in each histogram bin. This value is set 00315 * to \b NULL if the histogram cannot be computed successfully. 00316 */ 00317 virtual void getHistogram(const double*& pBinCenters, const unsigned int*& pHistogramCounts) = 0; 00318 00319 /** 00320 * Returns the histogram values for the data. 00321 * 00322 * @param pBinCenters 00323 * Populated with an array of 256 values that specify the center 00324 * location of the histogram bins. This value is set to \b NULL 00325 * if the histogram cannot be computed successfully. 00326 * @param pHistogramCounts 00327 * Populated with an array of 256 values that specify the number 00328 * of values contained in each histogram bin. This value is set 00329 * to \b NULL if the histogram cannot be computed successfully. 00330 * @param component 00331 * The complex data component for which to get its histogram 00332 * values. 00333 */ 00334 virtual void getHistogram(const double*& pBinCenters, const unsigned int*& pHistogramCounts, 00335 ComplexComponent component) = 0; 00336 00337 /** 00338 * Sets the step size used when computing the statistics for the data. 00339 * 00340 * This method sets the number of rows and columns that will be stepped 00341 * over while looping through the data to compute the statistics. 00342 * 00343 * @param resolution 00344 * The step size for the data. Must be at least 1. 00345 */ 00346 virtual void setStatisticsResolution(int resolution) = 0; 00347 00348 /** 00349 * Gets the step size used when computing the statistics for the data. 00350 * 00351 * This method gets the number of rows and columns that will be stepped 00352 * over while looping through the data to compute the statistics. 00353 * 00354 * @return The step size for the data. Will be at least 1. 00355 */ 00356 virtual int getStatisticsResolution() const = 0; 00357 00358 /** 00359 * Sets values that will be excluded from statistics computation. 00360 * 00361 * Certain layers (e.g. ThresholdLayer) also take these values into 00362 * account. 00363 * 00364 * This method is intended to be used to change the bad values in an 00365 * existing RasterElement. To set the initial bad values that should be 00366 * used to populate a RasterElement when it is created, use the 00367 * RasterDataDescriptor::setBadValues() method instead. 00368 * 00369 * @param badValues 00370 * The values that should be ignored when computing statistics. 00371 */ 00372 virtual void setBadValues(const std::vector<int>& badValues) = 0; 00373 00374 /** 00375 * Gets the values that will be excluded from statistics computation. 00376 * These values will always be sorted. 00377 * 00378 * @return The values that should be ignored when computing statistics. 00379 */ 00380 virtual const std::vector<int>& getBadValues() const = 0; 00381 00382 /** 00383 * Queries whether the statistics have been calculated for the data. 00384 * 00385 * @return Returns \b true if the statistics have been calculated; 00386 * otherwise returns \b false. 00387 */ 00388 virtual bool areStatisticsCalculated() const = 0; 00389 00390 /** 00391 * Queries whether the complex data statistics have been calculated for the 00392 * data. 00393 * 00394 * @param component 00395 * The complex data component for which to query its statistics. 00396 * 00397 * @return Returns \b true if the statistics have been calculated; 00398 * otherwise returns \b false. 00399 */ 00400 virtual bool areStatisticsCalculated(ComplexComponent component) const = 0; 00401 00402 protected: 00403 /** 00404 * A plug-in cannot create this object, it can only retrieve an already existing 00405 * object from RasterElement::getStatistics and the RasterElement will manage 00406 * any instances of this object. 00407 */ 00408 virtual ~Statistics() {} 00409 }; 00410 00411 #endif