Changeset 1871
- Timestamp:
- Sep 23, 2004, 2:23:48 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmSubtractBias.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmSubtractBias.c
r1862 r1871 1 1 /** @file psMinimize.c 2 2 * \brief basic minimization functions 3 * @ingroup M ath3 * @ingroup Modules 4 4 * 5 5 * This file will contain a module which will subtract the detector bias … … 8 8 * @author George Gusciora, MHPCC 9 9 * 10 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $11 * @date $Date: 2004-09-2 3 06:48:30$10 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 11 * @date $Date: 2004-09-24 00:23:48 $ 12 12 * 13 13 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 36 36 37 37 38 psReadout *psSubtractFrame(in, bias) 38 psReadout *psSubtractFrame(psReadout *in, 39 const psReadout *bias) 39 40 { 41 int i; 42 int j; 43 40 44 if (bias == NULL) { 41 45 return(in); 42 46 } 43 // XXX: Check sizes 44 // XXX: use offsets 45 46 for (i=0;i<rows;i++) 47 for (j=0;j<cols;j++) 48 in[i][j]-=bias[i][j]; 47 48 if (((in->image)->numRows + in->row0 - bias->row0) > (bias->image)->numRows) { 49 // XXX: psErrorMsg() bias image does not have enough rows. 50 } 51 if (((in->image)->numCols + in->row0 - bias->row0) > (bias->image)->numCols) { 52 // XXX: psErrorMsg() bias image does not have enough columns. 53 } 54 55 // XXX: Verify that this is the correct way to use offsets. 56 // XXX: Instead of performing an if-statement to determine if the mask 57 // is non-zero, we instead always or the bias mask with the image 58 // mask. Might want to verify this is faster. 59 for (i=0;i<(in->image)->numRows;i++) { 60 for (j=0;j<(in->image)->numCols;j++) { 61 (in->image)->data.F32[i][j]-= 62 (bias->image)->data.F32[i+in->row0-bias->row0][j+in->col0-bias->col0]; 63 ((in->mask)->data.U8[i][j])|= 64 (bias->mask)->data.U8[i+in->row0-bias->row0][j+in->col0-bias->col0]; 65 } 66 } 67 68 return(in); 49 69 } 70 71 // XXX: Is there already a function which does this? 72 psImage *p_psImageSubtractScalar(psImage *image, 73 float *scalar) 74 { 75 int i; 76 int j; 77 78 for (i=0;i<image->numRows;i++) { 79 for (j=0;j<image->numCols;j++) { 80 image->data.F32[i][j]-= scalar; 81 } 82 } 83 return(image); 84 } 85 50 86 51 87 psReadout *pmSubtractBias(psReadout *in, … … 58 94 const psReadout *bias) 59 95 { 60 if ((overscans == NULL) && 61 (overScanAxis != PM_OVERSCAN_NONE)) { 96 int i; 97 int j; 98 int nBin; 99 int numBins; 100 static psVector *tmp = NULL; 101 static psVector *tmpRow = NULL; 102 static psVector *tmpCol = NULL; 103 static psVector *tmpMask = NULL; 104 105 if (in == NULL) { 62 106 //XXX: psErrorMsg() 63 107 } 64 if ((overscans != NULL) && 65 (overScanAxis == PM_OVERSCAN_NONE)) { 108 109 if ((overscans == NULL) && (overScanAxis != PM_OVERSCAN_NONE)) { 110 //XXX: psErrorMsg() 111 } 112 if ((overscans != NULL) && (overScanAxis == PM_OVERSCAN_NONE)) { 66 113 //XXX: psWarningMsg() 67 psSubtractFrame(in, bias); 68 } 114 return(psSubtractFrame(in, bias)); 115 } 116 69 117 if (overScanAxis == PM_OVERSCAN_ALL) { 70 psImageStats( in->image..., stat);71 p sSubtractScalarFromImage(...);72 return( )?118 psImageStats(stat, in->image, in->mask, 0xffffffff); 119 p_psImageSubtractScalar(in->image, stat->value); 120 return(in) 73 121 } 122 74 123 if (((overScanAxis == PM_OVERSCAN_NONE) || 75 124 (overScanAxis == PM_OVERSCAN_ALL)) && … … 77 126 //XXX: psWarningMsg() 78 127 //XXX: Then what? 79 } 80 if (overScanAxis == PM_OVERSCAN_ROW) { 81 myVec = reduce the overscan area to a vector 82 } 83 if (overScanAxis == PM_OVERSCAN_COL) { 84 myVec = reduce the overscan area to a vector 85 } 86 if (nBin > 0) { 87 psVector *myBin = psVectorAlloc(nBin, PS_TYPE_F32); 88 } 89 if (!((fitSpec == NULL) || (fit ==PM_FIT_NONE))) { 90 fit the vector to a linear or cubic spline. 91 } 92 93 if (overScanAxis == PM_OVERSCAN_ROW) { 94 for (i=0;i<rows;i++) 95 for (j=0;j<cols;j++) 96 image[i][j]-= myBin[i]; 97 } 98 if (overScanAxis == PM_OVERSCAN_COLUMN) { 99 for (i=0;i<rows;i++) 100 for (j=0;j<cols;j++) 101 image[i][j]-= myBin[j]; 102 } 103 return(in); 104 } 105 128 return(in) 129 } 130 131 // XXX: Is there a better way to extract a psVector from a psImage without 132 // having to copy every element in that vector? 133 134 // XXX: If we get here, do we know that overScanAxis == PM_OVERSCAN_ROW 135 // or PM_OVERSCAN_COL? 136 137 if ((overScanAxis == PM_OVERSCAN_ROW) || (overScanAxis == PM_OVERSCAN_COL)) { 138 if (overScanAxis == PM_OVERSCAN_ROW) { 139 tmp = psVectorAlloc((in->image)->numCols, PS_TYPE_F32); 140 tmpRow = psVectorAlloc((in->image)->numCols, PS_TYPE_F32); 141 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 } 150 } 151 if (overScanAxis == PM_OVERSCAN_COL) { 152 tmp = psVectorAlloc((in->image)->numRows, PS_TYPE_F32); 153 tmpcol = psVectorAlloc((in->image)->numRows, PS_TYPE_F32); 154 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); 167 psVector *myBin = psVectorAlloc(numBins, PS_TYPE_F32); 168 169 for (i=0;i<numBins;i++) { 170 // XXX: do this 171 } 172 // XXX: resize tmp to myBin, and store myBin elements there. 173 } else { 174 nBin = 1; 175 } 176 177 if (!((fitSpec == NULL) || (fit ==PM_FIT_NONE))) { 178 fit the vector to a linear or cubic spline. 179 } 180 181 if (overScanAxis == PM_OVERSCAN_ROW) { 182 for (i=0;i<(in->image)->numCols;i++) { 183 for (j=0;j<(in->image)->numRows;j++) { 184 (in->image)->data.F32[i][j]-= tmp->data.F32[j/nBin]; 185 } 186 } 187 } 188 189 if (overScanAxis == PM_OVERSCAN_COLUMN) { 190 for (i=0;i<(in->image)->numRows;i++) { 191 for (j=0;j<(in->image)->numCols;j++) { 192 (in->image)->data.F32[i][j]-= tmp->data.F32[j/nBin]; 193 } 194 } 195 } 196 return(in); 197 } 198 199 if (bias != NULL) { 200 return(psSubtractFrame(in, bias)); 201 } 202 203 // XXX: psErrorMsg(): Shouldn't get here? 204 } 205
Note:
See TracChangeset
for help on using the changeset viewer.
