Changeset 2286
- Timestamp:
- Nov 4, 2004, 4:45:42 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/pmReadoutCombine.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/pmReadoutCombine.c
r2282 r2286 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 5$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-11-0 4 20:52:17$7 * @version $Revision: 1.6 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-11-05 02:45:42 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 55 55 PS_PTR_CHECK_NULL(inputs, NULL); 56 56 PS_PTR_CHECK_NULL(params, NULL); 57 //unsigned int maskVal = params->maskVal;57 unsigned int maskVal = params->maskVal; 58 58 psStats *stats = params->stats; 59 59 int i; 60 60 int j; 61 int numInputCols = -1;62 int numInputRows = -1;63 61 int maxInputCols = 0; 64 62 int maxInputRows = 0; … … 69 67 psReadout *tmpReadout; 70 68 float tmpF; 69 71 70 72 71 // … … 92 91 minInputRows = PS_MIN(minInputRows, 93 92 (tmpReadout->row0 + tmpReadout->image->row0)); 93 tmpF = tmpReadout->row0 + 94 tmpReadout->image->row0 + 95 tmpReadout->image->numRows; 96 maxInputRows = PS_MAX(maxInputRows, tmpF); 97 98 minInputCols = PS_MIN(minInputCols, 99 (tmpReadout->col0 + tmpReadout->image->col0)); 94 100 tmpF = tmpReadout->col0 + 95 101 tmpReadout->image->col0 + 96 102 tmpReadout->image->numCols; 97 103 maxInputCols = PS_MAX(maxInputCols, tmpF); 98 99 minInputCols = PS_MIN(minInputCols,100 (tmpReadout->col0 + tmpReadout->image->col0));101 tmpF = tmpReadout->row0 +102 tmpReadout->image->row0 +103 tmpReadout->image->numRows;104 maxInputRows = PS_MAX(maxInputRows, tmpF);105 104 tmpInput = tmpInput->next; 106 105 numInputs++; 107 106 } 108 107 108 // We ensure that the zero vector is of the proper size. 109 if (zero != NULL) { 110 PS_VECTOR_CHECK_TYPE(zero, PS_TYPE_F32, NULL); 111 if (numInputs > zero->n) { 112 // XXX: ERROR: the zero vector does not have enough elements. 113 return(NULL); 114 } else if (numInputs < zero->n) { 115 // XXX: WARNING: the zero vector too many elements. 116 } 117 } 118 119 // We ensure that the scale vector is of the proper size. 120 if (scale != NULL) { 121 PS_VECTOR_CHECK_TYPE(scale, PS_TYPE_F32, NULL); 122 if (numInputs > scale->n) { 123 // XXX: ERROR: the scale vector does not have enough elements. 124 return(NULL); 125 } else if (numInputs < scale->n) { 126 // XXX: WARNING: the scale vector too many elements. 127 } 128 } 129 130 // At this point, the following variables have been computed: 131 // maxInputRows: the largest input row value, in output image space. 132 // maxInputCols: the largest input column value, in output image space. 133 // minInputRows: the smallest input row value, in output image space. 134 // minInputCols: the smallest input column value, in output image space. 135 // 109 136 if (output == NULL) { 110 output = psImageAlloc( numInputCols-minInputCols,111 numInputRows-minInputRows, PS_TYPE_F32);137 output = psImageAlloc(1+maxInputCols-minInputCols, 138 1+maxInputRows-minInputRows, PS_TYPE_F32); 112 139 *(int *) &(output->col0) = minInputCols; 113 140 *(int *) &(output->row0) = minInputRows; … … 115 142 if (((output->col0 + output->numCols) < maxInputCols) || 116 143 ((output->row0 + output->numRows) < maxInputRows)) { 117 //XXX psError(__func__,"Output image (%d, %d) is too small to hold combined images.\n",144 //XXX ERROR: "Output image (%d, %d) is too small to hold combined images.\n", 118 145 // output->row0 + output->numRows, 119 146 // output->col0 + output->numCols); … … 121 148 } 122 149 123 if ((output->col0 > minInputCols) || 124 (output->row0 > minInputRows)) { 125 //XXX psError(__func__, "Output image offset is larger then input image offset.\n"); 150 if ((output->col0 > minInputCols) || (output->row0 > minInputRows)) { 151 //XXX ERROR "Output image offset is larger then input image offset.\n"); 126 152 return(NULL); 127 153 } … … 136 162 psVector *tmpPixelMask = psVectorAlloc(numInputs, PS_TYPE_U8); 137 163 psVector *tmpPixelMaskNKeep = psVectorAlloc(numInputs, PS_TYPE_U8); 164 psVector *outRowLower = psVectorAlloc(numInputs, PS_TYPE_U32); 165 psVector *outRowUpper = psVectorAlloc(numInputs, PS_TYPE_U32); 166 psVector *outColLower = psVectorAlloc(numInputs, PS_TYPE_U32); 167 psVector *outColUpper = psVectorAlloc(numInputs, PS_TYPE_U32); 138 168 psReadout **tmpReadouts = (psReadout **) psAlloc(numInputs * sizeof(psReadout *)); 169 170 171 // For each input readout, we create a pointer to that readout in 172 // "tmpReadouts[]", and we store the min/max pixel indices for that 173 // readout, in putput image coordinates, in the psVectors 174 // (outRowLower, outColLower, outRowUpper, outColUpper). 139 175 i = 0; 140 176 while (NULL != tmpInput) { 141 177 tmpReadouts[i] = (psReadout *) tmpInput->data; 178 outRowLower->data.U32[i] = tmpReadouts[i]->row0 + tmpReadout->image->row0; 179 outColLower->data.U32[i] = tmpReadouts[i]->col0 + tmpReadout->image->col0; 180 outRowUpper->data.U32[i] = tmpReadouts[i]->row0 + 181 tmpReadouts[i]->image->row0 + 182 tmpReadouts[i]->image->numRows; 183 outColUpper->data.U32[i] = tmpReadouts[i]->col0 + 184 tmpReadouts[i]->image->col0 + 185 tmpReadouts[i]->image->numCols; 186 142 187 tmpInput = tmpInput->next; 143 188 i++; 144 } 145 146 for (i = 0; i < output->numRows ; i++) { 147 for (j = 0; j < output->numCols ; j++) { 189 190 } 191 192 // We loop through each pixel in the output image. We loop through each 193 // input readout. We determine if that output pixel is contained in the 194 // image from that readout. If so, we save it in psVector tmpPixels. 195 // If not, we set a mask for that element in tmpPixels. Then, we mask off 196 // pixels not between fracLow and fracHigh. Then we call the vector 197 // stats routine on those pixels/mask. Then we set the output pixel value 198 // to the result of the stats call. 199 for (i = output->row0; i < output->numRows ; i++) { 200 for (j = output->col0; j < output->numCols ; j++) { 148 201 for (int r = 0; r < numInputs ; r++) { 149 // if (i,j are valid for this readout) { 150 if (0) { 151 // tmpPixels->data.F32[r] = WHATEVER; 152 tmpPixelMask->data.U8[r] = 0; 202 if ((outRowLower->data.U32[r] <= i) && 203 (outColLower->data.U32[r] <= j) && 204 (outRowUpper->data.U32[r] > i) && 205 (outColUpper->data.U32[r] > j)) { 206 207 int imageRow = i - (tmpReadouts[r]->row0 + 208 tmpReadouts[i]->image->row0); 209 int imageCol = j - (tmpReadouts[r]->col0 + 210 tmpReadouts[r]->image->col0); 211 if (!(maskVal && tmpReadouts[i]->mask->data.U8[imageRow][imageCol])) { 212 tmpPixels->data.F32[r] = tmpReadouts[i]->image->data.F32[imageRow][imageCol]; 213 tmpPixelMask->data.U8[r] = 0; 214 } else { 215 tmpPixels->data.F32[r] = 0.0; 216 tmpPixelMask->data.U8[r] = 1; 217 } 153 218 } else { 154 219 tmpPixels->data.F32[r] = 0.0; … … 156 221 } 157 222 } 223 // At this point, we have scanned all input readouts for this 224 // one output pixel. 158 225 159 226 // Determine how many pixels lie between fracLow and fracHigh. … … 184 251 } 185 252 253 // XXX: Is this correct? 254 // We add the zero vector, if non-NULL. 255 if (zero != NULL) { 256 for (int r = 0; r < numInputs ; r++) { 257 tmpPixels->data.F32[r]+= zero->data.F32[r]; 258 } 259 } 260 261 // XXX: Is this correct? 262 // We scale the pixels by the scale vector, if not-NULL. 263 if (scale != NULL) { 264 for (int r = 0; r < numInputs ; r++) { 265 tmpPixels->data.F32[r]*= scale->data.F32[r]; 266 } 267 } 268 269 // XXX: Is this correct? 270 if (gain > 0.0) { 271 for (int r = 0; r < numInputs ; r++) { 272 tmpPixels->data.F32[r]*= gain; 273 } 274 } 275 276 // XXX: Is this correct? 277 if (!(readnoise < 0.0)) { 278 for (int r = 0; r < numInputs ; r++) { 279 tmpPixels->data.F32[r]+= readnoise; 280 } 281 } 282 186 283 // Calculate the specified statistic on the stack of pixels. 187 284 stats = psVectorStats(stats, … … 193 290 double statValue; 194 291 if (!p_psGetStatValue(stats, &statValue)) { 195 psError(PS_ERR_UNKNOWN,true, "Could not determine stats value.\n");292 //XXX ERROR: "Could not determine stats value.\n" 196 293 return(NULL); 197 294 } else { 198 output->data.F32[i ][j] = (float) statValue;295 output->data.F32[i-output->row0][j-output->col0] = (float) statValue; 199 296 } 200 297 } … … 205 302 psFree(tmpPixelMask); 206 303 psFree(tmpPixelMaskNKeep); 304 psFree(outRowLower); 305 psFree(outRowUpper); 306 psFree(outColLower); 307 psFree(outColUpper); 207 308 psFree(tmpReadouts); 208 309
Note:
See TracChangeset
for help on using the changeset viewer.
