IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 8, 2023, 11:54:08 AM (3 years ago)
Author:
eugene
Message:

merge from eam_branches/ipp-20220316. no_warn strncpy; avoid passing NULL to sprintf %s; add code for PATTERN_DEAD_CELLS; fix error in PSF residual image evaluation; drop detailed mask analysis for binned images (not actually used)

Location:
trunk/psModules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules

  • trunk/psModules/src/camera/pmFPABin.c

    r34843 r42379  
    3131    psImage *outImage;                  // Output image
    3232    if (out->image && out->image->numCols >= numColsOut && out->image->numRows >= numRowsOut) {
    33         outImage = out->image;
     33        outImage = out->image;
    3434    } else {
    35         outImage = out->image = psImageRecycle(out->image,  numColsOut, numRowsOut, PS_TYPE_F32);
     35        outImage = out->image = psImageRecycle(out->image,  numColsOut, numRowsOut, PS_TYPE_F32);
    3636    }
    3737
    3838    psImage *outMask;                   // Output mask
    3939    if (out->mask && out->mask->numCols >= numColsOut && out->mask->numRows >= numRowsOut) {
    40         outMask = out->mask;
     40        outMask = out->mask;
    4141    } else {
    42         outMask = out->mask = psImageRecycle(out->mask,  numColsOut, numRowsOut, PS_TYPE_IMAGE_MASK);
     42        outMask = out->mask = psImageRecycle(out->mask,  numColsOut, numRowsOut, PS_TYPE_IMAGE_MASK);
    4343    }
    4444
     
    5050    int yStart = psImageBinningGetFineY(binning, 0); // Starting input y for binning
    5151    for (int yOut = 0; yOut < numRowsOut; yOut++) {
    52         int yStop = psImageBinningGetFineY(binning, yOut + 1); // Stopping input y for binning
    53         yStop = PS_MIN(yStop, yLast);
    54         int xStart = psImageBinningGetFineX(binning, 0); // Starting input x for binning
    55         for (int xOut = 0; xOut < numColsOut; xOut++) {
    56             int xStop = psImageBinningGetFineX(binning, xOut + 1); // Stopping input x for binning
    57             xStop = PS_MIN(xStop, xLast);
     52        int yStop = psImageBinningGetFineY(binning, yOut + 1); // Stopping input y for binning
     53        yStop = PS_MIN(yStop, yLast);
     54        int xStart = psImageBinningGetFineX(binning, 0); // Starting input x for binning
     55        for (int xOut = 0; xOut < numColsOut; xOut++) {
     56            int xStop = psImageBinningGetFineX(binning, xOut + 1); // Stopping input x for binning
     57            xStop = PS_MIN(xStop, xLast);
    5858
    59             float sum = 0.0;            // Sum of pixels
    60             int numPix = 0;             // Number of pixels
     59            float sum = 0.0;            // Sum of pixels
     60            int numPix = 0;             // Number of pixels
    6161
    6262            for (int j = 0; j < Nbits; j++) { // Reset bit counter
    63               bitcounter[j] = 0;
     63                bitcounter[j] = 0;
    6464            }
    6565            pxlcount = 0;
    6666           
    67             for (int y = yStart; y < yStop; y++) {
    68                 for (int x = xStart; x < xStop; x++) {
    69                   if (inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] != 0)) {
    70                       for (int j = 0; j < Nbits; j++) {
    71                         psImageMaskType M = (psImageMaskType) pow(2,j);
    72                         if (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & M) {
    73                           bitcounter[j]++;
     67            for (int y = yStart; y < yStop; y++) {
     68                for (int x = xStart; x < xStop; x++) {
     69                    if (false && inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] != 0)) {
     70                        for (int j = 0; j < Nbits; j++) {
     71                            psImageMaskType M = (psImageMaskType) pow(2,j);
     72                            if (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & M) {
     73                                bitcounter[j]++;
     74                            }
    7475                        }
    75                       }
    7676                    }
    7777                 
    78                     if (inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) {
    79                         continue;
    80                     }
    81                     if (!isfinite(inImage->data.F32[y][x])) {
    82                         continue;
    83                     }
    84                     sum += inImage->data.F32[y][x];
    85                     numPix++;
     78                    if (inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) {
     79                        continue;
     80                    }
     81                    if (!isfinite(inImage->data.F32[y][x])) {
     82                        continue;
     83                    }
     84                    sum += inImage->data.F32[y][x];
     85                    numPix++;
    8686
    8787
    88                 }
    89             }
    90            
     88                }
     89            }
    9190           
    9291            // Values to set
    93             float imageValue;
     92            float imageValue;
    9493            psImageMaskType maskValue;
    95             if (numPix > 0) {
    96                 imageValue = sum / numPix;
    97                 maskValue = 0;
    98             } else {
    99                 imageValue = NAN;
    100                 maskValue = maskVal;
    101             }
    102             outImage->data.F32[yOut][xOut] = imageValue;
    103             if (0) {
    104               outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = maskValue;
     94            if (numPix > 0) {
     95                imageValue = sum / numPix;
     96                maskValue = 0;
    10597            } else {
    106               outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = 0;
     98                imageValue = NAN;
     99                maskValue = maskVal;
    107100            }
    108             for (int j = 0; j < Nbits; j++) {
    109               if (bitcounter[j] > 0.5 * pxlcount) {
    110                 outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] |= (int) pow(2,j);
    111               }
     101            outImage->data.F32[yOut][xOut] = imageValue;
     102            if (true) {
     103                outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = maskValue;
     104            } else {
     105                outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = 0;
    112106            }
    113             xStart = xStop;
    114         }
    115         yStart = yStop;
     107            // this loop is pointless if pxlcount == 0 (all masked)
     108            if (false) {
     109                if (pxlcount) {
     110                    for (int j = 0; j < Nbits; j++) {
     111                        if (bitcounter[j] > 0.5 * pxlcount) {
     112                            outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] |= (1 << j);
     113                        }
     114                    }
     115                } else {
     116                    outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = maskValue;
     117                }
     118            }
     119            xStart = xStop;
     120        }
     121        yStart = yStop;
    116122    }
    117123
     
    120126    out->data_exists = true;
    121127    if (out->parent) {
    122         pmCell *outCell = out->parent;  // Output cell
    123         outCell->data_exists = outCell->parent->data_exists = true;
     128        pmCell *outCell = out->parent;  // Output cell
     129        outCell->data_exists = outCell->parent->data_exists = true;
    124130
    125         // We would copy the concepts from the input cell, except that is done by pmFPACopy,
    126         // pmChipCopyStructure, etc.  This function just does the mechanics of binning.
    127         // We don't even update the CELL.XBIN, CELL.YBIN because that would apply the correction twice.
     131        // We would copy the concepts from the input cell, except that is done by pmFPACopy,
     132        // pmChipCopyStructure, etc.  This function just does the mechanics of binning.
     133        // We don't even update the CELL.XBIN, CELL.YBIN because that would apply the correction twice.
    128134    }
    129135
Note: See TracChangeset for help on using the changeset viewer.