IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18724


Ignore:
Timestamp:
Jul 24, 2008, 3:58:31 PM (18 years ago)
Author:
eugene
Message:

set masked pixels in binned images to maskedValue if requested (needs modified version of API)

Location:
trunk/ppImage/src
Files:
3 edited

Legend:

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

    r18556 r18724  
    123123pmReadout* ppImageDetrendSelectFirst(pmCell *cell, char *name, bool doThis);
    124124
    125 bool ppImageRebinChip (pmConfig *config, pmFPAview *view, char *outName);
    126 bool ppImageRebinReadout (pmReadout *output, pmReadout *input, pmFPAfile *outFile);
     125bool ppImageRebinChip (pmConfig *config, pmFPAview *view, ppImageOptions *options, char *outName);
     126bool ppImageRebinReadout (pmReadout *output, pmReadout *input, pmFPAfile *outFile, ppImageOptions *options);
    127127
    128128bool ppImagePhotom (pmConfig *config, pmFPAview *view);
  • trunk/ppImage/src/ppImageLoop.c

    r18556 r18724  
    8787            ESCAPE ("Unable to mosaic chip");
    8888
    89         if (!ppImageRebinChip(config, view, "PPIMAGE.BIN1"))
    90             ESCAPE ("Unable to bin chip (level 1).");
    91 
    92         if (!ppImageRebinChip(config, view, "PPIMAGE.BIN2"))
    93             ESCAPE ("Unable to bin chip (level 2).");
    94 
    9589        // we perform photometry on the readouts of this chip in the output
    9690        if (options->doPhotom) {
     
    10397                ESCAPE ("Unable to replace masked pixels with background level");
    10498        }
     99
     100        // binning (used for display) must take place after the background is replaced, if desired
     101        if (!ppImageRebinChip(config, view, options, "PPIMAGE.BIN1"))
     102            ESCAPE ("Unable to bin chip (level 1).");
     103
     104        if (!ppImageRebinChip(config, view, options, "PPIMAGE.BIN2"))
     105            ESCAPE ("Unable to bin chip (level 2).");
    105106
    106107        // Close cells (XXX shouldn't pmFPAfileClose iterate down as needed?)
  • trunk/ppImage/src/ppImageRebinReadout.c

    r18216 r18724  
    55#include "ppImage.h"
    66
    7 bool ppImageRebinChip (pmConfig *config, pmFPAview *view, char *outName) {
     7bool ppImageRebinChip (pmConfig *config, pmFPAview *view, ppImageOptions *options, char *outName) {
    88
    99    pmCell *cell;
     
    3333
    3434            // run the rebin code
    35             ppImageRebinReadout (outReadout, inReadout, outFile);
     35            ppImageRebinReadout (outReadout, inReadout, outFile, options);
    3636        }
    3737
     
    6161
    6262// XXX this should be made consistent with psImageBinning
    63 bool ppImageRebinReadout (pmReadout *output, pmReadout *input, pmFPAfile *outFile)
     63bool ppImageRebinReadout (pmReadout *output, pmReadout *input, pmFPAfile *outFile, ppImageOptions *options)
    6464{
    6565    PS_ASSERT_PTR_NON_NULL(output, false);
     
    8080    int nY = input->image->numRows;
    8181
     82    // we should *either* skip masked pixels or replace masked pixels with the specified value
     83   
     84
    8285    // do the rebinning by hand, mean only for test
    8386    for (int yOut = 0; yOut < output->image->numRows; yOut++) {
    8487        for (int xOut = 0; xOut < output->image->numCols; xOut++) {
     88            float maskedValue = 0.0;
    8589            float value = 0;
    8690            int nPix = 0;
    8791            for (int yIn = yOut * dY; (yIn < yOut * dY + dY) && (yIn < nY); yIn ++) {
    8892                for (int xIn = xOut * dX; (xIn < xOut * dX + dX) && (xIn < nX); xIn ++) {
    89                     if (input->mask && input->mask->data.U8[yIn][xIn]) continue;
     93                    if (input->mask && input->mask->data.U8[yIn][xIn]) {
     94                      maskedValue = input->image->data.F32[yIn][xIn];
     95                      continue;
     96                    }
    9097                    value += input->image->data.F32[yIn][xIn];
    9198                    nPix ++;
    9299                }
    93100            }
    94             output->image->data.F32[yOut][xOut] = value / nPix;
     101            if (nPix > 0) {
     102              output->image->data.F32[yOut][xOut] = value / nPix;
     103            } else {
     104              if (options->replaceMasked) {
     105                output->image->data.F32[yOut][xOut] = maskedValue;
     106              } else {
     107                output->image->data.F32[yOut][xOut] = 0.0;
     108              }
     109            }
    95110        }
    96111    }
Note: See TracChangeset for help on using the changeset viewer.