IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 19, 2006, 4:38:28 PM (21 years ago)
Author:
Paul Price
Message:

Getting a working ppImage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_rel9_p0/psModules/src/astrom/pmChipMosaic.c

    r5974 r6062  
    33
    44#include "pslib.h"
    5 #include "pmAstrometry.h"
     5#include "pmFPA.h"
    66#include "pmChipMosaic.h"
    77
     
    3434    // Get the maximum extent of the mosaic image
    3535    int xMin = INT_MAX;
    36     int xMax = 0;
     36    int xMax = - INT_MAX;
    3737    int yMin = INT_MAX;
    38     int yMax = 0;
     38    int yMax = - INT_MAX;
    3939    for (int i = 0; i < source->n; i++) {
    4040        psImage *image = source->data[i]; // The image of interest
     41        if (!image) {
     42            continue;
     43        }
    4144
    4245        assert(image->type.type == PS_TYPE_F32); // Only implemented for F32 images so far.
     
    7477    for (int i = 0; i < source->n; i++) {
    7578        psImage *image = source->data[i]; // The image of interest
     79        if (!image) {
     80            continue;
     81        }
    7682        if (xBinSource->data.S32[i] == xBinTarget && yBinSource->data.S32[i] == yBinTarget &&
    7783                xFlip->data.U8[i] == 0 && yFlip->data.U8[i] == 0) {
     
    107113
    108114// Mosaic a chip together into a single image
    109 static psImage *mosaicChip(pmChip *chip,// Chip to mosaic
    110                            int xBinChip, int yBinChip // Binning of mosaic image in x and y
    111                           )
     115static bool mosaicChip(pmChip *chip,// Chip to mosaic
     116                       int xBinChip, int yBinChip // Binning of mosaic image in x and y
     117                      )
    112118{
    113119
    114120    psArray *cells = chip->cells;       // The array of cells
    115121    psArray *images = psArrayAlloc(cells->n); // Array of images that will be mosaicked
     122    psArray *weights = psArrayAlloc(cells->n); // Array of weight images to be mosaicked
     123    psArray *masks = psArrayAlloc(cells->n); // Array of mask images to be mosaicked
    116124    psVector *x0 = psVectorAlloc(cells->n, PS_TYPE_S32); // Origin x coordinates
    117125    psVector *y0 = psVectorAlloc(cells->n, PS_TYPE_S32); // Origin y coordinates
     
    126134        x0->data.S32[i] = psMetadataLookupS32(NULL, cell->concepts, "CELL.X0");
    127135        y0->data.S32[i] = psMetadataLookupS32(NULL, cell->concepts, "CELL.Y0");
     136        psTrace(__func__, 9, "Cell %d: x0=%d y0=%d\n", i, x0->data.S32[i], y0->data.S32[i]);
    128137        xBin->data.S32[i] = psMetadataLookupS32(NULL, cell->concepts, "CELL.XBIN");
    129138        yBin->data.S32[i] = psMetadataLookupS32(NULL, cell->concepts, "CELL.XBIN");
     
    159168        }
    160169        psImage *image = ((pmReadout*)readouts->data[0])->image; // The image to put into the mosaic
     170        psImage *weight = ((pmReadout*)readouts->data[0])->weight;
     171        psImage *mask = ((pmReadout*)readouts->data[0])->weight;
    161172        images->data[i] = psImageSubset(image, *trimsec); // Trimmed image
    162     }
    163 
     173        weights->data[i] = weight ? psImageSubset(weight, *trimsec) : NULL;
     174        masks->data[i] = mask ? psImageSubset(mask, *trimsec) : NULL;
     175    }
    164176    // Mosaic the images together and we're done
    165     psImage *mosaic = p_pmImageMosaic(images, xFlip, yFlip, xBin, yBin, xBinChip, yBinChip, x0, y0);
     177    psImage *image = p_pmImageMosaic(images, xFlip, yFlip, xBin, yBin, xBinChip, yBinChip, x0, y0);
     178    psImage *weight = p_pmImageMosaic(weights, xFlip, yFlip, xBin, yBin, xBinChip, yBinChip, x0, y0);
     179    psImage *mask = p_pmImageMosaic(masks, xFlip, yFlip, xBin, yBin, xBinChip, yBinChip, x0, y0);
    166180
    167181    // Clean up
     
    173187    psFree(yFlip);
    174188    psFree(images);
    175 
    176     return mosaic;
     189    psFree(weights);
     190    psFree(masks);
     191
     192    // Chop off all the component cells, and put in a new one
     193
     194    #if 1
     195    // XXX For the sake of getting something working, I am not going to bother with sorting out where
     196    // the double free is coming from.  I'm going to drop the pointers on the array and create a memory
     197    // leak.  We can clean this up later, when we're not under as much pressure.
     198    chip->cells = psArrayAlloc(0);
     199    #else
     200
     201    psArrayElementsFree(chip->cells);
     202    chip->cells = psArrayRealloc(chip->cells, 0);
     203    chip->cells->n = 0;
     204    #endif
     205
     206    pmCell *cell = pmCellAlloc(chip, NULL, __func__); // New cell
     207    cell->exists = true;
     208    cell->process = true;
     209    pmReadout *readout = pmReadoutAlloc(cell); // New readout
     210    readout->image = image;
     211    readout->weight = weight;
     212    readout->mask = mask;
     213    //psFree(readout);
     214
     215    return true;
    177216}
    178217
     
    193232
    194233        numChips++;
    195         psImage *mosaic = mosaicChip(chip, xBinChip, yBinChip); // Mosaic of cells within the chip
    196 
    197         // Chop off all the component cells, and put in a new one
    198         psArrayElementsFree(chip->cells);
    199         chip->cells = psArrayRealloc(chip->cells, 1);
    200         pmCell *cell = pmCellAlloc(chip, NULL, __func__); // New cell
    201         pmReadout *readout = pmReadoutAlloc(cell); // New readout
    202         readout->image = mosaic;
    203         psFree(readout);
     234        mosaicChip(chip, xBinChip, yBinChip); // Mosaic of cells within the chip
     235
    204236    }
    205237
Note: See TracChangeset for help on using the changeset viewer.