IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 17, 2006, 12:17:38 PM (20 years ago)
Author:
Paul Price
Message:

Documenting and cleaning up pmMaskBadPixels; removing old error files --- unneccesary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmMaskBadPixels.c

    r7479 r9616  
    1 /** @file  pmMaskBadPixels.c
    2  *
    3  *  @brief Given an input image, a bad pixel mask, a corresponding value in the bad pixel mask to mask, a
    4  *  saturation level, and a growing radius, mask in the input image those pixels in the bad pixel mask that
    5  *  match the value to mask.
    6  *
    7  *  Apply the supplied bad pixel mask readout (mask) to the given science readout (input).
    8  *  The science readout must already have a supplied mask element (use eg. pmReadoutSetMask)
    9  *  The supplied mask image must be of MASK type
    10  
    11  *  If maskVal is non-zero, all pixels in the mask have any of the same bits sets as maskVal
    12  *  shall have the corresponding bits raised.
    13  
    14  *  If maskVal is zero, any zero pixels in the mask be OR-ed with PM_MASK_BAD
    15  
    16  * Note that the input image and the mask need not be the same size, since the input image may
    17  * already have been trimmed (following overscan subtraction).  The function assumes the pixels
    18  * originate from the same detector and uses the values of col0,row0 in both the input and the
    19  * mask to match corresponding pixels.
    20  
    21  * In the event that the mask image is too small (i.e., pixels on the input image refer to
    22  * pixels outside the range of the mask image), the function shall generate an error.
    23  
    24  *  @author Ross Harman, MHPCC
    25  *  @author Eugene Magnier, IfA
    26  *
    27  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    28  *  @date $Date: 2006-06-10 02:59:23 $
    29  *
    30  *  Copyright 2004 IfA, University of Hawaii
    31  */
    32 
    331#if HAVE_CONFIG_H
    342#include <config.h>
     
    364
    375#include <stdio.h>
    38 #include <math.h>
    39 #include <strings.h>
     6#include <pslib.h>
    407
    418#include "pmFPAMaskWeight.h"
    429#include "pmMaskBadPixels.h"
    43 #include "pmMaskBadPixelsErrors.h"
    4410
    45 // apply an externally-supplied mask image to the current science image
    46 // this function
    47 bool pmMaskBadPixels(pmReadout *input, pmReadout *mask, psMaskType maskVal)
     11bool pmMaskBadPixels(pmReadout *input, const pmReadout *mask, psMaskType maskVal)
    4812{
    49 
    50     int xI;
    51     int xJ;
    52 
    5313    PS_ASSERT_PTR_NON_NULL(input, false);
    5414    PS_ASSERT_PTR_NON_NULL(input->mask, false);
    55     PS_ASSERT_IMAGE_TYPE(input->mask, PS_TYPE_MASK, NULL);
     15    PS_ASSERT_IMAGE_TYPE(input->mask, PS_TYPE_MASK, false);
    5616
    5717    PS_ASSERT_PTR_NON_NULL(mask, false);
    5818    PS_ASSERT_PTR_NON_NULL(mask->mask, false);
    59     PS_ASSERT_IMAGE_TYPE(mask->mask, PS_TYPE_MASK, NULL);
     19    PS_ASSERT_IMAGE_TYPE(mask->mask, PS_TYPE_MASK, false);
    6020
    6121    psImage *inMask = input->mask;
     
    6525    int colMax = inMask->col0 + inMask->numCols;
    6626
    67     if (exMask->row0 > inMask->row0) {
     27    if (exMask->row0 > inMask->row0 || exMask->col0 > inMask->col0 ||
     28            exMask->row0 + exMask->numRows < rowMax || exMask->col0 + exMask->numCols < colMax) {
    6829        psError( PS_ERR_BAD_PARAMETER_SIZE, true,
    69                  PS_ERRORTEXT_pmMaskBadPixels_SIZE_INPUT_IMAGE,
    70                  inMask->numRows, inMask->numCols, exMask->numRows, exMask->numCols);
    71         return false;
    72     }
    73     if (exMask->col0 > inMask->col0) {
    74         psError( PS_ERR_BAD_PARAMETER_SIZE, true,
    75                  PS_ERRORTEXT_pmMaskBadPixels_SIZE_INPUT_IMAGE,
    76                  inMask->numRows, inMask->numCols, exMask->numRows, exMask->numCols);
    77         return false;
    78     }
    79     if (exMask->row0 + exMask->numRows < rowMax) {
    80         psError( PS_ERR_BAD_PARAMETER_SIZE, true,
    81                  PS_ERRORTEXT_pmMaskBadPixels_SIZE_INPUT_IMAGE,
    82                  inMask->numRows, inMask->numCols, exMask->numRows, exMask->numCols);
    83         return false;
    84     }
    85     if (exMask->col0 + exMask->numCols < colMax) {
    86         psError( PS_ERR_BAD_PARAMETER_SIZE, true,
    87                  PS_ERRORTEXT_pmMaskBadPixels_SIZE_INPUT_IMAGE,
     30                 "Input image size exceeds that of mask image: (%d, %d) vs (%d, %d)",
    8831                 inMask->numRows, inMask->numCols, exMask->numRows, exMask->numCols);
    8932        return false;
     
    10346        // set raised pixels in exMask which are selected by maskVal
    10447        for (int j = 0; j < inMask->numRows; j++) {
    105             xJ = j - offRow;
     48            int xJ = j - offRow;
    10649            for (int i = 0; i < inMask->numCols; i++) {
    107                 xI = i - offCol;
     50                int xI = i - offCol;
    10851                inVal[j][i] |= (maskVal & exVal[xJ][xI]);
    10952            }
     
    11255        // set raised pixels in exMask which are selected by maskVal
    11356        for (int j = 0; j < inMask->numRows; j++) {
    114             xJ = j - offRow;
     57            int xJ = j - offRow;
    11558            for (int i = 0; i < inMask->numCols; i++) {
    116                 xI = i - offCol;
     59                int xI = i - offCol;
    11760                if (exVal[xJ][xI] == 0) {
    11861                    inVal[j][i] |= PM_MASK_BAD;
Note: See TracChangeset for help on using the changeset viewer.