IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28300


Ignore:
Timestamp:
Jun 10, 2010, 2:45:18 PM (16 years ago)
Author:
Paul Price
Message:

Working!

Location:
trunk/ppBackground/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppBackground/src/ppBackground.h

    r28296 r28300  
    3939/// Restore the background to an image
    4040bool ppBackgroundRestore(
    41     pmChip *out,                        // Output chip
    42     const pmChip *chip,                 // Input chip
     41    pmChip *chip,                       // Chip to correct
    4342    const pmChip *background,           // Chip with background model
    4443    const pmChip *pattern,              // Chip with pattern
  • trunk/ppBackground/src/ppBackgroundLoop.c

    r28296 r28300  
    8686                    readout->image = psImageAlloc(numCols, numRows, PS_TYPE_F32);
    8787                    psImageInit(readout->image, 0.0);
     88                    readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
     89                    psImageInit(readout->mask, 0);
    8890
    8991                    if (!pmPatternRowApply(readout, maskBad) || !pmPatternCellApply(readout, maskBad)) {
     
    116118            }
    117119
    118             pmChip *mosaic = pmFPAviewThisChip(view, patternMosaic); // Chip for mosaicked pattern
    119             if (!mosaic->hdu && !mosaic->parent->hdu) {
    120                 pmFPAAddSourceFromView(patternMosaic, view, file->format);
     120            if (data->patternName) {
     121                pmChip *patternChip = pmFPAviewThisChip(view, patternFile->fpa); // Chip for pattern
     122                pmChip *mosaic = pmFPAviewThisChip(view, patternMosaic); // Chip for mosaicked pattern
     123                if (!mosaic->hdu && !mosaic->parent->hdu) {
     124                    pmFPAAddSourceFromView(patternMosaic, view, file->format);
     125                }
     126                if (!pmChipMosaic(mosaic, patternChip, true, maskBad)) {
     127                    psError(psErrorCodeLast(), false, "Unable to mosaic pattern correction");
     128                    return false;
     129                }
     130                pmFPAfileActivate(config->files, true, NULL);
     131            //            pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");
    121132            }
    122             if (!pmChipMosaic(mosaic, chip, true, maskBad)) {
    123                 psError(psErrorCodeLast(), false, "Unable to mosaic pattern correction");
    124                 return false;
    125             }
    126             pmFPAfileActivate(config->files, true, NULL);
    127             //            pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");
    128133        }
    129134
    130         pmChip *outChip = pmFPAfileThisChip(config->files, view, "PPBACKGROUND.OUTPUT"); // Chip for output
    131135        pmChip *patternChip = patternFile ? pmFPAviewThisChip(view, patternMosaic) : NULL; // Chip with pattern
    132136        pmChip *bgChip = bgFile ? pmFPAviewThisChip(view, bgFile->fpa) : NULL; // Chip with background model
    133         if (!ppBackgroundRestore(outChip, chip, bgChip, patternChip, view, config)) {
     137        if (!ppBackgroundRestore(chip, bgChip, patternChip, view, config)) {
    134138            psError(psErrorCodeLast(), false, "Unable to replace background");
    135139            return false;
  • trunk/ppBackground/src/ppBackgroundRestore.c

    r28296 r28300  
    66#include "ppBackground.h"
    77
    8 bool ppBackgroundRestore(pmChip *out, const pmChip *chip, const pmChip *background, const pmChip *pattern,
     8bool ppBackgroundRestore(pmChip *chip, const pmChip *background, const pmChip *pattern,
    99                         const pmFPAview *oldView, pmConfig *config)
    1010{
    11     PS_ASSERT_PTR_NON_NULL(out, false);
    1211    PS_ASSERT_PTR_NON_NULL(chip, false);
    1312    PS_ASSERT_PTR_NON_NULL(oldView, false);
     
    1817    view->readout = 0;
    1918
    20     pmReadout *inRO = pmFPAviewThisReadout(view, chip->parent);
    21     if (!inRO || !inRO->data_exists) {
     19    pmReadout *ro = pmFPAviewThisReadout(view, chip->parent);
     20    if (!ro || !ro->data_exists) {
    2221        psError(PPBACKGROUND_ERR_CONFIG, true, "Readout has no data");
    2322        return false;
    2423    }
    25     const psImage *inImage = inRO->image, *inMask = inRO->mask;   // Input image
    26     int numCols = inImage->numCols, numRows = inImage->numRows; // Size of image
    27 
    28     pmReadout *outRO = pmFPAviewThisReadout(view, out->parent);
    29     if (!outRO) {
    30         pmCell *outCell = pmFPAviewThisCell(view, out->parent);
    31         outRO = pmReadoutAlloc(outCell);
    32         psFree(outRO);                  // Drop reference
    33     }
    34     outRO->image = psImageCopy(outRO->image, inImage, PS_TYPE_F32);
    35     outRO->mask = psImageCopy(outRO->mask, inMask, PS_TYPE_IMAGE_MASK);
    36     psImage *outImage = outRO->image, *outMask = outRO->mask; // Output image
     24    const psImage *image = ro->image, *mask = ro->mask;   // Input image
     25    int numCols = image->numCols, numRows = image->numRows; // Size of image
    3726
    3827    if (background) {
    3928        pmReadout *bgRO = pmFPAviewThisReadout(view, background->parent); // Readout with background
    40         psImageBinning *binning = psphotBackgroundBinning(outImage, config);
     29        psImageBinning *binning = psphotBackgroundBinning(image, config);
    4130        if (!binning) {
    4231            psError(psErrorCodeLast(), false, "Unable to find background binning");
     
    6049        for (int y = 0; y < numRows; y++) {
    6150            for (int x = 0; x < numCols; x++) {
    62                 outImage->data.F32[y][x] += bgImage->data.F32[y][x];
     51                image->data.F32[y][x] += bgImage->data.F32[y][x];
    6352            }
    6453        }
     
    7261        for (int y = 0; y < numRows; y++) {
    7362            for (int x = 0; x < numCols; x++) {
    74                 outImage->data.F32[y][x] = patternImage->data.F32[y][x];
    75                 outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= patternMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x];
     63                image->data.F32[y][x] -= patternImage->data.F32[y][x];
     64                mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= patternMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x];
    7665            }
    7766        }
    7867    }
    7968
    80     outRO->data_exists = true;
    81     outRO->parent->data_exists = true;
    82     outRO->parent->parent->data_exists = true;
     69    ro->data_exists = true;
     70    ro->parent->data_exists = true;
     71    ro->parent->parent->data_exists = true;
    8372
    8473    return true;
Note: See TracChangeset for help on using the changeset viewer.