IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28296


Ignore:
Timestamp:
Jun 10, 2010, 1:12:33 PM (16 years ago)
Author:
Paul Price
Message:

Output isn't the same as input.

Location:
trunk/ppBackground/src
Files:
3 edited

Legend:

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

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

    r28293 r28296  
    125125            }
    126126            pmFPAfileActivate(config->files, true, NULL);
    127             pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");
     127            //            pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");
    128128        }
    129129
     130        pmChip *outChip = pmFPAfileThisChip(config->files, view, "PPBACKGROUND.OUTPUT"); // Chip for output
    130131        pmChip *patternChip = patternFile ? pmFPAviewThisChip(view, patternMosaic) : NULL; // Chip with pattern
    131132        pmChip *bgChip = bgFile ? pmFPAviewThisChip(view, bgFile->fpa) : NULL; // Chip with background model
    132         if (!ppBackgroundRestore(chip, bgChip, patternChip, view, config)) {
     133        if (!ppBackgroundRestore(outChip, chip, bgChip, patternChip, view, config)) {
    133134            psError(psErrorCodeLast(), false, "Unable to replace background");
    134135            return false;
  • trunk/ppBackground/src/ppBackgroundRestore.c

    r28293 r28296  
    66#include "ppBackground.h"
    77
    8 bool ppBackgroundRestore(pmChip *chip, const pmChip *background, const pmChip *pattern,
     8bool ppBackgroundRestore(pmChip *out, const pmChip *chip, const pmChip *background, const pmChip *pattern,
    99                         const pmFPAview *oldView, pmConfig *config)
    1010{
     11    PS_ASSERT_PTR_NON_NULL(out, false);
    1112    PS_ASSERT_PTR_NON_NULL(chip, false);
    1213    PS_ASSERT_PTR_NON_NULL(oldView, false);
     
    1718    view->readout = 0;
    1819
    19     pmReadout *ro = pmFPAviewThisReadout(view, chip->parent);
    20     if (!ro || !ro->data_exists) {
     20    pmReadout *inRO = pmFPAviewThisReadout(view, chip->parent);
     21    if (!inRO || !inRO->data_exists) {
    2122        psError(PPBACKGROUND_ERR_CONFIG, true, "Readout has no data");
    2223        return false;
    2324    }
    24     psImage *image = ro->image, *mask = ro->mask;           // Image to correct
    25     int numCols = image->numCols, numRows = image->numRows; // Size of image
     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
    2637
    2738    if (background) {
    2839        pmReadout *bgRO = pmFPAviewThisReadout(view, background->parent); // Readout with background
    29         psImageBinning *binning = psphotBackgroundBinning(image, config);
     40        psImageBinning *binning = psphotBackgroundBinning(outImage, config);
    3041        if (!binning) {
    3142            psError(psErrorCodeLast(), false, "Unable to find background binning");
     
    4960        for (int y = 0; y < numRows; y++) {
    5061            for (int x = 0; x < numCols; x++) {
    51                 image->data.F32[y][x] += bgImage->data.F32[y][x];
     62                outImage->data.F32[y][x] += bgImage->data.F32[y][x];
    5263            }
    5364        }
     
    6172        for (int y = 0; y < numRows; y++) {
    6273            for (int x = 0; x < numCols; 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];
     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];
    6576            }
    6677        }
    6778    }
    6879
    69     ro->data_exists = true;
    70     ro->parent->data_exists = true;
    71     ro->parent->parent->data_exists = true;
     80    outRO->data_exists = true;
     81    outRO->parent->data_exists = true;
     82    outRO->parent->parent->data_exists = true;
    7283
    7384    return true;
Note: See TracChangeset for help on using the changeset viewer.