IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 19, 2006, 11:47:06 PM (21 years ago)
Author:
Paul Price
Message:

Readouts now contain a subimage

File:
1 edited

Legend:

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

    r6062 r6080  
    3737    int yMin = INT_MAX;
    3838    int yMax = - INT_MAX;
     39    psElemType type = 0;
    3940    for (int i = 0; i < source->n; i++) {
    4041        psImage *image = source->data[i]; // The image of interest
     
    4344        }
    4445
    45         assert(image->type.type == PS_TYPE_F32); // Only implemented for F32 images so far.
     46        // Only implemented for F32 and U8 images so far.
     47        assert(image->type.type == PS_TYPE_F32 || image->type.type == PS_TYPE_U8);
     48        // All input types must be the same
     49        if (type == 0) {
     50            type = image->type.type;
     51        }
     52        assert(type == image->type.type);
    4653
    4754        // Size of cell in x and y
     
    7178
    7279    psTrace(__func__, 3, "Spliced image will be %dx%d\n", (int)xSize, (int)ySize);
    73     psImage *mosaic = psImageAlloc((int)xSize, (int)ySize, PS_TYPE_F32); // The mosaic image
     80    psImage *mosaic = psImageAlloc((int)xSize, (int)ySize, type); // The mosaic image
    7481    psImageInit(mosaic, 0.0);
    7582
     
    96103                    // In case the original image is binned but the mosaic is not, we need to fill in the
    97104                    // values in the mosaic.
    98                     for (int j = 0; j < yBinSource->data.S32[i]; j++) {
    99                         int yTarget = (int)(yTargetBase + yParity * (float)j / (float)yBinTarget);
    100                         for (int i = 0; i < xBinSource->data.S32[i]; i++) {
    101                             int xTarget = (int)(xTargetBase + xParity * (float)i / (float)xBinTarget);
    102 
    103                             mosaic->data.F32[yTarget][xTarget] += image->data.F32[y][x];
    104                         }
    105                     } // Iterating over mosaic image for binned input image
     105                    #define FILL_IN(TYPE)                                                                    \
     106                    for (int j = 0; j < yBinSource->data.S32[i]; j++) {                                      \
     107                        int yTarget = (int)(yTargetBase + yParity * (float)j / (float)yBinTarget);           \
     108                        for (int i = 0; i < xBinSource->data.S32[i]; i++) {                                  \
     109                            int xTarget = (int)(xTargetBase + xParity * (float)i / (float)xBinTarget);       \
     110                            mosaic->data.TYPE[yTarget][xTarget] += image->data.TYPE[y][x];                   \
     111                        }                                                                                    \
     112                    }
     113
     114                    switch (type) {
     115                    case PS_TYPE_F32:
     116                        FILL_IN(F32);
     117                        break;
     118                    case PS_TYPE_U8:
     119                        FILL_IN(U8);
     120                        break;
     121                    default:
     122                        psAbort(__func__, "Should never get here.\n");
     123                    }
     124
    106125                }
    107126            } // Iterating over input image
     
    158177        }
    159178
    160         // Trim the image to get rid of the overscan
    161         psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
    162         psTrace(__func__, 7, "Cell %d trimsec: [%.0f:%.0f,%.0f:%.0f]\n", i, trimsec->x0, trimsec->x1,
    163                 trimsec->y0, trimsec->y1);
    164179        psArray *readouts = cell->readouts; // The array of readouts
    165180        if (readouts->n > 1) {
     
    167182                     "be mosaicked.\n", i);
    168183        }
    169         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;
    172         images->data[i] = psImageSubset(image, *trimsec); // Trimmed image
    173         weights->data[i] = weight ? psImageSubset(weight, *trimsec) : NULL;
    174         masks->data[i] = mask ? psImageSubset(mask, *trimsec) : NULL;
     184        pmReadout *readout = readouts->data[0]; // The only readout we'll bother with
     185
     186        // The images to put into the mosaic
     187        images->data[i]  = readout->image;
     188        weights->data[i] = readout->weight;
     189        masks->data[i]   = readout->mask;
    175190    }
    176191    // Mosaic the images together and we're done
Note: See TracChangeset for help on using the changeset viewer.