IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 27, 2008, 2:12:12 PM (18 years ago)
Author:
Paul Price
Message:

Trying to reduce memory usage, which gets somewhat large in the end of the stack.

File:
1 edited

Legend:

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

    r19241 r19243  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.35 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2008-08-27 22:31:03 $
     10 *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2008-08-28 00:12:12 $
    1212 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
    1313 *
     
    205205        return;
    206206    }
    207     data->inspect = psPixelsAdd(data->inspect, data->inspect->nalloc, x, y);
     207    data->inspect = psPixelsAdd(data->inspect, data->inspect ? data->inspect->nalloc : PIXEL_LIST_BUFFER ,
     208                                x, y);
    208209    return;
    209210}
     
    476477// can be identified easily.
    477478static psArray *pixelMapGenerate(const psArray *input, // Data to stack
    478                                  int numCols, int numRows // Size of (sky) images
     479                                 int minCols, int maxCols, int minRows, int maxRows // Bounds of interest
    479480    )
    480481{
     482    int numCols = maxCols - minCols + 1, numRows = maxRows - minRows + 1; // Size of map
     483
    481484    psArray *map = psArrayAlloc(numRows); // The pixel map
    482485    for (int y = 0; y < numRows; y++) {
     
    492495        psPixels *pixels = data->reject; // The rejected pixels
    493496        for (int j = 0; j < pixels->n; j++) {
    494             int x = pixels->data[j].x, y = pixels->data[j].y; // Coordinates of interest
     497            int x = pixels->data[j].x - minCols, y = pixels->data[j].y - minRows; // Coordinates of interest
    495498            if (x < 0 || x >= numCols || y < 0 || y >= numRows) {
    496                 //                psWarning("Bad pixel coordinate: %d,%d --- ignored.", x, y);
    497499                continue;
    498500            }
     
    513515// Query a "pixel map", by returning the list of image indices for a particular pixel.
    514516static psVector *pixelMapQuery(const psArray *map, // Pixel map
     517                               int x0, int y0, // Offset into map
    515518                               int x, int y // Coordinates of interest
    516519    )
    517520{
     521    // Adjust for offset
     522    x -= x0;
     523    y -= y0;
     524
    518525    assert(y >= 0 && y < map->n);
    519526    psArray *colMap = map->data[y];     // Columns for that row
     
    624631        psImage *combinedVariance = combined->weight; // Combined variance map
    625632
    626         psArray *pixelMap = pixelMapGenerate(input, maxInputCols, maxInputRows); // Map of pixels to source
     633        psArray *pixelMap = pixelMapGenerate(input, minInputCols, maxInputCols,
     634                                             minInputRows, maxInputRows); // Map of pixels to source
    627635        psPixels *pixels = NULL;            // Total list of pixels, with no duplicates
    628636        for (int i = 0; i < num; i++) {
     
    638646            for (int y = minInputRows; y < maxInputRows; y++) {
    639647                for (int x = minInputCols; x < maxInputCols; x++) {
    640                     psVector *reject = pixelMapQuery(pixelMap, x, y); // Inspect these images closely
     648                    psVector *reject = pixelMapQuery(pixelMap, minInputCols, minInputRows,
     649                                                     x, y); // Reject these images
    641650                    combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, varFactors,
    642651                                  reject, x, y, maskVal, bad, numIter, rej, useVariance, safe, buffer);
     
    651660                    continue;
    652661                }
    653                 psVector *reject = pixelMapQuery(pixelMap, x, y); // Inspect these images closely
     662                psVector *reject = pixelMapQuery(pixelMap, minInputCols, minInputRows,
     663                                                 x, y); // Reject these images
    654664                combinePixels(combinedImage, combinedMask, combinedVariance, input, weights, varFactors,
    655665                              reject, x, y, maskVal, bad, numIter, rej, useVariance, safe, buffer);
Note: See TracChangeset for help on using the changeset viewer.