IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14625


Ignore:
Timestamp:
Aug 22, 2007, 4:24:58 PM (19 years ago)
Author:
Paul Price
Message:

Changes to stacking to allow it to work on convolved images. Pulled a few things out with #ifdef.

Location:
trunk/psModules/src/imcombine
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmStack.c

    r14459 r14625  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.11 $ $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 $
    1212 *
    1313 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    7373static void stackDataFree(pmStackData *data)
    7474{
    75     psFree(data->detector);
    76     psFree(data->sky);
     75    psFree(data->readout);
    7776    psFree(data->pixels);
    7877    return;
     
    222221    for (int i = 0; i < num; i++) {
    223222        pmStackData *data = inputs->data[i]; // Stack data of interest
    224         psImage *image = data->sky->image; // Image of interest
    225         psImage *weight = data->sky->weight; // Weight map of interest
    226         psImage *mask = data->sky->mask; // Mask of interest
     223        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
    227226        pixelData->data.F32[i] = image->data.F32[y][x];
    228227        if (weight) {
     
    306305
    307306// 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?
     307static bool validateInputData(bool *haveWeights, // Do we have weights in the sky images?
    311308                              bool *havePixels, // Do we have lists of pixels?
    312309                              int *num,    // Number of inputs
     
    317314    PS_ASSERT_ARRAY_NON_NULL(input, false);
    318315    *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
    350338    for (int i = 1; i < *num; i++) {
    351339        pmStackData *data = input->data[i]; // Stack data for this input
    352340        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.");
    360343            return false;
    361344        }
     
    364347            return false;
    365348        }
    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);
    385359        }
    386360    }
     
    390364
    391365
    392 
     366#if 0
    393367// Examine a pixel carefully to see if it should be rejected in the stack by convolving all the input images
    394368// to the same seeing, and clipping there.
     
    416390        pmStackData *data = input->data[i]; // Stacking data
    417391        int radius = extent * seeing->data.F32[i]; // How much to convolve
    418         psImage *image = data->sky->image; // Image to convolve
    419         psImage *mask = data->sky->mask; // Image mask
     392        psImage *image = data->readout->image; // Image to convolve
     393        psImage *mask = data->readout->mask; // Image mask
    420394
    421395        int xMin = PS_MAX(xPix - radius, 0);
     
    476450    return true;
    477451}
    478 
     452#endif
    479453
    480454
     
    530504
    531505/// Constructor
    532 pmStackData *pmStackDataAlloc(pmReadout *sky, float seeing, float weight)
     506pmStackData *pmStackDataAlloc(pmReadout *readout, float weight)
    533507{
    534508    pmStackData *data = psAlloc(sizeof(pmStackData)); // Stack data, to return
    535509    psMemSetDeallocator(data, (psFreeFunc)stackDataFree);
    536510
    537     data->detector = NULL;
    538 
    539     data->sky = psMemIncrRefCounter(sky);
     511    data->readout = psMemIncrRefCounter(readout);
    540512    data->pixels = NULL;
    541     data->seeing = seeing;
    542513    data->weight = weight;
    543514
     
    550521{
    551522    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?
    555524    bool havePixels;                    // Do we have lists of pixels?
    556525    int num;                            // Number of inputs
    557526    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)) {
    560528        return false;
    561529    }
     
    571539        PS_ASSERT_IMAGES_SIZE_EQUAL(combined->image, combined->mask, false);
    572540    }
    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 images
    581 
    582         // ...
    583 
    584 #if 0
    585         numCols = data->sky->image->numCols;
    586         numRows = data->sky->image->numRows;
    587 #endif
    588     }
    589541
    590542    // Pull out the weightings
     
    635587
    636588        psImage *combinedWeights = combined->weight; // Combined weight map
    637         if (haveSkyWeights && !combinedWeights) {
     589        if (haveWeights && !combinedWeights) {
    638590            combined->weight = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    639591            combinedWeights = combined->weight;
     
    668620    psFree(buffer);
    669621
    670     psList *cells = psListAlloc(NULL);  // List of cells, for concept update
    671     for (int i = 0; i < num; i++) {
    672         pmStackData *data = input->data[i]; // Stacking data; contains the list of pixels
    673         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 
    682622    return true;
    683623}
    684624
     625#if 0
    685626bool pmStackReject(psArray *input, psMaskType maskVal, float extent, float threshold)
    686627{
    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?
    690629    bool havePixels;                    // Do we have lists of pixels?
    691630    int num;                            // Number of inputs
    692631    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)) {
    695633        return false;
    696634    }
     
    768706    return true;
    769707}
    770 
     708#endif
  • trunk/psModules/src/imcombine/pmStack.h

    r13457 r14625  
    88 * @author GLG, MHPCC
    99 *
    10  * @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    11  * @date $Date: 2007-05-22 03:59:32 $
     10 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     11 * @date $Date: 2007-08-23 02:24:58 $
    1212 * Copyright 2004-2007 Institute for Astronomy, University of Hawaii
    1313 */
     
    2626/// Container for input image
    2727typedef struct {
    28     pmReadout *detector;                ///< Original (unwarped) readout from the detector
    29     pmReadout *sky;                     ///< Warped readout (sky cell)
     28    pmReadout *readout;                 ///< Warped readout (sky cell)
    3029    psPixels *pixels;                   ///< Pixels to inspect or reject
    31     float seeing;                       ///< Seeing FWHM (pixels)
    3230    float weight;                       ///< Weight to apply
    3331} pmStackData;
    3432
    3533/// Constructor
    36 pmStackData *pmStackDataAlloc(pmReadout *sky, ///< Warped readout (sky cell)
    37                               float seeing, ///< Seeing FWHM (pixels)
     34pmStackData *pmStackDataAlloc(pmReadout *readout, ///< Warped readout (sky cell)
    3835                              float weight ///< Weight to apply
    3936    );
Note: See TracChangeset for help on using the changeset viewer.