Changeset 14625
- Timestamp:
- Aug 22, 2007, 4:24:58 PM (19 years ago)
- Location:
- trunk/psModules/src/imcombine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmStack.c
r14459 r14625 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1.1 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2007-08- 10 00:34:04$10 * @version $Revision: 1.12 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2007-08-23 02:24:58 $ 12 12 * 13 13 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 73 73 static void stackDataFree(pmStackData *data) 74 74 { 75 psFree(data->detector); 76 psFree(data->sky); 75 psFree(data->readout); 77 76 psFree(data->pixels); 78 77 return; … … 222 221 for (int i = 0; i < num; i++) { 223 222 pmStackData *data = inputs->data[i]; // Stack data of interest 224 psImage *image = data-> sky->image; // Image of interest225 psImage *weight = data-> sky->weight; // Weight map of interest226 psImage *mask = data-> sky->mask; // Mask of interest223 psImage *image = data->readout->image; // Image of interest 224 psImage *weight = data->readout->weight; // Weight map of interest 225 psImage *mask = data->readout->mask; // Mask of interest 227 226 pixelData->data.F32[i] = image->data.F32[y][x]; 228 227 if (weight) { … … 306 305 307 306 // Ensure the input array of pmStackData is valid, and get some details out of it 308 static bool validateInputData(bool *haveDetector, // Do we have the detector images? 309 bool *haveSky, // Do we have the sky images? 310 bool *haveSkyWeights, // Do we have weights in the sky images? 307 static bool validateInputData(bool *haveWeights, // Do we have weights in the sky images? 311 308 bool *havePixels, // Do we have lists of pixels? 312 309 int *num, // Number of inputs … … 317 314 PS_ASSERT_ARRAY_NON_NULL(input, false); 318 315 *num = input->n; 319 { 320 pmStackData *data = input->data[0]; // First image off the rank 321 PS_ASSERT_PTR_NON_NULL(data, false); 322 assert(psMemGetDeallocator(data) == (psFreeFunc)stackDataFree); // Ensure it's the right type 323 *haveDetector = (data->detector != NULL); 324 if (*haveDetector) { 325 PS_ASSERT_IMAGE_NON_NULL(data->detector->image, false); 326 PS_ASSERT_IMAGE_NON_NULL(data->detector->mask, false); 327 PS_ASSERT_IMAGES_SIZE_EQUAL(data->detector->image, data->detector->mask, false); 328 PS_ASSERT_IMAGE_TYPE(data->detector->image, PS_TYPE_F32, false); 329 PS_ASSERT_IMAGE_TYPE(data->detector->mask, PS_TYPE_MASK, false); 330 } 331 *haveSky = (data->sky != NULL); 332 *haveSkyWeights = false; 333 if (*haveSky) { 334 PS_ASSERT_IMAGE_NON_NULL(data->sky->image, false); 335 PS_ASSERT_IMAGE_TYPE(data->sky->image, PS_TYPE_F32, false); 336 PS_ASSERT_IMAGE_NON_NULL(data->sky->mask, false); 337 PS_ASSERT_IMAGE_TYPE(data->sky->mask, PS_TYPE_MASK, false); 338 PS_ASSERT_IMAGES_SIZE_EQUAL(data->sky->image, data->sky->mask, false); 339 *numCols = data->sky->image->numCols; 340 *numRows = data->sky->image->numRows; 341 if (data->sky->weight) { 342 *haveSkyWeights = true; 343 PS_ASSERT_IMAGE_NON_NULL(data->sky->weight, false); 344 PS_ASSERT_IMAGES_SIZE_EQUAL(data->sky->image, data->sky->weight, false); 345 PS_ASSERT_IMAGE_TYPE(data->sky->weight, PS_TYPE_F32, false); 346 } 347 } 348 *havePixels = (data->pixels != NULL); 349 } 316 317 // The first is a template 318 pmStackData *data = input->data[0]; // First image off the rank 319 PS_ASSERT_PTR_NON_NULL(data, false); 320 assert(psMemGetDeallocator(data) == (psFreeFunc)stackDataFree); // Ensure it's the right type 321 *haveWeights = false; 322 PS_ASSERT_IMAGE_NON_NULL(data->readout->image, false); 323 PS_ASSERT_IMAGE_TYPE(data->readout->image, PS_TYPE_F32, false); 324 PS_ASSERT_IMAGE_NON_NULL(data->readout->mask, false); 325 PS_ASSERT_IMAGE_TYPE(data->readout->mask, PS_TYPE_MASK, false); 326 PS_ASSERT_IMAGES_SIZE_EQUAL(data->readout->image, data->readout->mask, false); 327 *numCols = data->readout->image->numCols; 328 *numRows = data->readout->image->numRows; 329 if (data->readout->weight) { 330 *haveWeights = true; 331 PS_ASSERT_IMAGE_NON_NULL(data->readout->weight, false); 332 PS_ASSERT_IMAGES_SIZE_EQUAL(data->readout->image, data->readout->weight, false); 333 PS_ASSERT_IMAGE_TYPE(data->readout->weight, PS_TYPE_F32, false); 334 } 335 *havePixels = (data->pixels != NULL); 336 337 // Make sure the rest correspond with the first 350 338 for (int i = 1; i < *num; i++) { 351 339 pmStackData *data = input->data[i]; // Stack data for this input 352 340 assert(psMemGetDeallocator(data) == (psFreeFunc)stackDataFree); // Ensure it's the right type 353 if ((*haveDetector && !data->detector) || (data->detector && !*haveDetector)) { 354 psError(PS_ERR_UNEXPECTED_NULL, true, 355 "The detector readout is specified in some but not all inputs."); 356 return false; 357 } 358 if ((*haveSky && !data->sky) || (data->sky && !*haveSky)) { 359 psError(PS_ERR_UNEXPECTED_NULL, true, "The sky cell is specified in some but not all inputs."); 341 if (!data->readout) { 342 psError(PS_ERR_UNEXPECTED_NULL, true, "The readout is specified in some but not all inputs."); 360 343 return false; 361 344 } … … 364 347 return false; 365 348 } 366 if (*haveDetector) { 367 PS_ASSERT_IMAGE_NON_NULL(data->detector->image, false); 368 PS_ASSERT_IMAGE_NON_NULL(data->detector->mask, false); 369 PS_ASSERT_IMAGE_TYPE(data->detector->image, PS_TYPE_F32, false); 370 PS_ASSERT_IMAGE_TYPE(data->detector->mask, PS_TYPE_MASK, false); 371 PS_ASSERT_IMAGES_SIZE_EQUAL(data->detector->image, data->detector->mask, false); 372 } 373 if (*haveSky) { 374 PS_ASSERT_IMAGE_NON_NULL(data->sky->image, false); 375 PS_ASSERT_IMAGE_NON_NULL(data->sky->mask, false); 376 PS_ASSERT_IMAGE_TYPE(data->sky->image, PS_TYPE_F32, false); 377 PS_ASSERT_IMAGE_TYPE(data->sky->mask, PS_TYPE_MASK, false); 378 PS_ASSERT_IMAGE_SIZE(data->sky->image, *numCols, *numRows, false); 379 PS_ASSERT_IMAGES_SIZE_EQUAL(data->sky->image, data->sky->mask, false); 380 if (*haveSkyWeights) { 381 PS_ASSERT_IMAGE_NON_NULL(data->sky->weight, false); 382 PS_ASSERT_IMAGES_SIZE_EQUAL(data->sky->image, data->sky->weight, false); 383 PS_ASSERT_IMAGE_TYPE(data->sky->weight, PS_TYPE_F32, false); 384 } 349 PS_ASSERT_IMAGE_NON_NULL(data->readout->image, false); 350 PS_ASSERT_IMAGE_NON_NULL(data->readout->mask, false); 351 PS_ASSERT_IMAGE_TYPE(data->readout->image, PS_TYPE_F32, false); 352 PS_ASSERT_IMAGE_TYPE(data->readout->mask, PS_TYPE_MASK, false); 353 PS_ASSERT_IMAGE_SIZE(data->readout->image, *numCols, *numRows, false); 354 PS_ASSERT_IMAGES_SIZE_EQUAL(data->readout->image, data->readout->mask, false); 355 if (*haveWeights) { 356 PS_ASSERT_IMAGE_NON_NULL(data->readout->weight, false); 357 PS_ASSERT_IMAGES_SIZE_EQUAL(data->readout->image, data->readout->weight, false); 358 PS_ASSERT_IMAGE_TYPE(data->readout->weight, PS_TYPE_F32, false); 385 359 } 386 360 } … … 390 364 391 365 392 366 #if 0 393 367 // Examine a pixel carefully to see if it should be rejected in the stack by convolving all the input images 394 368 // to the same seeing, and clipping there. … … 416 390 pmStackData *data = input->data[i]; // Stacking data 417 391 int radius = extent * seeing->data.F32[i]; // How much to convolve 418 psImage *image = data-> sky->image; // Image to convolve419 psImage *mask = data-> sky->mask; // Image mask392 psImage *image = data->readout->image; // Image to convolve 393 psImage *mask = data->readout->mask; // Image mask 420 394 421 395 int xMin = PS_MAX(xPix - radius, 0); … … 476 450 return true; 477 451 } 478 452 #endif 479 453 480 454 … … 530 504 531 505 /// Constructor 532 pmStackData *pmStackDataAlloc(pmReadout * sky, float seeing, float weight)506 pmStackData *pmStackDataAlloc(pmReadout *readout, float weight) 533 507 { 534 508 pmStackData *data = psAlloc(sizeof(pmStackData)); // Stack data, to return 535 509 psMemSetDeallocator(data, (psFreeFunc)stackDataFree); 536 510 537 data->detector = NULL; 538 539 data->sky = psMemIncrRefCounter(sky); 511 data->readout = psMemIncrRefCounter(readout); 540 512 data->pixels = NULL; 541 data->seeing = seeing;542 513 data->weight = weight; 543 514 … … 550 521 { 551 522 PS_ASSERT_PTR_NON_NULL(combined, false); 552 bool haveDetector; // Do we have the detector images? 553 bool haveSky; // Do we have the sky images? 554 bool haveSkyWeights; // Do we have the sky weight maps? 523 bool haveWeights; // Do we have the weight maps? 555 524 bool havePixels; // Do we have lists of pixels? 556 525 int num; // Number of inputs 557 526 int numCols, numRows; // Size of (sky) images 558 if (!validateInputData(&haveDetector, &haveSky, &haveSkyWeights, &havePixels, &num, 559 &numCols, &numRows, input)) { 527 if (!validateInputData(&haveWeights, &havePixels, &num, &numCols, &numRows, input)) { 560 528 return false; 561 529 } … … 571 539 PS_ASSERT_IMAGES_SIZE_EQUAL(combined->image, combined->mask, false); 572 540 } 573 if (!haveDetector && !haveSky) {574 psError(PS_ERR_UNEXPECTED_NULL, true, "Nothing to combine!");575 return false;576 }577 578 579 if (!haveSky) {580 // Need to generate the sky cell images581 582 // ...583 584 #if 0585 numCols = data->sky->image->numCols;586 numRows = data->sky->image->numRows;587 #endif588 }589 541 590 542 // Pull out the weightings … … 635 587 636 588 psImage *combinedWeights = combined->weight; // Combined weight map 637 if (have SkyWeights && !combinedWeights) {589 if (haveWeights && !combinedWeights) { 638 590 combined->weight = psImageAlloc(numCols, numRows, PS_TYPE_F32); 639 591 combinedWeights = combined->weight; … … 668 620 psFree(buffer); 669 621 670 psList *cells = psListAlloc(NULL); // List of cells, for concept update671 for (int i = 0; i < num; i++) {672 pmStackData *data = input->data[i]; // Stacking data; contains the list of pixels673 psListAdd(cells, PS_LIST_TAIL, data->sky->parent);674 }675 if (!pmConceptsAverageCells(combined->parent, cells, NULL, NULL, false)) {676 psError(PS_ERR_UNKNOWN, false, "Unable to average concepts for input sky readouts.");677 psFree(cells);678 return false;679 }680 psFree(cells);681 682 622 return true; 683 623 } 684 624 625 #if 0 685 626 bool pmStackReject(psArray *input, psMaskType maskVal, float extent, float threshold) 686 627 { 687 bool haveDetector; // Do we have the detector images? 688 bool haveSky; // Do we have the sky images? 689 bool haveSkyWeights; // Do we have the sky weight maps? 628 bool haveWeights; // Do we have the sky weight maps? 690 629 bool havePixels; // Do we have lists of pixels? 691 630 int num; // Number of inputs 692 631 int numCols, numRows; // Size of (sky) images 693 if (!validateInputData(&haveDetector, &haveSky, &haveSkyWeights, &havePixels, 694 &num, &numCols, &numRows, input)) { 632 if (!validateInputData(&haveWeights, &havePixels, &num, &numCols, &numRows, input)) { 695 633 return false; 696 634 } … … 768 706 return true; 769 707 } 770 708 #endif -
trunk/psModules/src/imcombine/pmStack.h
r13457 r14625 8 8 * @author GLG, MHPCC 9 9 * 10 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2007-0 5-22 03:59:32$10 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2007-08-23 02:24:58 $ 12 12 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii 13 13 */ … … 26 26 /// Container for input image 27 27 typedef struct { 28 pmReadout *detector; ///< Original (unwarped) readout from the detector 29 pmReadout *sky; ///< Warped readout (sky cell) 28 pmReadout *readout; ///< Warped readout (sky cell) 30 29 psPixels *pixels; ///< Pixels to inspect or reject 31 float seeing; ///< Seeing FWHM (pixels)32 30 float weight; ///< Weight to apply 33 31 } pmStackData; 34 32 35 33 /// Constructor 36 pmStackData *pmStackDataAlloc(pmReadout *sky, ///< Warped readout (sky cell) 37 float seeing, ///< Seeing FWHM (pixels) 34 pmStackData *pmStackDataAlloc(pmReadout *readout, ///< Warped readout (sky cell) 38 35 float weight ///< Weight to apply 39 36 );
Note:
See TracChangeset
for help on using the changeset viewer.
