Changeset 7855 for trunk/psModules/src/detrend/pmFlatField.c
- Timestamp:
- Jul 10, 2006, 10:42:47 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmFlatField.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmFlatField.c
r7604 r7855 18 18 * @author Ross Harman, MHPCC 19 19 * 20 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $21 * @date $Date: 2006-0 6-21 03:21:16$20 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 21 * @date $Date: 2006-07-10 20:42:47 $ 22 22 * 23 23 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 47 47 PS_ASSERT_IMAGE_NON_EMPTY(flat->image, false); 48 48 if (in->mask) { 49 PS_ASSERT_IMAGE_TYPE(in->mask, PS_TYPE_U8, false); 49 PS_ASSERT_IMAGE_TYPE(in->mask, PS_TYPE_MASK, false); 50 PS_ASSERT_IMAGES_SIZE_EQUAL(in->mask, in->image, false); 50 51 } 51 52 PS_ASSERT_IMAGE_TYPE(flat->image, in->image->type.type, false); 52 53 int totOffCol = 0;54 int totOffRow = 0;55 psElemType inType;56 psElemType flatType;57 psElemType maskType;58 59 // Check for nulls60 if (in == NULL) {61 return true; // Readout may not have data in it62 } else if(flat==NULL) {63 psError( PS_ERR_BAD_PARAMETER_NULL, true,64 PS_ERRORTEXT_pmFlatField_NULL_FLAT_READOUT);65 return false;66 }67 53 68 54 psImage *inImage = in->image; // Input image 69 55 psImage *inMask = in->mask; // Mask for input image 70 56 psImage *flatImage = flat->image; // Flat-field image 57 58 // Check input image and its mask are not larger than flat image 59 if (inImage->numRows > flatImage->numRows || inImage->numCols > flatImage->numCols) { 60 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 61 PS_ERRORTEXT_pmFlatField_SIZE_INPUT_IMAGE, 62 inImage->numRows, inImage->numCols, flatImage->numRows, flatImage->numCols); 63 return false; 64 } 65 if (inMask && (inMask->numRows > flatImage->numRows || inMask->numCols > flatImage->numCols)) { 66 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 67 PS_ERRORTEXT_pmFlatField_SIZE_MASK_IMAGE, 68 inMask->numRows, inMask->numCols, flatImage->numRows, flatImage->numCols); 69 return false; 70 } 71 71 72 72 // Offsets on the chip … … 76 76 int y0flat = psMetadataLookupS32(NULL, flat->parent->concepts, "CELL.Y0"); 77 77 78 if (inImage == NULL) { 79 psError( PS_ERR_BAD_PARAMETER_NULL, true, 80 PS_ERRORTEXT_pmFlatField_NULL_INPUT_IMAGE); 81 return false; 82 } else if(flatImage == NULL) { 83 psError( PS_ERR_BAD_PARAMETER_NULL, true, 84 PS_ERRORTEXT_pmFlatField_NULL_FLAT_IMAGE); 85 return false; 86 } 87 88 // Check input image and its mask are not larger than flat image 89 90 if (inImage->numRows>flatImage->numRows || inImage->numCols>flatImage->numCols) { 91 psError( PS_ERR_BAD_PARAMETER_SIZE, true, 92 PS_ERRORTEXT_pmFlatField_SIZE_INPUT_IMAGE, 93 inImage->numRows, inImage->numCols, flatImage->numRows, flatImage->numCols); 94 return false; 95 } 96 if (inMask && (inMask->numRows > flatImage->numRows || inMask->numCols > flatImage->numCols)) { 97 psError( PS_ERR_BAD_PARAMETER_SIZE, true, 98 PS_ERRORTEXT_pmFlatField_SIZE_MASK_IMAGE, 99 inMask->numRows, inMask->numCols, flatImage->numRows, flatImage->numCols); 100 return false; 101 } 102 103 // Determine total offset based on image offset with chip offset 104 totOffCol = inImage->col0 + y0in - flatImage->col0 - y0flat; 105 totOffRow = inImage->row0 + x0in - flatImage->row0 - x0flat; 78 // Determine offset based on image offset with chip offset: input frame to flat frame 79 int yOffset = in->row0 + y0in - flat->col0 - y0flat; 80 int xOffset = in->row0 + x0in - flat->col0 - x0flat; 106 81 107 82 // Check that offsets are within image limits 108 if(totOffRow>=flatImage->numRows || totOffCol>=flatImage->numCols) { 109 psError( PS_ERR_BAD_PARAMETER_SIZE, true, 110 PS_ERRORTEXT_pmFlatField_OFFSET_FLAT_IMAGE, 111 totOffRow, totOffCol, flatImage->numRows, flatImage->numCols); 112 return false; 113 } else if(totOffRow>=inImage->numRows || totOffCol>=inImage->numCols) { 114 psError( PS_ERR_BAD_PARAMETER_SIZE, true, 115 PS_ERRORTEXT_pmFlatField_OFFSET_INPUT_IMAGE, 116 totOffRow, totOffCol, inImage->numRows, inImage->numCols); 117 return false; 118 } else if(inMask && (totOffRow>=inMask->numRows || totOffCol>=inMask->numCols)) { 119 psError( PS_ERR_BAD_PARAMETER_SIZE, true, 120 PS_ERRORTEXT_pmFlatField_OFFSET_MASK_IMAGE, 121 totOffRow, totOffCol, inMask->numRows, inMask->numCols); 122 return false; 123 } 124 125 // Check for incorrect types 126 inType = inImage->type.type; 127 flatType = flatImage->type.type; 128 maskType = inMask->type.type; 129 if(PS_IS_PSELEMTYPE_COMPLEX(inType)) { 130 psError( PS_ERR_BAD_PARAMETER_TYPE, true, 131 PS_ERRORTEXT_pmFlatField_TYPE_INPUT_IMAGE, 132 inType); 133 return false; 134 } else if(PS_IS_PSELEMTYPE_COMPLEX(flatType)) { 135 psError( PS_ERR_BAD_PARAMETER_TYPE, true, 136 PS_ERRORTEXT_pmFlatField_TYPE_FLAT_IMAGE, 137 flatType); 138 return false; 139 } else if(inMask && inMask->type.type != PS_TYPE_MASK) { 140 psError( PS_ERR_BAD_PARAMETER_TYPE, true, 141 PS_ERRORTEXT_pmFlatField_TYPE_MASK_IMAGE, 142 maskType); 143 return false; 144 } else if(inType != flatType) { 145 psError( PS_ERR_BAD_PARAMETER_TYPE, true, 146 PS_ERRORTEXT_pmFlatField_TYPE_MISMATCH, 147 inType, flatType); 83 if (inImage->numRows + yOffset >= flatImage->numRows || 84 inImage->numCols + xOffset >= flatImage->numCols) { 85 psError(PS_ERR_BAD_PARAMETER_SIZE, true, 86 PS_ERRORTEXT_pmFlatField_OFFSET_FLAT_IMAGE, 87 yOffset, xOffset, flatImage->numRows, flatImage->numCols); 148 88 return false; 149 89 } … … 152 92 #define FLAT_DIVISION_CASE(TYPE) \ 153 93 case PS_TYPE_##TYPE: \ 154 for ( long j = totOffRow; j < inImage->numRows; j++) { \155 for ( long i = totOffCol; i < inImage->numCols; i++) { \94 for (int j = 0; j < inImage->numRows; j++) { \ 95 for (int i = 0; i < inImage->numCols; i++) { \ 156 96 if (flatImage->data.TYPE[j][i] <= 0.0) { \ 157 97 if (inMask) { \ 158 98 inMask->data.U8[j][i] |= PM_MASK_FLAT; \ 159 99 } \ 160 flatImage->data.TYPE[j][i] = 0.0; \100 inImage->data.TYPE[j][i] = NAN; \ 161 101 } else { \ 162 if (!inMask || !inMask->data.U8[j][i]) { \ 163 inImage->data.TYPE[j][i] /= flatImage->data.TYPE[j][i]; \ 164 } \ 102 inImage->data.TYPE[j][i] /= flatImage->data.TYPE[j][i]; \ 165 103 } \ 166 104 } \ … … 168 106 break; 169 107 170 switch (inType) {108 switch (inImage->type.type) { 171 109 FLAT_DIVISION_CASE(U8); 172 110 FLAT_DIVISION_CASE(U16); … … 180 118 FLAT_DIVISION_CASE(F64); 181 119 default: 182 psError( PS_ERR_BAD_PARAMETER_TYPE, true, 183 PS_ERRORTEXT_pmFlatField_TYPE_UNSUPPORTED, 184 inType); 120 psError(PS_ERR_BAD_PARAMETER_TYPE, true, 121 PS_ERRORTEXT_pmFlatField_TYPE_UNSUPPORTED, 122 inImage->type.type); 123 return false; 185 124 } 186 125
Note:
See TracChangeset
for help on using the changeset viewer.
