IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 19, 2007, 4:22:26 PM (19 years ago)
Author:
Paul Price
Message:

Extensive changes to APIs to allow use of a nominated value to mask
against (the maskVal). Previously, the mask values were either
hard-coded (e.g., PM_MASK_SAT) or taken as anything non-zero. The
code is tested under psphot (which has similar changes) and does not
crash, but neither is it successful in marking all bad pixels (EAM
will investigate). For this reason, I have left the "gutter" pixels
(cell gaps) set to 0 instead of NAN in pmFPAMosaic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAMosaic.c

    r13499 r13898  
    2222
    2323#define CELL_LIST_BUFFER 10             // Buffer size for cell lists
     24
     25#define BLANK_VALUE 0.0                 // Value for pixels that are blank in the mosaicked image (e.g., //
     26                                        // between cells).
     27                                        // XXX This should ultimately be set to NAN, but psphot doesn't like
     28                                        // that (masking needs to be more thorough).
    2429
    2530//////////////////////////////////////////////////////////////////////////////////////////////////////////////
     
    397402                    for (int x = 0; x < image->numCols; x++) { \
    398403                        int xTarget = xTargetBase + xParity * x; \
    399                         mosaic->data.TYPE[yTarget][xTarget] += image->data.TYPE[y][x]; \
     404                        mosaic->data.TYPE[yTarget][xTarget] = image->data.TYPE[y][x]; \
    400405                    } \
    401406                } \
     
    416421                        for (int k = 0; k < xBinSource->data.S32[i]; k++) { \
    417422                            int xTarget = (int)(xTargetBinBase + xParity * (float)k / (float)xBinTarget); \
    418                             mosaic->data.TYPE[yTarget][xTarget] += image->data.TYPE[y][x]; \
     423                            mosaic->data.TYPE[yTarget][xTarget] = image->data.TYPE[y][x]; \
    419424                        } \
    420425                    } \
     
    504509    psTrace("psModules.camera", 3, "Spliced image will be %dx%d\n", (int)xSize, (int)ySize);
    505510    psImage *mosaic = psImageAlloc((int)xSize, (int)ySize, type); // The mosaic image
    506     psImageInit(mosaic, 0);
     511    psImageInit(mosaic, unexposed);
    507512
    508513    // Next pass through the images to do the mosaicking
     
    524529            (yFlip->data.U8[i] == 0)) {
    525530            // Let someone else do the hard work
    526             psImageOverlaySection(mosaic, image, xTargetBase, yTargetBase, "+");
     531            psImageOverlaySection(mosaic, image, xTargetBase, yTargetBase, "=");
    527532            continue;
    528533        }
     
    723728                       int *xBinChip, int *yBinChip, // The binning in x and y, to be returned
    724729                       const pmChip *chip, // Chip to mosaic
    725                        const pmCell *targetCell // Cell to which to mosaic
     730                       const pmCell *targetCell, // Cell to which to mosaic
     731                       psMaskType blank // Mask value to give blank pixels
    726732                      )
    727733{
     
    804810    // Mosaic the images together and we're done
    805811    if (allGood) {
    806         *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, NAN);
    807         *mosaicWeights = imageMosaic(weights, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, NAN);
    808         *mosaicMask = imageMosaic(masks, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, 0xff);
     812        *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, BLANK_VALUE);
     813        *mosaicWeights = imageMosaic(weights, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, BLANK_VALUE);
     814        *mosaicMask = imageMosaic(masks, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, blank);
    809815    }
    810816
     
    830836                      const pmFPA *fpa,  // FPA to mosaic
    831837                      const pmChip *targetChip, // Chip to which to mosaic
    832                       const pmCell *targetCell // Cell to which to mosaic
     838                      const pmCell *targetCell, // Cell to which to mosaic
     839                      psMaskType blank  // Mask value to give blank pixels
    833840                     )
    834841{
     
    937944    // Mosaic the images together and we're done
    938945    if (allGood) {
    939         *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, NAN);
    940         *mosaicWeights = imageMosaic(weights, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, NAN);
    941         *mosaicMask = imageMosaic(masks, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, 0xff);
     946        *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, BLANK_VALUE);
     947        *mosaicWeights = imageMosaic(weights, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, BLANK_VALUE);
     948        *mosaicMask = imageMosaic(masks, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, blank);
    942949    }
    943950
     
    986993// the mosaic image.
    987994
    988 bool pmChipMosaic(pmChip *target, const pmChip *source, bool deepCopy)
     995bool pmChipMosaic(pmChip *target, const pmChip *source, bool deepCopy, psMaskType blank)
    989996{
    990997    // Target exists, and has only a single cell
     
    10391046        // Case 2 --- we need to mosaic by cut and paste
    10401047        psTrace("psModules.camera", 1, "Case 2 mosaicking: cut and paste.\n");
    1041         if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source, targetCell)) {
     1048        if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source, targetCell, blank)) {
    10421049            psError(PS_ERR_UNKNOWN, false, "Unable to mosaic cells.\n");
    10431050            return false;
     
    12171224
    12181225
    1219 bool pmFPAMosaic(pmFPA *target, const pmFPA *source, bool deepCopy)
     1226bool pmFPAMosaic(pmFPA *target, const pmFPA *source, bool deepCopy, psMaskType blank)
    12201227{
    12211228    // Target exists, and has only a single chip with single cell
     
    12601267        psTrace("psModules.camera", 1, "Case 2 mosaicking: cut and paste.\n");
    12611268        if (!fpaMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source,
    1262                        targetChip, targetCell)) {
     1269                       targetChip, targetCell, blank)) {
    12631270            psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chips.\n");
    12641271            return false;
Note: See TracChangeset for help on using the changeset viewer.