Changeset 11760
- Timestamp:
- Feb 12, 2007, 5:08:17 PM (19 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 2 edited
-
imageops/psImageStats.c (modified) (2 diffs)
-
math/psStats.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageStats.c
r11759 r11760 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.10 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2007-02-13 03:0 1:23$11 * @version $Revision: 1.105 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2007-02-13 03:08:17 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 183 183 } 184 184 185 out = psVectorHistogram(out, junkData, NULL, junkMask, maskVal); 185 if (!psVectorHistogram(out, junkData, NULL, junkMask, maskVal)) { 186 psError(PS_ERR_UNKNOWN, false, "Unable to generate image histogram.\n"); 187 psFree(junkMask); 188 psFree(junkData); 189 return false; 190 } 186 191 187 192 psFree(junkMask); -
trunk/psLib/src/math/psStats.c
r11686 r11760 13 13 * use ->min and ->max (PS_STAT_USE_RANGE) 14 14 * 15 * @version $Revision: 1.20 0$ $Name: not supported by cvs2svn $16 * @date $Date: 2007-02- 07 23:52:54$15 * @version $Revision: 1.201 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2007-02-13 03:08:17 $ 17 17 * 18 18 * Copyright 2006 IfA, University of Hawaii … … 87 87 /****************************************************************************** 88 88 MISC PRIVATE STATISTICAL FUNCTIONS 89 89 90 90 NOTE: it is assumed that any call to these statistical functions will have 91 91 been preceded by a call to the psVectorStats() function. Various sanity tests 92 92 will only be performed in psVectorStats(). 93 93 94 94 For many of these private stats routines, it is possible that there are no acceptable elements 95 95 in the input vector (if no elements lie within range, or there are no unmasked elements, or the … … 106 106 mean of the input vector. If there was a problem with the mean calculation, 107 107 this routine sets stats->sampleMean to NAN. 108 108 109 109 using the method below, with a single loop for various options costs only a small amount and is 110 110 much easier to debug. running 10000 tests of 1000 point vectors for the two methods gives: 111 111 112 112 separate single w/errors 113 113 (mask: 0, range: 0): 0.067 sec 0.073 sec (10%) 0.072 sec … … 115 115 (mask: 0, range: 0): 0.136 sec 0.162 sec (20%) 0.170 sec 116 116 (mask: 1, range: 0): 0.177 sec 0.181 sec ( 2%) 0.198 sec 117 117 118 118 (effect of errors not tested) 119 119 120 120 To optmize this, use a macro and ifdef in or out the three states (errors, mask, range) 121 121 *****************************************************************************/ … … 320 320 Returns 321 321 NULL 322 322 323 323 using the method below, with a single loop for various options costs only a small amount and is 324 324 much easier to debug. running 10000 tests of 1000 point vectors for the two methods gives: 325 325 326 326 single 327 327 (mask: 0, range: 0): 0.193 sec … … 329 329 (mask: 0, range: 0): 0.349 sec 330 330 (mask: 1, range: 0): 0.401 sec 331 331 332 332 *****************************************************************************/ 333 333 static bool vectorSampleStdev(const psVector* myVector, … … 408 408 vectorClippedStats(myVector, errors, maskInput, maskValInput, stats): calculates the 409 409 clipped stats (mean or stdev) of the input vector. 410 410 411 411 Inputs 412 412 myVector … … 557 557 vectorRobustStats(myVector, maskInput, maskValInput, stats): This is the new 558 558 version of the robust stats routine. 559 559 560 560 XXX: MUST DO: If the errors in the input values are known, then the same 561 561 approach is used, except that the histograms become probability density … … 567 567 each input value contributes constant area. Then the robust median and 568 568 standard deviation are estimated in the same manner as above. 569 569 570 570 XXX: Check for errors in psLib routines that we call. 571 571 572 572 XXX: Review and ensure that all memory is free'ed at premature exits. 573 573 *****************************************************************************/ … … 666 666 histogram = psHistogramAlloc(min, max, numBins); 667 667 // XXXXX we need to consider this step if errors -> variance 668 histogram = psVectorHistogram(histogram, myVector, errors, mask, maskVal); 668 if (!psVectorHistogram(histogram, myVector, errors, mask, maskVal)) { 669 psError(PS_ERR_UNKNOWN, false, "Unable to generate histogram for robust statistics.\n"); 670 psFree(histogram); 671 psFree(statsMinMax); 672 return false; 673 } 669 674 if (psTraceGetLevel("psLib.math") >= 8) { 670 675 PS_VECTOR_PRINT_F32(histogram->bounds); … … 980 985 981 986 psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers) 982 histogram = psVectorHistogram(histogram, myVector, errors, mask, maskVal); 987 if (!psVectorHistogram(histogram, myVector, errors, mask, maskVal)) { 988 psError(PS_ERR_UNKNOWN, false, "Unable to generate histogram for fitted statistics.\n"); 989 psFree(histogram); 990 psFree(statsMinMax); 991 return false; 992 } 983 993 if (psTraceGetLevel("psLib.math") >= 8) { 984 994 PS_VECTOR_PRINT_F32(histogram->nums); … … 1174 1184 1175 1185 psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers) 1176 histogram = psVectorHistogram(histogram, myVector, errors, mask, maskVal); 1186 if (!psVectorHistogram(histogram, myVector, errors, mask, maskVal)) { 1187 psError(PS_ERR_UNKNOWN, false, "Unable to generate histogram for fitted statistcs v2.\n"); 1188 psFree(histogram); 1189 psFree(statsMinMax); 1190 return false; 1191 } 1177 1192 if (psTraceGetLevel("psLib.math") >= 8) { 1178 1193 PS_VECTOR_PRINT_F32(histogram->nums); … … 1382 1397 1383 1398 psHistogram *histogram = psHistogramAlloc(min, max, numBins); // A new histogram (without outliers) 1384 histogram = psVectorHistogram(histogram, myVector, errors, mask, maskVal); 1399 if (!psVectorHistogram(histogram, myVector, errors, mask, maskVal)) { 1400 psError(PS_ERR_UNKNOWN, false, "Unable to generate histogram for fitted statistics v3.\n"); 1401 psFree(histogram); 1402 psFree(statsMinMax); 1403 return false; 1404 } 1385 1405 if (psTraceGetLevel("psLib.math") >= 8) { 1386 1406 PS_VECTOR_PRINT_F32(histogram->nums); … … 1594 1614 robustHistogram with a Gaussian of width sigma. It returns a psVector of the 1595 1615 smoothed data. 1596 1616 1597 1617 XXX this function is unused 1598 1618 *****************************************************************************/ … … 1753 1773 function which calls the above private stats functions based on what bits 1754 1774 were set in stats->options. 1755 1775 1756 1776 Inputs 1757 1777 in … … 1761 1781 Returns 1762 1782 The stats structure. 1763 1783 1764 1784 XXX: Should we free stats if the asserts fail? NO; we don't own it (RHL). 1765 1785 *****************************************************************************/ … … 2107 2127 then determines for what value x does that quadratic f(x) = yVal (the input 2108 2128 parameter). 2109 2129 2110 2130 *****************************************************************************/ 2111 2131 static psF32 fitQuadraticSearchForYThenReturnX(const psVector *xVec,
Note:
See TracChangeset
for help on using the changeset viewer.
