Changeset 2856 for trunk/psModules/src/pmSubtractBias.c
- Timestamp:
- Dec 30, 2004, 11:35:04 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmSubtractBias.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmSubtractBias.c
r2850 r2856 6 6 * @author George Gusciora, MHPCC 7 7 * 8 * @version $Revision: 1.2 6$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-12-30 01:41:51$8 * @version $Revision: 1.27 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-12-30 21:35:03 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 29 29 const psReadout *bias) 30 30 { 31 inti;32 intj;31 psS32 i; 32 psS32 j; 33 33 34 34 if (bias == NULL) { … … 38 38 } 39 39 40 // XXX: What should be returned here?41 40 if (((in->image)->numRows + in->row0 - bias->row0) > (bias->image)->numRows) { 42 41 psError(PS_ERR_UNKNOWN,true, "bias image does not have enough rows\n"); … … 48 47 } 49 48 50 // XXX: Verify that this is the correct way to use offsets.51 49 for (i=0;i<(in->image)->numRows;i++) { 52 50 for (j=0;j<(in->image)->numCols;j++) { … … 65 63 /****************************************************************************** 66 64 p_psImageSubtractScalar(): subtract a scalar from the input image. 67 68 // XXX: Is there already a function which does this?69 65 *****************************************************************************/ 70 66 psImage *p_psImageSubtractScalar(psImage *image, 71 floatscalar)67 psF32 scalar) 72 68 { 73 int i; 74 int j; 75 76 for (i=0;i<image->numRows;i++) { 77 for (j=0;j<image->numCols;j++) { 69 for (psS32 i=0;i<image->numRows;i++) { 70 for (psS32 j=0;j<image->numCols;j++) { 78 71 (image->data.F32[i][j])-= scalar; 79 72 } … … 83 76 84 77 /****************************************************************************** 85 GenNewStatOptions(): this routine will take as input the options member of 86 the stat data structure, determine if multiple options have been specified, 87 issue a warning message if so, and return the highest priority option 88 (according to the order of the if-statements in this code). 78 GenNewStatOptions(): this routine will take as input the options member of the 79 stat data structure, determine if multiple options have been specified, issue 80 a warning message if so, and return the highest priority option (according to 81 the order of the if-statements in this code). The higher priority options are 82 listed lower in the code. 89 83 *****************************************************************************/ 90 84 psStatsOptions GenNewStatOptions(const psStats *stat) 91 85 { 92 intnumOptions = 0;86 psS32 numOptions = 0; 93 87 psStatsOptions opt = 0; 88 89 if (stat->options & PS_STAT_ROBUST_MODE) { 90 if (numOptions == 0) { 91 opt = PS_STAT_ROBUST_MODE; 92 } 93 numOptions++; 94 } 95 96 if (stat->options & PS_STAT_ROBUST_MEDIAN) { 97 if (numOptions == 0) { 98 opt = PS_STAT_ROBUST_MEDIAN; 99 } 100 numOptions++; 101 } 102 103 if (stat->options & PS_STAT_ROBUST_MEAN) { 104 if (numOptions == 0) { 105 opt = PS_STAT_ROBUST_MEAN; 106 } 107 numOptions++; 108 } 109 110 if (stat->options & PS_STAT_CLIPPED_MEAN) { 111 if (numOptions == 0) { 112 opt = PS_STAT_CLIPPED_MEAN; 113 } 114 numOptions++; 115 } 116 117 if (stat->options & PS_STAT_SAMPLE_MEDIAN) { 118 if (numOptions == 0) { 119 opt = PS_STAT_SAMPLE_MEDIAN; 120 } 121 numOptions++; 122 } 94 123 95 124 if (stat->options & PS_STAT_SAMPLE_MEAN) { … … 98 127 } 99 128 100 if (stat->options & PS_STAT_SAMPLE_MEDIAN) {101 if (numOptions == 0) {102 opt = PS_STAT_SAMPLE_MEDIAN;103 }104 numOptions++;105 }106 107 if (stat->options & PS_STAT_CLIPPED_MEAN) {108 if (numOptions == 0) {109 opt = PS_STAT_CLIPPED_MEAN;110 }111 numOptions++;112 }113 114 if (stat->options & PS_STAT_ROBUST_MEAN) {115 if (numOptions == 0) {116 opt = PS_STAT_ROBUST_MEAN;117 }118 numOptions++;119 }120 121 if (stat->options & PS_STAT_ROBUST_MEDIAN) {122 if (numOptions == 0) {123 opt = PS_STAT_ROBUST_MEDIAN;124 }125 numOptions++;126 }127 128 if (stat->options & PS_STAT_ROBUST_MODE) {129 if (numOptions == 0) {130 opt = PS_STAT_ROBUST_MODE;131 }132 numOptions++;133 }134 129 135 130 if (numOptions == 0) { … … 154 149 *****************************************************************************/ 155 150 psVector *ScaleOverscanVector(psVector *overscanVector, 156 intn,151 psS32 n, 157 152 void *fitSpec, 158 153 pmFit fit) … … 178 173 psPolynomial1D *myPoly; 179 174 psSpline1D *mySpline; 180 floatx;181 inti;175 psF32 x; 176 psS32 i; 182 177 183 178 if (fit == PM_FIT_POLYNOMIAL) { 184 179 // Fit a polynomial to the old overscan vector. 185 180 myPoly = (psPolynomial1D *) fitSpec; 181 PS_POLY_CHECK_NULL(myPoly, NULL); 186 182 myPoly = psVectorFitPolynomial1D(myPoly, NULL, overscanVector, NULL); 183 if (myPoly == NULL) { 184 psError(PS_ERR_UNKNOWN, false, "ScaleOverscanVector(): Could not fit a polynomial to the psVector.\n"); 185 return(NULL); 186 } 187 187 188 188 // For each element of the new vector, convert the x-ordinate to that … … 190 190 // interpolated value at that point, and set the new vector. 191 191 for (i=0;i<n;i++) { 192 x = (( float) i) * ((float) overscanVector->n) / ((float) n);192 x = ((psF32) i) * ((psF32) overscanVector->n) / ((psF32) n); 193 193 newVec->data.F32[i] = psPolynomial1DEval(myPoly, x); 194 194 } … … 200 200 mustFreeSpline = 1; 201 201 } 202 202 203 // 203 204 // NOTE: Since the X arg in the psVectorFitSpline1D() function is NULL, … … 206 207 // 207 208 mySpline = psVectorFitSpline1D(mySpline, NULL, overscanVector, NULL); 209 if (mySpline == NULL) { 210 psError(PS_ERR_UNKNOWN, false, "ScaleOverscanVector(): Could not fit a spline to the psVector.\n"); 211 return(NULL); 212 } 208 213 209 214 // For each element of the new vector, convert the x-ordinate to that … … 212 217 for (i=0;i<n;i++) { 213 218 // Scale to [0 : overscanVector->n - 1] 214 x = (( float) i) * ((float) (overscanVector->n-1)) / ((float) n);219 x = ((psF32) i) * ((psF32) (overscanVector->n-1)) / ((psF32) n); 215 220 newVec->data.F32[i] = psSpline1DEval(mySpline, x); 216 221 } … … 228 233 } 229 234 235 /****************************************************************************** 236 XXX: The SDRS does not specify type support. F32 is implemented here. 237 *****************************************************************************/ 230 238 psReadout *pmSubtractBias(psReadout *in, 231 239 void *fitSpec, … … 233 241 pmOverscanAxis overScanAxis, 234 242 psStats *stat, 235 intnBinOrig,243 psS32 nBinOrig, 236 244 pmFit fit, 237 245 const psReadout *bias) … … 263 271 return(in); 264 272 } 265 inti;266 intj;267 intnumBins = 0;273 psS32 i; 274 psS32 j; 275 psS32 numBins = 0; 268 276 static psVector *overscanVector = NULL; 269 277 psVector *tmpRow = NULL; … … 276 284 psPolynomial1D *myPoly = NULL; 277 285 psSpline1D *mySpline = NULL; 278 int nBin; 279 // XXX: This comment isn't right? 280 // Determine if multiple options are specified in stat. 286 psS32 nBin; 287 281 288 // 289 // Create a static stats data structure and determine the highest 290 // priority stats option. 291 // 292 static psStats *myStats = NULL; 293 if (myStats == NULL) { 294 myStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 295 p_psMemSetPersistent(myStats, true); 296 } 282 297 if (stat != NULL) { 283 stat->options = GenNewStatOptions(stat);298 myStats->options = GenNewStatOptions(stat); 284 299 } 285 300 … … 314 329 while (NULL != tmpOverscan) { 315 330 myOverscanImage = (psImage *) tmpOverscan->data; 316 psImageStats( stat, myOverscanImage, NULL, 0xffffffff);317 p_psGetStatValue( stat, &statValue);331 psImageStats(myStats, myOverscanImage, NULL, 0xffffffff); 332 p_psGetStatValue(myStats, &statValue); 318 333 p_psImageSubtractScalar(in->image, statValue); 319 334 … … 356 371 tmpRow->data.F32[j] = myOverscanImage->data.F32[j][i]; 357 372 } 358 stat = psVectorStats(stat, tmpRow, NULL, NULL, 0);359 p_psGetStatValue( stat, &statValue);373 myStats = psVectorStats(myStats, tmpRow, NULL, NULL, 0); 374 p_psGetStatValue(myStats, &statValue); 360 375 overscanVector->data.F32[i] = statValue; 361 376 } … … 399 414 tmpCol->data.F32[j] = myOverscanImage->data.F32[i][j]; 400 415 } 401 stat = psVectorStats(stat, tmpCol, NULL, NULL, 0);402 p_psGetStatValue( stat, &statValue);416 myStats = psVectorStats(myStats, tmpCol, NULL, NULL, 0); 417 p_psGetStatValue(myStats, &statValue); 403 418 overscanVector->data.F32[i] = statValue; 404 419 } … … 441 456 } 442 457 } 443 stat = psVectorStats(stat, binVec, NULL, NULL, 0);444 p_psGetStatValue( stat, &statValue);458 myStats = psVectorStats(myStats, binVec, NULL, NULL, 0); 459 p_psGetStatValue(myStats, &statValue); 445 460 myBin->data.F32[i] = statValue; 446 461 } … … 492 507 psF32 tmpF32 = 0.0; 493 508 if (fit == PM_FIT_POLYNOMIAL) { 494 tmpF32 = psPolynomial1DEval(myPoly, (( float) i) / ((float) nBin));509 tmpF32 = psPolynomial1DEval(myPoly, ((psF32) i) / ((psF32) nBin)); 495 510 } else if (fit == PM_FIT_SPLINE) { 496 tmpF32 = psSpline1DEval(mySpline, (( float) i) / ((float) nBin));511 tmpF32 = psSpline1DEval(mySpline, ((psF32) i) / ((psF32) nBin)); 497 512 } 498 513 for (j=0;j<(in->image)->numRows;j++) { 499 514 (in->image)->data.F32[j][i]-= tmpF32; 500 501 515 } 502 516 } … … 510 524 psF32 tmpF32 = 0.0; 511 525 if (fit == PM_FIT_POLYNOMIAL) { 512 tmpF32 = psPolynomial1DEval(myPoly, (( float) i) / ((float) nBin));526 tmpF32 = psPolynomial1DEval(myPoly, ((psF32) i) / ((psF32) nBin)); 513 527 } else if (fit == PM_FIT_SPLINE) { 514 tmpF32 = psSpline1DEval(mySpline, (( float) i) / ((float) nBin));528 tmpF32 = psSpline1DEval(mySpline, ((psF32) i) / ((psF32) nBin)); 515 529 } 516 530
Note:
See TracChangeset
for help on using the changeset viewer.
