IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 22, 2008, 9:28:00 AM (18 years ago)
Author:
Paul Price
Message:

Merging in branch development. ppStack now works with incremental reads. Needs some cleanup, but it works.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppStack/src/ppStackMatch.c

    r15850 r16605  
    99#include "ppStack.h"
    1010
     11#define ARRAY_BUFFER 16                 // Number to add to array at a time
     12
     13
    1114//#define TESTING
    1215
    13 bool ppStackMatch(pmReadout *output, const pmReadout *input, const pmReadout *sourcesRO,
    14                   const pmPSF *psf, const pmConfig *config)
     16bool ppStackMatch(pmReadout *readout, psArray **regions, psArray **kernels,
     17                  const pmReadout *sourcesRO, const pmPSF *psf, const pmConfig *config)
    1518{
     19    assert(readout);
     20    assert(regions && !*regions);
     21    assert(kernels && !*kernels);
     22    assert(sourcesRO);
     23    assert(psf);
     24    assert(config);
     25
    1626    // Look up appropriate values from the ppSub recipe
    1727    bool mdok;                          // Status of MD lookup
     
    6878    pmReadout *fake = pmReadoutAlloc(NULL); // Fake readout with target PSF
    6979
    70     if (!pmReadoutFakeFromSources(fake, input->image->numCols, input->image->numRows, sources, NULL, NULL,
     80    if (!pmReadoutFakeFromSources(fake, readout->image->numCols, readout->image->numRows, sources, NULL, NULL,
    7181                                  psf, powf(10.0, -0.4 * maxMag), 0, false)) {
    7282        psError(PS_ERR_UNKNOWN, false, "Unable to generate fake image with target PSF.");
     
    8595
    8696    // Do the image matching
    87     if (!pmSubtractionMatch(output, NULL, input, fake, footprint, regionSize, spacing, threshold,
     97    pmReadout *output = pmReadoutAlloc(NULL); // Output readout, for holding results temporarily
     98    if (!pmSubtractionMatch(output, NULL, readout, fake, footprint, regionSize, spacing, threshold,
    8899                            sources, stampsName, type, size, order, widths, orders, inner, ringsOrder,
    89100                            binning, optimum, optWidths, optOrder, optThresh, iter, rej, maskBad,
     
    92103        psFree(fake);
    93104        psFree(optWidths);
     105        psFree(output);
    94106        return false;
    95107    }
     
    97109    psFree(optWidths);
    98110
     111    // Replace original images with convolved
     112    psFree(readout->image);
     113    psFree(readout->mask);
     114    psFree(readout->weight);
     115    readout->image  = psMemIncrRefCounter(output->image);
     116    readout->mask   = psMemIncrRefCounter(output->mask);
     117    readout->weight = psMemIncrRefCounter(output->weight);
     118
     119    // Extract the regions and solutions used in the image matching
     120    // This stops them from being freed when we iterate back up the FPA
     121    *regions = psArrayAllocEmpty(ARRAY_BUFFER); // Array of regions
     122    {
     123        psString regex = NULL;          // Regular expression
     124        psStringAppend(&regex, "^%s$", PM_SUBTRACTION_ANALYSIS_REGION);
     125        psMetadataIterator *iter = psMetadataIteratorAlloc(output->analysis, PS_LIST_HEAD, regex); // Iterator
     126        psFree(regex);
     127        psMetadataItem *item = NULL;// Item from iteration
     128        while ((item = psMetadataGetAndIncrement(iter))) {
     129            assert(item->type == PS_DATA_REGION);
     130            *regions = psArrayAdd(*regions, ARRAY_BUFFER, item->data.V);
     131        }
     132        psFree(iter);
     133    }
     134    *kernels = psArrayAllocEmpty(ARRAY_BUFFER); // Array of kernels
     135    {
     136        psString regex = NULL;          // Regular expression
     137        psStringAppend(&regex, "^%s$", PM_SUBTRACTION_ANALYSIS_KERNEL);
     138        psMetadataIterator *iter = psMetadataIteratorAlloc(output->analysis, PS_LIST_HEAD, regex); // Iterator
     139        psFree(regex);
     140        psMetadataItem *item = NULL;// Item from iteration
     141        while ((item = psMetadataGetAndIncrement(iter))) {
     142            assert(item->type == PS_DATA_UNKNOWN);
     143            // Set the normalisation dimensions, since these will be otherwise unavailable when reading the
     144            // images by scans.
     145            pmSubtractionKernels *kernel = item->data.V; // Kernel used in subtraction
     146            kernel->numCols = readout->image->numCols;
     147            kernel->numRows = readout->image->numRows;
     148
     149            *kernels = psArrayAdd(*kernels, ARRAY_BUFFER, kernel);
     150        }
     151        psFree(iter);
     152    }
     153    assert((*regions)->n == (*kernels)->n);
     154
     155
     156    psFree(output);
     157
    99158    return true;
    100159}
Note: See TracChangeset for help on using the changeset viewer.