Changeset 9616 for trunk/psModules/src/detrend/pmMaskBadPixels.c
- Timestamp:
- Oct 17, 2006, 12:17:38 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmMaskBadPixels.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmMaskBadPixels.c
r7479 r9616 1 /** @file pmMaskBadPixels.c2 *3 * @brief Given an input image, a bad pixel mask, a corresponding value in the bad pixel mask to mask, a4 * saturation level, and a growing radius, mask in the input image those pixels in the bad pixel mask that5 * 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 type10 11 * If maskVal is non-zero, all pixels in the mask have any of the same bits sets as maskVal12 * shall have the corresponding bits raised.13 14 * If maskVal is zero, any zero pixels in the mask be OR-ed with PM_MASK_BAD15 16 * Note that the input image and the mask need not be the same size, since the input image may17 * already have been trimmed (following overscan subtraction). The function assumes the pixels18 * originate from the same detector and uses the values of col0,row0 in both the input and the19 * 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 to22 * pixels outside the range of the mask image), the function shall generate an error.23 24 * @author Ross Harman, MHPCC25 * @author Eugene Magnier, IfA26 *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 Hawaii31 */32 33 1 #if HAVE_CONFIG_H 34 2 #include <config.h> … … 36 4 37 5 #include <stdio.h> 38 #include <math.h> 39 #include <strings.h> 6 #include <pslib.h> 40 7 41 8 #include "pmFPAMaskWeight.h" 42 9 #include "pmMaskBadPixels.h" 43 #include "pmMaskBadPixelsErrors.h"44 10 45 // apply an externally-supplied mask image to the current science image 46 // this function 47 bool pmMaskBadPixels(pmReadout *input, pmReadout *mask, psMaskType maskVal) 11 bool pmMaskBadPixels(pmReadout *input, const pmReadout *mask, psMaskType maskVal) 48 12 { 49 50 int xI;51 int xJ;52 53 13 PS_ASSERT_PTR_NON_NULL(input, false); 54 14 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); 56 16 57 17 PS_ASSERT_PTR_NON_NULL(mask, false); 58 18 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); 60 20 61 21 psImage *inMask = input->mask; … … 65 25 int colMax = inMask->col0 + inMask->numCols; 66 26 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) { 68 29 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)", 88 31 inMask->numRows, inMask->numCols, exMask->numRows, exMask->numCols); 89 32 return false; … … 103 46 // set raised pixels in exMask which are selected by maskVal 104 47 for (int j = 0; j < inMask->numRows; j++) { 105 xJ = j - offRow;48 int xJ = j - offRow; 106 49 for (int i = 0; i < inMask->numCols; i++) { 107 xI = i - offCol;50 int xI = i - offCol; 108 51 inVal[j][i] |= (maskVal & exVal[xJ][xI]); 109 52 } … … 112 55 // set raised pixels in exMask which are selected by maskVal 113 56 for (int j = 0; j < inMask->numRows; j++) { 114 xJ = j - offRow;57 int xJ = j - offRow; 115 58 for (int i = 0; i < inMask->numCols; i++) { 116 xI = i - offCol;59 int xI = i - offCol; 117 60 if (exVal[xJ][xI] == 0) { 118 61 inVal[j][i] |= PM_MASK_BAD;
Note:
See TracChangeset
for help on using the changeset viewer.
