Changeset 1880
- Timestamp:
- Sep 24, 2004, 11:05:00 AM (22 years ago)
- Location:
- trunk/psModules/src
- Files:
-
- 1 added
- 2 edited
-
Makefile (added)
-
Makefile.am (modified) (2 diffs)
-
pmSubtractBias.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/Makefile.am
r1849 r1880 2 2 bin_PROGRAMS = tst_pmFlatField tst_pmMaskBadPixels 3 3 4 libpsmodule_a_SOURCES = pmFlatField.c pmMaskBadPixels.c p sTest.c5 libpsmodule_a_HEADERS = pmFlatField.h pmMaskBadPixels.h p sTest.h4 libpsmodule_a_SOURCES = pmFlatField.c pmMaskBadPixels.c pmSubtractBias.c psTest.c 5 libpsmodule_a_HEADERS = pmFlatField.h pmMaskBadPixels.h pmSubtractBias.h psTest.h 6 6 libpsmodule_adir = . 7 7 … … 11 11 tst_pmMaskBadPixels_SOURCES = tst_pmMaskBadPixels.c 12 12 tst_pmMaskBadPixels_LDFLAGS = libpsmodule.a 13 14 tst_pmSB_SOURCES = tst_pmMaskBadPixels.c 15 tst_pmSB_LDFLAGS = libpsmodule.a -
trunk/psModules/src/pmSubtractBias.c
r1877 r1880 8 8 * @author George Gusciora, MHPCC 9 9 * 10 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-09-24 18:31:02$10 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-09-24 21:05:00 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 35 35 // PM_FIT_SPLINE ///< Fit cubic splines 36 36 37 #define PM_SUBTRACT_BIAS_POLYNOMIAL_ORDER 2 38 #define PM_SUBTRACT_BIAS_SPLINE_ORDER 3 37 39 38 40 psReadout *psSubtractFrame(psReadout *in, … … 84 86 } 85 87 88 /****************************************************************************** 89 GenNewStatOptions(): this routine will take as input the options member of 90 the stat data structure, determine if multiple options have been specified, 91 issue a warning message if so, and return the highest priority option 92 (according to the order of the if-statements in this code). 93 *****************************************************************************/ 94 psStatsOptions GenNewStatOptions(const psStats *stat) 95 { 96 int numOptions = 0; 97 psStatsOptions opt; 98 99 if (stat->options & PS_STAT_SAMPLE_MEAN) { 100 numOptions++; 101 opt = PS_STAT_SAMPLE_MEAN; 102 } 103 104 if (stat->options & PS_STAT_SAMPLE_MEDIAN) { 105 if (numOptions == 0) { 106 opt = PS_STAT_SAMPLE_MEDIAN; 107 } 108 numOptions++; 109 } 110 111 if (stat->options & PS_STAT_CLIPPED_MEAN) { 112 if (numOptions == 0) { 113 opt = PS_STAT_CLIPPED_MEAN; 114 } 115 numOptions++; 116 } 117 118 if (stat->options & PS_STAT_ROBUST_MEAN) { 119 if (numOptions == 0) { 120 opt = PS_STAT_ROBUST_MEAN; 121 } 122 numOptions++; 123 } 124 125 if (stat->options & PS_STAT_ROBUST_MEDIAN) { 126 if (numOptions == 0) { 127 opt = PS_STAT_ROBUST_MEDIAN; 128 } 129 numOptions++; 130 } 131 132 if (stat->options & PS_STAT_ROBUST_MODE) { 133 if (numOptions == 0) { 134 opt = PS_STAT_ROBUST_MODE; 135 } 136 numOptions++; 137 } 138 139 if (numOptions != 1) { 140 \\ XXX: 141 Generate warning message. 142 } 143 144 return(opt); 145 } 146 147 // XXX: Must scale the overscan vector 148 psVector *ScaleOverscanVector(overscanVector, 149 (in->image)->numCols, 150 pmFit fit) 151 { 152 return(overscanVector); 153 } 154 86 155 87 156 psReadout *pmSubtractBias(psReadout *in, … … 98 167 int nBin; 99 168 int numBins; 100 static psVector *tmp = NULL; 101 static psVector *tmpRow = NULL; 102 static psVector *tmpCol = NULL; 103 static psVector *tmpMask = NULL; 169 static psVector *overscanVector = NULL; 170 psVector *tmpRow = NULL; 171 psVector *tmpCol = NULL; 172 psVector *tmpMask = NULL; 173 psVector *myBin = NULL; 174 psVector *binVec = NULL; 175 psList *tmpOverscan = NULL; 104 176 105 177 if (in == NULL) { … … 107 179 } 108 180 181 // 182 // Determine if multiple options are specified in stat. 183 // 184 if (stat != NULL) { 185 stat->options = GenNewStatOptions(stat); 186 } 187 109 188 if ((overscans == NULL) && (overScanAxis != PM_OVERSCAN_NONE)) { 110 189 //XXX: psErrorMsg() 111 }112 if ((overscans != NULL) && (overScanAxis == PM_OVERSCAN_NONE)) {113 //XXX: psWarningMsg()114 return(psSubtractFrame(in, bias));115 }116 117 if (overScanAxis == PM_OVERSCAN_ALL) {118 psImageStats(stat, in->image, in->mask, 0xffffffff);119 p_psImageSubtractScalar(in->image, stat->value);120 190 return(in); 121 191 } … … 129 199 } 130 200 201 if (overScanAxis == PM_OVERSCAN_NONE) { 202 if (overscans != NULL) { 203 //XXX: psWarningMsg() 204 } 205 return(psSubtractFrame(in, bias)); 206 } 207 208 if (overScanAxis == PM_OVERSCAN_ALL) { 209 psImageStats(stat, in->image, in->mask, 0xffffffff); 210 p_psImageSubtractScalar(in->image, stat->value); 211 return(in); 212 } 213 131 214 // XXX: Is there a better way to extract a psVector from a psImage without 132 215 // having to copy every element in that vector? … … 135 218 // or PM_OVERSCAN_COL? 136 219 220 // XXX: How to use multiple overscans? Currently, only the first is used. 137 221 if ((overScanAxis == PM_OVERSCAN_ROW) || (overScanAxis == PM_OVERSCAN_COL)) { 222 myOverscanImage = (psImage *) overscans->data; 223 138 224 if (overScanAxis == PM_OVERSCAN_ROW) { 139 tmp = psVectorAlloc((in->image)->numCols, PS_TYPE_F32); 225 overscanVector = psVectorAlloc((myOverscanImage->image)->numCols, PS_TYPE_F32); 226 for (i=0;i<overscanVector->n;i++) { 227 overscanVector->data.F32[i] = 0.0; 228 } 140 229 tmpRow = psVectorAlloc((in->image)->numCols, PS_TYPE_F32); 141 230 tmpMask = psVectorAlloc((in->image)->numCols, PS_TYPE_U8); 142 for (i=0;i<(in->image)->numCols;i++) { 143 for (j=0;j<(in->image)->numRows;j++) { 144 tmpRow->data.F32[j] = (in->image)->data.F32[i][j]; 145 tmpMask->data.U8[j] = (in->mask)->data.U8[i][j]; 146 } 147 stat = psVectorStats(stat, tmpRow, tmpMask, 0xffffffff); 148 tmp->data.F32[i] = stat->value; 149 } 231 232 tmpOverscan = (psList *) overscans; 233 while (tmpOverscan) { 234 myOverscanImage = (psImage *) tmpOverscan->data; 235 for (i=0;i<(myOverscanImage->image)->numCols;i++) { 236 for (j=0;j<(myOverscanImage->image)->numRows;j++) { 237 tmpRow->data.F32[j] = (myOverscanImage->image)->data.F32[i][j]; 238 tmpMask->data.U8[j] = (myOverscanImage->mask)->data.U8[i][j]; 239 } 240 stat = psVectorStats(stat, tmpRow, tmpMask, 0xffffffff); 241 overscanVector->data.F32[i] = stat->value; 242 } 243 // tmpOverscan = tmpOverscan->next; 244 tmpOverscan = NULL: 245 } 246 247 psFree(tmpRow); 248 psFree(tmpMask); 249 ScaleOverscanVector(overscanVector, (in->image)->numCols, fit); 150 250 } 151 251 if (overScanAxis == PM_OVERSCAN_COL) { 152 tmp = psVectorAlloc((in->image)->numRows, PS_TYPE_F32); 252 overscanVector = psVectorAlloc((myOverscanImage->image)->numRows, PS_TYPE_F32); 253 for (i=0;i<overscanVector->n;i++) { 254 overscanVector->data.F32[i] = 0.0; 255 } 153 256 tmpcol = psVectorAlloc((in->image)->numRows, PS_TYPE_F32); 154 257 tmpMask = psVectorAlloc((in->image)->nuRows, PS_TYPE_U8); 155 for (i=0;i<(in->image)->numRows;i++) { 156 for (j=0;j<(in->image)->numCols;j++) { 157 tmpRow->data.F32[j] = (in->image)->data.F32[i][j]; 158 tmpMask->data.U8[j] = (in->mask)->data.U8[i][j]; 159 } 160 stat = psVectorStats(stat, tmpRow, tmpMask, 0xffffffff); 161 tmp->data.F32[i] = stat->value; 162 } 163 } 164 165 if (nBin > 0) { 166 numBins = 1+((tmp->n)/nBin); 258 259 tmpOverscan = (psList *) overscans; 260 while (tmpOverscan) { 261 for (i=0;i<(myOverscanImage->image)->numRows;i++) { 262 for (j=0;j<(myOverscanImage->image)->numCols;j++) { 263 tmpRow->data.F32[j] = (myOverscanImage->image)->data.F32[i][j]; 264 tmpMask->data.U8[j] = (myOverscanImage->mask)->data.U8[i][j]; 265 } 266 stat = psVectorStats(stat, tmpRow, tmpMask, 0xffffffff); 267 overscanVector->data.F32[i] = stat->value; 268 } 269 // tmpOverscan = tmpOverscan->next; 270 tmpOverscan = NULL: 271 } 272 psFree(tmpCol); 273 psFree(tmpMask); 274 ScaleOverscanVector(overscanVector, (in->image)->numRows, fit); 275 } 276 277 if ((nBin > 0) && (nBin < overscanVector->n)) { 278 numBins = 1+((overscanVector->n)/nBin); 167 279 psVector *myBin = psVectorAlloc(numBins, PS_TYPE_F32); 280 binVec = psVectorAlloc(nBin, PS_TYPE_F32); 168 281 169 282 for (i=0;i<numBins;i++) { 170 // XXX: do this 171 } 172 // XXX: resize tmp to myBin, and store myBin elements there. 283 for(j=0;j<nBin;j++) { 284 if (overscanVector->n > ((i*nBin)+j)) { 285 binVec->data.F32[j] = overscanVector->data.F32[(i*nBin)+j]; 286 } else { 287 // XXX: we get here if nBin does not evenly divide 288 // the overscanVector vector. This is the last bin. Should 289 // we change the binVec->n to acknowledge that? 290 binVec->n = j; 291 } 292 } 293 stat = psVectorStats(stat, binVec, NULL, 0); 294 myBin->data.F32[i] = stat->value; 295 } 296 // Change the effective size of overscanVector. 297 overscanVector->n = numBins; 298 for (i=0;i<numBins;i++) { 299 overscanVector->data.F32[i] = myBin->data.F32[i]; 300 } 301 psFree(binVec); 302 psFree(myBin); 173 303 } else { 174 304 nBin = 1; 175 305 } 176 306 177 if (!((fitSpec == NULL) || (fit ==PM_FIT_NONE))) { 178 fit the vector to a linear or cubic spline. 307 if (!((fitSpec == NULL) || (fit == PM_FIT_NONE))) { 308 if (fit == PM_FIT_POLYNOMIAL) { 309 myPoly = (psPolynomial1D *) fitSpec; 310 myPoly = psVectorFitPolynomial1D(myPoly, NULL, overscanVector, NULL); 311 for (i=0;i<numBins;i++) { 312 overscanVector->data.F32[i] = psPolynomial1DEval((float) i, myPoly); 313 } 314 315 } else if (fit == PM_FIT_SPLINE) { 316 mySpline = (psSPline1D *) fitSpec; 317 // XXX: What is the point of doing this? 318 } 179 319 } 180 320 … … 182 322 for (i=0;i<(in->image)->numCols;i++) { 183 323 for (j=0;j<(in->image)->numRows;j++) { 184 (in->image)->data.F32[i][j]-= tmp->data.F32[j/nBin];324 (in->image)->data.F32[i][j]-= overscanVector->data.F32[j/nBin]; 185 325 } 186 326 } … … 190 330 for (i=0;i<(in->image)->numRows;i++) { 191 331 for (j=0;j<(in->image)->numCols;j++) { 192 (in->image)->data.F32[i][j]-= tmp->data.F32[j/nBin]; 193 } 194 } 195 } 332 (in->image)->data.F32[i][j]-= overscanVector->data.F32[j/nBin]; 333 } 334 } 335 } 336 psFree(overscanVector); 196 337 return(in); 197 338 }
Note:
See TracChangeset
for help on using the changeset viewer.
