Changeset 1813
- Timestamp:
- Sep 14, 2004, 3:04:29 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmFlatField.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmFlatField.c
r1804 r1813 15 15 * @author Ross Harman, MHPCC 16 16 * 17 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $18 * @date $Date: 2004-09-1 4 18:08:14$17 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 18 * @date $Date: 2004-09-15 01:04:29 $ 19 19 * 20 20 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 33 33 #define CHECK_NULL(STRUCT) \ 34 34 if (STRUCT == NULL) { \ 35 psAbort(__func__, " : Line %d - Null not allowed for %s", __LINE__, #STRUCT); \ 35 psError(__func__, " : Line %d - Null not allowed for %s", __LINE__, #STRUCT); \ 36 return false; \ 36 37 } \ 37 38 38 psReadout *pmFlatField(psReadout *in, psReadout *inMask, const psReadout *flat, const psReadout *flatMask)39 bool pmFlatField(psReadout *in, psReadout *inMask, const psReadout *flat) 39 40 { 40 41 int i = 0; 41 42 int j = 0; 43 int totOffCol = 0; 44 int totOffRow = 0; 42 45 psElemType inType; 43 46 psElemType flatType; 47 psElemType maskType; 44 48 psImage *inImage = NULL; 45 49 psImage *flatImage = NULL; 46 psImage *inMaskImage = NULL; 47 psImage *flatMaskImage = NULL; 50 psImage *maskImage = NULL; 48 51 49 52 CHECK_NULL(in); 50 53 CHECK_NULL(flat); 51 54 CHECK_NULL(inMask); 52 CHECK_NULL(flatMask);53 55 54 56 inImage = in->image; 55 57 flatImage = flat->image; 56 inMaskImage = inMask->image; 57 flatMaskImage = flatMask->image; 58 maskImage = inMask->image; 58 59 59 60 CHECK_NULL(inImage); 60 61 CHECK_NULL(flatImage); 61 CHECK_NULL(inMaskImage); 62 CHECK_NULL(flatMaskImage); 62 CHECK_NULL(maskImage); 63 64 totOffCol = inImage->col0 + in->col0; 65 totOffRow = inImage->row0 + in->row0; 63 66 64 67 if(inImage->numRows > flatImage->numRows) { 65 68 psError(__func__, " : Line %d - Input image exceeds flat image in number of rows. (%d vs %d).", 66 69 __LINE__, inImage->numRows, flatImage->numRows); 67 return NULL;70 return false; 68 71 } 69 72 … … 71 74 psError(__func__, " : Line %d - Input image exceeds flat image in number of columns. (%d vs %d).", 72 75 __LINE__, inImage->numCols, flatImage->numCols); 73 return NULL;76 return false; 74 77 } 75 78 76 if( inImage->row0> flatImage->numRows-1) {77 psError(__func__, " : Line %d - In put image row offset exceeds number of flat image rows. (%d vs %d).",78 __LINE__, inImage->row0, flatImage->numRows);79 return NULL;79 if(totOffRow > flatImage->numRows-1) { 80 psError(__func__, " : Line %d - Initial row offset exceeds that of flat image. (%d vs %d).", 81 __LINE__, totOffRow, flatImage->numRows); 82 return false; 80 83 } 81 84 82 if( inImage->col0> flatImage->numCols-1) {83 psError(__func__, " : Line %d - In put image column offset exceeds number of flat image columns. (%d vs %d).",84 __LINE__, inImage->col0, flatImage->numCols);85 return NULL;85 if(totOffCol > flatImage->numCols-1) { 86 psError(__func__, " : Line %d - Initial column offset exceeds that of flat image. (%d vs %d).", 87 __LINE__, totOffCol, flatImage->numCols); 88 return false; 86 89 } 87 90 88 inType = in->image->type.type; 89 flatType = flat->image->type.type; 91 if(totOffRow > inImage->numRows-1) { 92 psError(__func__, " : Line %d - Initial row offset exceeds that of input image. (%d vs %d).", 93 __LINE__, totOffRow, inImage->numRows); 94 return false; 95 } 96 97 if(totOffCol > inImage->numCols-1) { 98 psError(__func__, " : Line %d - Initial column offset exceeds that of input image. (%d vs %d).", 99 __LINE__, totOffCol, inImage->numCols); 100 return false; 101 } 102 103 inType = inImage->type.type; 104 flatType = flatImage->type.type; 105 maskType = maskImage->type.type; 106 107 if(PS_IS_PSELEMTYPE_COMPLEX(inType)) { 108 psError(__func__, " : Line %d - Complex types not allowed for input image", __LINE__); 109 return false; 110 } 111 112 if(PS_IS_PSELEMTYPE_COMPLEX(flatType)) { 113 psError(__func__, " : Line %d - Complex types not allowedfor flat image", __LINE__); 114 return false; 115 } 116 117 if(PS_IS_PSELEMTYPE_COMPLEX(maskType)) { 118 psError(__func__, " : Line %d - Complex types not allowed for mask image", __LINE__); 119 return false; 120 } 121 122 if(PS_IS_PSELEMTYPE_REAL(maskType)) { 123 psError(__func__, " : Line %d - Floating point types not allowed for mask image", __LINE__); 124 return false; 125 } 126 90 127 if(inType != flatType) { 91 128 psError(__func__, " : Line %d - Input and flat image types don't agree. (%d vs %d).", … … 96 133 // Macro for all PS types 97 134 #define PM_FLAT_DIVISION(TYPE) \ 98 case PS_TYPE_##TYPE: \ 99 for(j = inImage->row0; j < inImage->numRows; j++) { \ 100 for(i = inImage->col0; i < inImage->numCols; i++) { \ 101 if(creal(flatImage->data.TYPE[j][i]) <= 0.0) { \ 135 case PS_TYPE_##TYPE: \ 136 /* Per Eugene's request, use two sets of loops: first to fill mask, second to avoid div with bad pix */ \ 137 for(j = totOffRow; j < inImage->numRows; j++) { \ 138 for(i = totOffCol; i < inImage->numCols; i++) { \ 139 if(flatImage->data.TYPE[j][i] <= 0.0) { \ 102 140 /* Negative or zero flat pixels shall be masked in input image as PM_MASK_FLAT */ \ 103 inMaskImage->data.F64[j][i] = PM_MASK_FLAT; \ 104 } else if(flatMaskImage->data.TYPE[j][i]){ \ 105 /* Pixels masked in the flat shall be masked with same values in the output */ \ 106 inMaskImage->data.TYPE[j][i] = flatMaskImage->data.TYPE[j][i]; \ 141 maskImage->data.F64[j][i] = PM_MASK_FLAT; \ 107 142 } \ 108 if(creal(flatImage->data.TYPE[j][i]) < 0.0) { \ 109 /* Negative pixels from the flat image may be set to zero */ \ 110 inImage->data.TYPE[j][i] = 0.0; \ 111 } else if(fabs(flatImage->data.TYPE[j][i]) < FLT_EPSILON) { \ 112 psError(__func__, " : Line %d - Divide by zero. Row: %d Col: %d",__LINE__, j, i); \ 113 } else { \ 143 } \ 144 } \ 145 for(j = totOffRow; j < inImage->numRows; j++) { \ 146 for(i = totOffCol; i < inImage->numCols; i++) { \ 147 if(maskImage->data.F64[j][i] == 0) { \ 114 148 /* Module shall divide the input image by the flat-fielded image */ \ 115 149 inImage->data.TYPE[j][i] = inImage->data.TYPE[j][i]/flatImage->data.TYPE[j][i]; \ 116 150 } \ 117 } \118 } \151 } \ 152 } \ 119 153 break; 120 154 … … 130 164 PM_FLAT_DIVISION(F32); 131 165 PM_FLAT_DIVISION(F64); 132 PM_FLAT_DIVISION(C32);133 PM_FLAT_DIVISION(C64);134 166 default: 135 167 psError(__func__, "Unsupported image datatype (%d)", inType);
Note:
See TracChangeset
for help on using the changeset viewer.
