Changeset 7278 for trunk/psModules/src/detrend/pmSubtractBias.c
- Timestamp:
- Jun 1, 2006, 2:55:23 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmSubtractBias.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmSubtractBias.c
r7018 r7278 11 11 * @author GLG, MHPCC 12 12 * 13 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $14 * @date $Date: 2006-0 5-01 01:56:29$13 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-06-02 00:55:23 $ 15 15 * 16 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 146 146 147 147 148 #if 0149 /******************************************************************************150 ImageSubtractScalar(): subtract a scalar from the input image.151 152 XXX: Use a psLib function for this.153 154 XXX: This should155 *****************************************************************************/156 static psImage *ImageSubtractScalar(psImage *image,157 psF32 scalar)158 {159 for (psS32 i=0;i<image->numRows;i++) {160 for (psS32 j=0;j<image->numCols;j++) {161 image->data.F32[i][j]-= scalar;162 }163 }164 return(image);165 }166 #endif167 168 148 /****************************************************************************** 169 149 GenNewStatOptions(): this routine will take as input the options member of the … … 175 155 static psStatsOptions GenNewStatOptions(const psStats *stat) 176 156 { 157 assert(stat); 158 177 159 psS32 numOptions = 0; 178 160 psStatsOptions opt = 0; … … 210 192 if (numOptions != 1) { 211 193 psLogMsg(__func__, PS_LOG_WARN, 212 "WARNING: pmSubtractBias.c: GenNewStatOptions(): Too many statistics options have been specified\n"); 213 } 214 return(opt); 215 } 216 217 218 219 #if 0 220 /****************************************************************************** 221 ScaleOverscanVector(): this routine takes as input an arbitrary vector, 222 creates a new vector of length n, and fills the new vector with the 223 interpolated values of the old vector. The type of interpolation is: 224 PM_FIT_POLYNOMIAL: fit a polynomial to the entire input vector data. 225 PM_FIT_SPLINE: fit splines to the input vector data. 226 XXX: Doesn't it make more sense to do polynomial interpolation on a few 227 elements of the input vector, rather than fit a polynomial to the entire 228 vector? 229 *****************************************************************************/ 230 static psVector *ScaleOverscanVector(psVector *overscanVector, 231 psS32 n, 232 void *fitSpec, 233 pmFit fit) 234 { 235 psTrace(".psModule.pmSubtracBias.ScaleOverscanVector", 4, 236 "---- ScaleOverscanVector() begin (%d -> %d) ----\n", overscanVector->n, n); 237 // PS_VECTOR_PRINT_F32(overscanVector); 238 239 if (NULL == overscanVector) { 240 return(overscanVector); 241 } 242 243 // Allocate the new vector. 244 psVector *newVec = psVectorAlloc(n, PS_TYPE_F32); 245 246 // 247 // If the new vector is the same size as the old, simply copy the data. 248 // 249 if (n == overscanVector->n) { 250 for (psS32 i = 0 ; i < n ; i++) { 251 newVec->data.F32[i] = overscanVector->data.F32[i]; 252 } 253 return(newVec); 254 } 255 psPolynomial1D *myPoly; 256 psSpline1D *mySpline; 257 psF32 x; 258 psS32 i; 259 if (fit == PM_FIT_POLYNOMIAL) { 260 // Fit a polynomial to the old overscan vector. 261 myPoly = (psPolynomial1D *) fitSpec; 262 PS_ASSERT_POLY_NON_NULL(myPoly, NULL); 263 myPoly = psVectorFitPolynomial1D(myPoly, NULL, 0, overscanVector, NULL, NULL); 264 if (myPoly == NULL) { 265 psError(PS_ERR_UNKNOWN, false, "ScaleOverscanVector()(1): Could not fit a polynomial to the psVector.\n"); 266 return(NULL); 267 } 268 269 // For each element of the new vector, convert the x-ordinate to that 270 // of the old vector, use the fitted polynomial to determine the 271 // interpolated value at that point, and set the new vector. 272 for (i=0;i<n;i++) { 273 x = ((psF32) i) * ((psF32) overscanVector->n) / ((psF32) n); 274 newVec->data.F32[i] = psPolynomial1DEval(myPoly, x); 275 } 276 } else if (fit == PM_FIT_SPLINE) { 277 psS32 mustFreeSpline = 0; 278 // Fit a spline to the old overscan vector. 279 mySpline = (psSpline1D *) fitSpec; 280 // XXX: Does it make any sense to have a psSpline argument? 281 if (mySpline == NULL) { 282 mustFreeSpline = 1; 283 } 284 285 // 286 // NOTE: Since the X arg in the psVectorFitSpline1D() function is NULL, 287 // splines endpoints will be from 0.0 to overscanVector->n-1. Must scale 288 // properly when doing the spline eval. 289 // 290 // mySpline = psVectorFitSpline1D(mySpline, NULL, overscanVector, NULL); 291 mySpline = psVectorFitSpline1D(NULL, overscanVector); 292 if (mySpline == NULL) { 293 psError(PS_ERR_UNKNOWN, false, "ScaleOverscanVector()(2): Could not fit a spline to the psVector.\n"); 294 return(NULL); 295 } 296 // PS_PRINT_SPLINE(mySpline); 297 298 // For each element of the new vector, convert the x-ordinate to that 299 // of the old vector, use the fitted polynomial to determine the 300 // interpolated value at that point, and set the new vector. 301 for (i=0;i<n;i++) { 302 // Scale to [0 : overscanVector->n - 1] 303 x = ((psF32) i) * ((psF32) (overscanVector->n-1)) / ((psF32) n); 304 newVec->data.F32[i] = psSpline1DEval(mySpline, x); 305 } 306 if (mustFreeSpline ==1) { 307 psFree(mySpline); 308 } 309 // PS_VECTOR_PRINT_F32(newVec); 310 311 312 } else { 313 psError(PS_ERR_UNKNOWN, true, "unknown fit type. Returning NULL.\n"); 314 psFree(newVec); 315 return(NULL); 316 } 317 318 psTrace(".psModule.pmSubtracBias.ScaleOverscanVector", 4, 319 "---- ScaleOverscanVector() exit ----\n"); 320 return(newVec); 321 } 322 323 #endif 194 "WARNING: pmSubtractBias.c: GenNewStatOptions(): Too many statistics options " 195 "have been specified\n"); 196 } 197 return opt; 198 } 199 324 200 325 201 // Produce an overscan vector from an array of pixels … … 329 205 ) 330 206 { 207 assert(overscanOpts); 208 assert(pixels); 209 assert(myStats); 210 331 211 // Reduce the overscans 332 212 psVector *reduced = psVectorAlloc(pixels->n, PS_TYPE_F32); // Overscan for each row … … 416 296 psTrace(".psModule.pmSubtracBias.pmSubtractBias", 4, 417 297 "---- pmSubtractBias() begin ----\n"); 418 PS_ASSERT_READOUT_NON_NULL(in, NULL); 419 PS_ASSERT_READOUT_NON_EMPTY(in, NULL); 420 PS_ASSERT_READOUT_TYPE(in, PS_TYPE_F32, NULL); 298 PS_ASSERT_PTR_NON_NULL(in, NULL); 299 PS_ASSERT_IMAGE_NON_NULL(in->image, NULL); 300 PS_ASSERT_IMAGE_TYPE(in->image, PS_TYPE_F32, NULL); 301 PS_ASSERT_PTR_NON_NULL(overscanOpts, NULL); 302 if (bias) { 303 PS_ASSERT_IMAGE_NON_NULL(bias->image, NULL); 304 PS_ASSERT_IMAGE_TYPE(bias->image, PS_TYPE_F32, NULL); 305 } 306 if (dark) { 307 PS_ASSERT_IMAGE_NON_NULL(dark->image, NULL); 308 PS_ASSERT_IMAGE_TYPE(dark->image, PS_TYPE_F32, NULL); 309 } 421 310 422 311 psImage *image = in->image; // The input image
Note:
See TracChangeset
for help on using the changeset viewer.
