Changeset 9619
- Timestamp:
- Oct 17, 2006, 3:05:59 PM (20 years ago)
- Location:
- trunk/psModules/src/detrend
- Files:
-
- 2 edited
-
pmSubtractBias.c (modified) (9 diffs)
-
pmSubtractBias.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmSubtractBias.c
r8669 r9619 1 //////////////////////////////////////////////////////////////////////////////////////////////////////////////2 // XXX WARNING: I have completely replaced this file with an OLD VERSION (that works) instead of the3 // one that was being worked on.4 //////////////////////////////////////////////////////////////////////////////////////////////////////////////5 6 /** @file pmSubtractBias.c7 *8 * This file will contain a module which will subtract the detector bias9 * in place from an input image.10 *11 * @author GLG, MHPCC12 *13 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $14 * @date $Date: 2006-08-29 21:39:44 $15 *16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii17 *18 */19 20 1 #if HAVE_CONFIG_H 21 2 #include <config.h> … … 25 6 #include <assert.h> 26 7 #include <pslib.h> 8 9 #include "pmFPA.h" 27 10 #include "pmSubtractBias.h" 28 11 … … 31 14 32 15 33 #define MAX(a,b) ((a) > (b) ? (a) : (b)) 34 #define MIN(a,b) ((a) < (b) ? (a) : (b)) 35 36 37 // XXX: put these in psConstants.h 38 void PS_POLY1D_PRINT(psPolynomial1D *poly) 39 { 40 printf("-------------- PS_POLY1D_PRINT() --------------\n"); 41 printf("poly->nX is %d\n", poly->nX); 42 for (psS32 i = 0 ; i < (1 + poly->nX) ; i++) { 43 printf("poly->coeff[%d] is %f\n", i, poly->coeff[i]); 44 } 45 } 46 47 void PS_PRINT_SPLINE(psSpline1D *mySpline) 48 { 49 printf("-------------- PS_PRINT_SPLINE() --------------\n"); 50 printf("mySpline->n is %d\n", mySpline->n); 51 for (psS32 i = 0 ; i < mySpline->n ; i++) { 52 PS_POLY1D_PRINT(mySpline->spline[i]); 53 } 54 PS_VECTOR_PRINT_F32(mySpline->knots); 55 } 56 57 #define PS_IMAGE_PRINT_F32_HIDEF(NAME) \ 58 printf("======== printing %s ========\n", #NAME); \ 59 for (int i = 0 ; i < (NAME)->numRows ; i++) { \ 60 for (int j = 0 ; j < (NAME)->numCols ; j++) { \ 61 printf("%.5f ", (NAME)->data.F32[i][j]); \ 62 } \ 63 printf("\n"); \ 64 }\ 65 66 67 void overscanOptionsFree(pmOverscanOptions *options) 16 static void overscanOptionsFree(pmOverscanOptions *options) 68 17 { 69 18 psFree(options->stat); … … 91 40 92 41 93 /****************************************************************************** 94 psSubtractFrame(): this routine will take as input a readout for the input 95 image and a readout for the bias image. The bias image is subtracted in 96 place from the input image. 97 *****************************************************************************/ 98 static bool SubtractFrame(pmReadout *in,// Input readout 42 // psSubtractFrame(): this routine will take as input a readout for the input image and a readout for the bias 43 // image. The bias image is subtracted in place from the input image. 44 static bool SubtractFrame(pmReadout *in, // Input readout 99 45 const pmReadout *sub, // Readout to be subtracted from input 100 46 float scale // Scale to apply before subtracting … … 109 55 psImage *subMask = sub->mask; // The mask for the subtraction image 110 56 57 // Check parities 111 58 int xIpar = psMetadataLookupS32(NULL, in->parent->concepts, "CELL.XPARITY"); 112 59 int xSpar = psMetadataLookupS32(NULL, sub->parent->concepts, "CELL.XPARITY"); … … 252 199 253 200 254 255 /******************************************************************************256 XXX: The SDRS does not specify type support. F32 is implemented here.257 *****************************************************************************/258 201 bool pmSubtractBias(pmReadout *in, pmOverscanOptions *overscanOpts, 259 202 const pmReadout *bias, const pmReadout *dark) … … 280 223 if (overscanOpts->fitType != PM_FIT_NONE && overscanOpts->fitType != PM_FIT_POLY_ORD && 281 224 overscanOpts->fitType != PM_FIT_POLY_CHEBY && overscanOpts->fitType != PM_FIT_SPLINE) { 282 psError(PS_ERR_UNKNOWN, true, "Invalid fit type (%d). Returning original image.\n", overscanOpts->fitType); 225 psError(PS_ERR_UNKNOWN, true, "Invalid fit type (%d). Returning original image.\n", 226 overscanOpts->fitType); 283 227 return false; 284 228 } … … 335 279 while ((overscan = psListGetAndIncrement(iter))) { 336 280 int diff = image->row0 - overscan->row0; // Offset between the two regions 337 for (int i = MAX(0,diff); i <MIN(image->numRows, overscan->numRows + diff); i++) {281 for (int i = PS_MAX(0,diff); i < PS_MIN(image->numRows, overscan->numRows + diff); i++) { 338 282 // i is row on overscan 339 283 // XXX Reimplement with memcpy … … 379 323 while ((overscan = psListGetAndIncrement(iter))) { 380 324 int diff = image->col0 - overscan->col0; // Offset between the two regions 381 for (int i = MAX(0,diff); i <MIN(image->numCols, overscan->numCols + diff); i++) {325 for (int i = PS_MAX(0,diff); i < PS_MIN(image->numCols, overscan->numCols + diff); i++) { 382 326 // i is column on overscan 383 327 // XXX Reimplement with memcpy -
trunk/psModules/src/detrend/pmSubtractBias.h
r7589 r9619 1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 2 // XXX WARNING: I have completely replaced this file with an OLD VERSION (that works) instead of the 3 // one that was being worked on. 4 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 1 /// @file pmSubtractBias.h 2 /// 3 /// @brief Subtract the overscan, bias and dark 4 /// 5 /// @ingroup Detrend 6 /// 7 /// @author George Gusciora, MHPCC 8 /// @author Paul Price, IfA 9 /// 10 /// @version $Revision: 1.3 $ $Name: not supported by cvs2svn $ 11 /// @date $Date: 2006-10-18 01:05:59 $ 12 /// 13 /// Copyright 2004--2006 Institute for Astronomy, University of Hawaii 14 /// 5 15 6 /** @file pmSubtractBias.h 7 * 8 * This file will contain a module which will subtract the detector bias 9 * in place from an input image. 10 * 11 * @author GLG, MHPCC 12 * 13 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 14 * @date $Date: 2006-06-17 01:50:43 $ 15 * 16 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii 17 * 18 */ 19 20 #if !defined(PM_SUBTRACT_BIAS_H) 16 #ifndef PM_SUBTRACT_BIAS_H 21 17 #define PM_SUBTRACT_BIAS_H 22 18 23 #if HAVE_CONFIG_H 24 #include <config.h> 25 #endif 26 27 #include<stdio.h> 28 #include<math.h> 29 #include "pslib.h" 19 #include <stdio.h> 20 #include <pslib.h> 30 21 31 22 #include "pmFPA.h" 32 23 33 typedef enum { 34 PM_OVERSCAN_NONE, ///< No overscan subtraction 35 PM_OVERSCAN_EDGE, ///< Subtract the statistic of pixels along the to-be-determined readout direction 36 PM_OVERSCAN_ROWS, ///< Subtract rows 37 PM_OVERSCAN_COLUMNS, ///< Subtract columns 38 PM_OVERSCAN_ALL ///< Subtract the statistic of all pixels in overscan region 39 } pmOverscanAxis; 40 24 /// Type of fit to perform 41 25 typedef enum { 42 26 PM_FIT_NONE, ///< No fit … … 46 30 } pmFit; 47 31 32 /// Options for overscan subtraction 33 /// 34 /// The overscan subtraction may be performed by reducing all overscan regions to a single value (e.g., if 35 /// there is no structure); or the overscan may be fit perpendicular to the read direction (usually the 36 /// columns) with a particular functional form; or a single value may be subtracted for each read/scan without 37 /// fitting (if the structure defies characterisation). In any case, statistics are required to reduce 38 /// multiple values to a single value (either for the scan, or for the entire overscan regions). 48 39 typedef struct 49 40 { 50 41 // Inputs 51 bool single; // Reduce all overscan regions to a single value?52 pmFit fitType; // Type of fit to overscan53 unsigned int order; // Order of polynomial, or number of spline pieces54 psStats *stat; // Statistic to use when reducing the minor direction42 bool single; ///< Reduce all overscan regions to a single value? 43 pmFit fitType; ///< Type of fit to overscan 44 unsigned int order; ///< Order of polynomial, or number of spline pieces 45 psStats *stat; ///< Statistic to use when reducing the minor direction 55 46 // Outputs 56 psPolynomial1D *poly; // Result of polynomial fit57 psSpline1D *spline; // Result of spline fit47 psPolynomial1D *poly; ///< Result of polynomial fit 48 psSpline1D *spline; ///< Result of spline fit 58 49 } 59 50 pmOverscanOptions; 60 51 61 pmOverscanOptions *pmOverscanOptionsAlloc(bool single, pmFit fitType, unsigned int order, psStats *stat); 52 /// Allocator for overscan options 53 pmOverscanOptions *pmOverscanOptionsAlloc(bool single, ///< Reduce all overscan regions to a single value? 54 pmFit fitType, ///< Type of fit to overscan 55 unsigned int order, ///< Order of polynomial, or number of splines 56 psStats *stat ///< Statistic to use 57 ); 62 58 63 bool pmSubtractBias(pmReadout *in, pmOverscanOptions *overscanOpts, 64 const pmReadout *bias, const pmReadout *dark); 65 66 #if 0 67 pmReadout *pmSubtractBias(pmReadout *in, ///< The input pmReadout image 68 void *fitSpec, ///< A polynomial or spline, defining the fit type. 69 const psList *overscans, ///< A psList of overscan images 70 pmOverscanAxis overScanAxis, ///< Defines how overscans are applied 71 psStats *stat, ///< The statistic to be used in combining overscan data 72 int nBin, ///< The amount of binning to be done image pixels. 73 pmFit fit, ///< PM_FIT_SPLINE, PM_FIT_POLYNOMIAL, or PM_FIT_NONE 74 const pmReadout *bias); ///< A possibly NULL bias pmReadout which is to be subtracted 75 #endif 59 /// Subtract the overscan, bias and/or dark 60 /// 61 /// Subtracts the overscan, as measured from the bias member of the input readout (if options are non-NULL), 62 /// bias (if non-NULL) and dark (if non-NULL) scaled by the CELL.DARKTIME concept. 63 bool pmSubtractBias(pmReadout *in, ///< Input readout, to be overscan/bias/dark corrected 64 pmOverscanOptions *overscanOpts, ///< Options for overscan subtraction, or NULL 65 const pmReadout *bias, ///< Bias image to subtract, or NULL 66 const pmReadout *dark ///< Dark image to scale and subtract, or NULL 67 ); 76 68 77 69 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
