Changeset 2147 for trunk/psModules/src/pmSubtractBias.c
- Timestamp:
- Oct 14, 2004, 4:15:48 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmSubtractBias.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmSubtractBias.c
r2141 r2147 6 6 * @author George Gusciora, MHPCC 7 7 * 8 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-10-15 0 1:11:16$8 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-15 02:15:48 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 200 200 pmOverscanAxis overScanAxis, 201 201 psStats *stat, 202 int nBin ,202 int nBinOrig, 203 203 pmFit fit, 204 204 const psReadout *bias) … … 217 217 psPolynomial1D *myPoly; 218 218 psSpline1D *mySpline; 219 int nBin; 219 220 220 221 PS_CHECK_NULL_PTR_RETURN_NULL(in); … … 265 266 } 266 267 267 // XXX: Is there a better way to extract a psVector from a psImage without 268 // having to copy every element in that vector? 269 270 // XXX: If we get here, do we know that overScanAxis == PM_OVERSCAN_ROWS 271 // or PM_OVERSCAN_COL? 272 273 // XXX: How to use multiple overscans? Currently, only the first is used. 274 275 if ((overScanAxis == PM_OVERSCAN_ROWS) || (overScanAxis == PM_OVERSCAN_COLUMNS)) { 276 myOverscanImage = (psImage *) ((overscans->head)->data); 277 278 if (overScanAxis == PM_OVERSCAN_ROWS) { 279 // We create a row vector and subtract this vector from image. 280 overscanVector = psVectorAlloc(myOverscanImage->numCols, PS_TYPE_F32); 281 for (i=0;i<overscanVector->n;i++) { 282 overscanVector->data.F32[i] = 0.0; 283 } 284 tmpRow = psVectorAlloc((in->image)->numRows, PS_TYPE_F32); 285 286 tmpOverscan = (psListElem *) overscans->head; 287 while (tmpOverscan) { 268 269 tmpOverscan = (psListElem *) overscans->head; 270 while (NULL != tmpOverscan) { 271 myOverscanImage = (psImage *) tmpOverscan->data; 272 273 // XXX: Is there a better way to extract a psVector from a psImage without 274 // having to copy every element in that vector? 275 // XXX: If we get here, do we know that overScanAxis == PM_OVERSCAN_ROWS 276 // or PM_OVERSCAN_COL? 277 278 if ((overScanAxis == PM_OVERSCAN_ROWS) || (overScanAxis == PM_OVERSCAN_COLUMNS)) { 279 if (overScanAxis == PM_OVERSCAN_ROWS) { 280 // We create a row vector and subtract this vector from image. 281 overscanVector = psVectorAlloc(myOverscanImage->numCols, PS_TYPE_F32); 282 for (i=0;i<overscanVector->n;i++) { 283 overscanVector->data.F32[i] = 0.0; 284 } 285 tmpRow = psVectorAlloc((in->image)->numRows, PS_TYPE_F32); 286 288 287 for (i=0;i<myOverscanImage->numCols;i++) { 289 288 for (j=0;j<myOverscanImage->numRows;j++) { … … 294 293 overscanVector->data.F32[i] = statValue; 295 294 } 296 // tmpOverscan = tmpOverscan->next; 297 tmpOverscan = NULL; 298 } 299 psFree(tmpRow); 300 if ((fit == PM_FIT_POLYNOMIAL) || 301 (fit == PM_FIT_SPLINE)) { 302 psVector *newVec = ScaleOverscanVector(overscanVector, (in->image)->numCols, fitSpec, fit); 303 psFree(overscanVector); 304 overscanVector = newVec; 305 } 306 } 307 if (overScanAxis == PM_OVERSCAN_COLUMNS) { 308 // We create a column vector and subtract this vector from image. 309 overscanVector = psVectorAlloc(myOverscanImage->numRows, PS_TYPE_F32); 310 for (i=0;i<overscanVector->n;i++) { 311 overscanVector->data.F32[i] = 0.0; 312 } 313 tmpCol = psVectorAlloc((in->image)->numCols, PS_TYPE_F32); 314 315 tmpOverscan = (psListElem *) overscans->head; 316 while (tmpOverscan) { 295 psFree(tmpRow); 296 if ((fit == PM_FIT_POLYNOMIAL) || (fit == PM_FIT_SPLINE)) { 297 psVector *newVec = ScaleOverscanVector(overscanVector, (in->image)->numCols, fitSpec, fit); 298 psFree(overscanVector); 299 overscanVector = newVec; 300 } 301 } 302 303 if (overScanAxis == PM_OVERSCAN_COLUMNS) { 304 // We create a column vector and subtract this vector from image. 305 overscanVector = psVectorAlloc(myOverscanImage->numRows, PS_TYPE_F32); 306 for (i=0;i<overscanVector->n;i++) { 307 overscanVector->data.F32[i] = 0.0; 308 } 309 tmpCol = psVectorAlloc((in->image)->numCols, PS_TYPE_F32); 310 317 311 for (i=0;i<myOverscanImage->numRows;i++) { 318 312 for (j=0;j<myOverscanImage->numCols;j++) { … … 323 317 overscanVector->data.F32[i] = statValue; 324 318 } 325 // tmpOverscan = tmpOverscan->next; 326 tmpOverscan = NULL; 327 } 328 psFree(tmpCol); 329 if ((fit == PM_FIT_POLYNOMIAL) || 330 (fit == PM_FIT_SPLINE)) { 331 psVector *newVec = ScaleOverscanVector(overscanVector, (in->image)->numRows, fitSpec, fit); 332 psFree(overscanVector); 333 overscanVector = newVec; 334 } 335 } 336 337 // 338 // Re-bin the overscan vector (change its length). 339 // 340 if ((nBin > 0) && (nBin < overscanVector->n)) { 341 numBins = 1+((overscanVector->n)/nBin); 342 myBin = psVectorAlloc(numBins, PS_TYPE_F32); 343 binVec = psVectorAlloc(nBin, PS_TYPE_F32); 344 345 for (i=0;i<numBins;i++) { 346 for(j=0;j<nBin;j++) { 347 if (overscanVector->n > ((i*nBin)+j)) { 348 binVec->data.F32[j] = overscanVector->data.F32[(i*nBin)+j]; 349 } else { 350 // XXX: we get here if nBin does not evenly divide 351 // the overscanVector vector. This is the last bin. Should 352 // we change the binVec->n to acknowledge that? 353 binVec->n = j; 354 } 355 } 356 stat = psVectorStats(stat, binVec, NULL, 0); 357 p_psGetStatValue(stat, &statValue); 358 myBin->data.F32[i] = statValue; 359 360 } 361 362 // Change the effective size of overscanVector. 363 overscanVector->n = numBins; 364 for (i=0;i<numBins;i++) { 365 overscanVector->data.F32[i] = myBin->data.F32[i]; 366 } 367 psFree(binVec); 368 psFree(myBin); 369 } else { 370 nBin = 1; 371 } 372 373 // 374 // Fit a polynomial to the overscan vector. 375 // 376 if (!((fitSpec == NULL) || (fit == PM_FIT_NONE))) { 377 if (fit == PM_FIT_POLYNOMIAL) { 378 myPoly = (psPolynomial1D *) fitSpec; 379 myPoly = psVectorFitPolynomial1D(myPoly, NULL, overscanVector, NULL); 319 320 psFree(tmpCol); 321 if ((fit == PM_FIT_POLYNOMIAL) || (fit == PM_FIT_SPLINE)) { 322 psVector *newVec = ScaleOverscanVector(overscanVector, (in->image)->numRows, fitSpec, fit); 323 psFree(overscanVector); 324 overscanVector = newVec; 325 } 326 } 327 328 // 329 // Re-bin the overscan vector (change its length). 330 // 331 if ((nBinOrig > 0) && (nBinOrig < overscanVector->n)) { 332 numBins = 1+((overscanVector->n)/nBinOrig); 333 myBin = psVectorAlloc(numBins, PS_TYPE_F32); 334 binVec = psVectorAlloc(nBinOrig, PS_TYPE_F32); 335 380 336 for (i=0;i<numBins;i++) { 381 overscanVector->data.F32[i] = psPolynomial1DEval((float) i, myPoly); 382 } 383 384 } else if (fit == PM_FIT_SPLINE) { 385 mySpline = (psSpline1D *) fitSpec; 386 // XXX: What is the point of doing this? 387 } 388 } 389 390 // 391 // Subtract overscan vector row-wise from the image. 392 // 393 if (overScanAxis == PM_OVERSCAN_ROWS) { 394 for (i=0;i<(in->image)->numCols;i++) { 395 for (j=0;j<(in->image)->numRows;j++) { 396 (in->image)->data.F32[j][i]-= overscanVector->data.F32[i/nBin]; 397 } 398 } 399 } 400 401 // 402 // Subtract overscan vector column-wise from the image. 403 // 404 if (overScanAxis == PM_OVERSCAN_COLUMNS) { 405 for (i=0;i<(in->image)->numRows;i++) { 406 for (j=0;j<(in->image)->numCols;j++) { 407 (in->image)->data.F32[i][j]-= overscanVector->data.F32[i/nBin]; 408 } 409 } 410 } 411 psFree(overscanVector); 412 return(in); 413 } 337 for(j=0;j<nBinOrig;j++) { 338 if (overscanVector->n > ((i*nBinOrig)+j)) { 339 binVec->data.F32[j] = overscanVector->data.F32[(i*nBinOrig)+j]; 340 } else { 341 // XXX: we get here if nBinOrig does not evenly divide 342 // the overscanVector vector. This is the last bin. Should 343 // we change the binVec->n to acknowledge that? 344 binVec->n = j; 345 } 346 } 347 stat = psVectorStats(stat, binVec, NULL, 0); 348 p_psGetStatValue(stat, &statValue); 349 myBin->data.F32[i] = statValue; 350 } 351 352 // Change the effective size of overscanVector. 353 overscanVector->n = numBins; 354 for (i=0;i<numBins;i++) { 355 overscanVector->data.F32[i] = myBin->data.F32[i]; 356 } 357 psFree(binVec); 358 psFree(myBin); 359 nBin = nBinOrig; 360 } else { 361 nBin = 1; 362 } 363 364 // 365 // Fit a polynomial to the overscan vector. 366 // 367 if (!((fitSpec == NULL) || (fit == PM_FIT_NONE))) { 368 if (fit == PM_FIT_POLYNOMIAL) { 369 myPoly = (psPolynomial1D *) fitSpec; 370 myPoly = psVectorFitPolynomial1D(myPoly, NULL, overscanVector, NULL); 371 for (i=0;i<numBins;i++) { 372 overscanVector->data.F32[i] = psPolynomial1DEval((float) i, myPoly); 373 } 374 375 } else if (fit == PM_FIT_SPLINE) { 376 mySpline = (psSpline1D *) fitSpec; 377 // XXX: What is the point of doing this? 378 } 379 } 380 381 // 382 // Subtract overscan vector row-wise from the image. 383 // 384 if (overScanAxis == PM_OVERSCAN_ROWS) { 385 for (i=0;i<(in->image)->numCols;i++) { 386 for (j=0;j<(in->image)->numRows;j++) { 387 (in->image)->data.F32[j][i]-= overscanVector->data.F32[i/nBin]; 388 } 389 } 390 } 391 392 // 393 // Subtract overscan vector column-wise from the image. 394 // 395 if (overScanAxis == PM_OVERSCAN_COLUMNS) { 396 for (i=0;i<(in->image)->numRows;i++) { 397 for (j=0;j<(in->image)->numCols;j++) { 398 (in->image)->data.F32[i][j]-= overscanVector->data.F32[i/nBin]; 399 } 400 } 401 } 402 psFree(overscanVector); 403 } 404 tmpOverscan = tmpOverscan->next; 405 } 406 414 407 415 408 if (bias != NULL) { 416 409 return(psSubtractFrame(in, bias)); 417 410 } 418 419 // XXX: psErrorMsg(): Shouldn't get here?420 411 return(in); 421 412 }
Note:
See TracChangeset
for help on using the changeset viewer.
