Changeset 5516 for trunk/psModules/src/imcombine/pmReadoutCombine.c
- Timestamp:
- Nov 15, 2005, 10:09:03 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmReadoutCombine.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmReadoutCombine.c
r5170 r5516 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $8 * @date $Date: 2005- 09-28 20:43:52$7 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2005-11-15 20:09:03 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 374 374 return(output); 375 375 } 376 377 378 /* This function measures the robust median at each of the minimum and maximum 379 * coordinates and determines the difference and mean of the two values. The size 380 * of the box used to make the measurement at each point is specified by the 381 * configuration variable FRINGE_SQUARE_RADIUS. From the collection of 382 * differences, the robust median is calculated, and returned as part of the 383 * fringe statistics. For each fringe point, the values of delta and midValue are 384 * also assigned and available to the user on return. 385 */ 386 387 psStats *pmFringeStats( 388 psArray *fringePoints, 389 psImage *image, 390 psMetadata *config) 391 { 392 PS_ASSERT_PTR_NON_NULL(fringePoints, NULL); 393 // for (psS32 i = 0 ; i < fringePoints->n ; i++) { 394 // if (!psMemCheckFringePoint((pmFringePoint *) fringePoints->data[i])) { 395 // psError(PS_ERR_UNKNOWN, true, "fringePoints->data[%d] is not of type pmFringePoint.\n"); 396 // return(NULL); 397 // } 398 // } 399 PS_ASSERT_IMAGE_NON_NULL(image, NULL); 400 PS_ASSERT_IMAGE_NON_EMPTY(image, NULL); 401 PS_ASSERT_IMAGE_TYPE(image, PS_TYPE_F32, NULL); 402 PS_ASSERT_PTR_NON_NULL(config, NULL); 403 404 psBool rc; 405 psF32 frSquareRadius = psMetadataLookupF32(&rc, config, "FRINGE_SQUARE_RADIUS"); 406 if (!rc) { 407 psError(PS_ERR_UNKNOWN, true, "Could not determing the fringe radius from the metadata.\n"); 408 } 409 410 psRegion minRegion; 411 psRegion maxRegion; 412 psStats *minStats = psStatsAlloc(PS_STAT_ROBUST_MEAN); 413 psStats *maxStats = psStatsAlloc(PS_STAT_ROBUST_MEAN); 414 psStats *diffStats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); 415 psVector *diffs = psVectorAlloc(fringePoints->n, PS_TYPE_F32); 416 417 // 418 // Loop through each fringe point. Determine the robust mean around 419 // the min and max for that fringe point. Save the difference between 420 // those two numbers in psVector diffs. 421 // 422 // XXX: Ensure you have the radius correct. (add 1 to x1 and y1?) 423 // 424 for (psS32 i = 0 ; i < fringePoints->n ; i++) { 425 pmFringePoint *fp = (pmFringePoint *) fringePoints->data[i]; 426 minRegion.x0 = fp->xMin - frSquareRadius; 427 minRegion.x1 = fp->xMin + frSquareRadius; 428 minRegion.y0 = fp->yMin - frSquareRadius; 429 minRegion.y1 = fp->yMin + frSquareRadius; 430 psImage *minSubImage = psImageSubset(image, minRegion); 431 minStats = psImageStats(minStats, minSubImage, NULL, 0); 432 433 maxRegion.x0 = fp->xMax - frSquareRadius; 434 maxRegion.x1 = fp->xMax + frSquareRadius; 435 maxRegion.y0 = fp->yMax - frSquareRadius; 436 maxRegion.y1 = fp->yMax + frSquareRadius; 437 psImage *maxSubImage = psImageSubset(image, maxRegion); 438 maxStats = psImageStats(maxStats, maxSubImage, NULL, 0); 439 440 if ((minStats == NULL) || (maxStats == NULL)) { 441 psError(PS_ERR_UNKNOWN, true, "Could not determine robust mean on subimage.\n"); 442 psFree(minStats); 443 psFree(maxStats); 444 return(NULL); 445 } 446 447 fp->midValue = 0.5 * (maxStats->robustMean + minStats->robustMean); 448 fp->delta = maxStats->robustMean - minStats->robustMean; 449 diffs->data.F32[i] = fp->delta; 450 } 451 psFree(minStats); 452 psFree(maxStats); 453 454 diffStats = psVectorStats(diffStats, diffs, NULL, NULL, 0); 455 psFree(diffs); 456 if (diffStats == NULL) { 457 psError(PS_ERR_UNKNOWN, true, "Could not determine robust median of the differences.\n"); 458 return(NULL); 459 } 460 return(diffStats); 461 } 462
Note:
See TracChangeset
for help on using the changeset viewer.
