Changeset 7740 for trunk/psModules/src/imcombine/pmReadoutCombine.c
- Timestamp:
- Jun 28, 2006, 2:27:51 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmReadoutCombine.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmReadoutCombine.c
r7362 r7740 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.1 6$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-06- 06 03:32:59$7 * @version $Revision: 1.17 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-06-29 00:27:51 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 126 126 long minInputCols = LONG_MAX; // The smallest input column value 127 127 long minInputRows = LONG_MAX; // The smallest input row value 128 psVector *mask = psVectorAlloc(inputs->n, PS_TYPE_U8); // Mask for stack129 mask->n = inputs->n;130 128 131 129 bool haveWeights = false; // Do we have weight images? … … 245 243 246 244 // We loop through each pixel in the output image. We loop through each input readout. We determine if 247 // that output pixel is contained in the image from that readout. If so, we save it in psVector 248 // tmpPixels. If not, we set a mask for that element in tmpPixels. Then, we mask off pixels not between249 // frac Low and fracHigh. Then we call the vector stats routine on those pixels/mask. Then we set the250 // output pixelvalue to the result of the stats call.245 // that output pixel is contained in the image from that readout. If so, we save it in psVector pixels. 246 // If not, we set a mask for that element in pixels. Then, we mask off pixels not between fracLow and 247 // fracHigh. Then we call the vector stats routine on those pixels/mask. Then we set the output pixel 248 // value to the result of the stats call. 251 249 252 250 psVector *pixels = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of pixels 253 251 pixels->n = inputs->n; 252 psF32 *pixelsData = pixels->data.F32; // Dereference pixels 253 254 psVector *mask = psVectorAlloc(inputs->n, PS_TYPE_U8); // Mask for stack 255 mask->n = inputs->n; 256 psU8 *maskData = mask->data.U8; // Dereference mask 257 254 258 psVector *weights = NULL; // Stack of weights 259 psF32 *weightsData = NULL; // Dereference weights 255 260 if (haveWeights) { 256 261 weights = psVectorAlloc(inputs->n, PS_TYPE_F32); // Stack of weights 257 262 weights->n = inputs->n; 263 weightsData = weights->data.F32; 258 264 } 259 265 psVector *index = NULL; // The indices to sort the pixels … … 274 280 } 275 281 282 // Dereference output products 283 psF32 **outputImage = output->image->data.F32; // Output image 284 psU8 **outputMask = output->mask->data.U8; // Output mask 285 psF32 **outputWeight = output->weight->data.F32; // Output weight map 286 276 287 for (int i = minInputRows; i < maxInputRows; i++) { 288 int yOut = i - output->row0; // y position on output readout 277 289 #if 0 290 278 291 if (psTraceGetLevel(__func__) > 9) { 279 292 printf("Processing row %d\r", i); … … 282 295 #endif 283 296 for (int j = minInputCols; j < maxInputCols; j++) { 297 int xOut = j - output->col0; // x position on output readout 298 284 299 int numValid = 0; // Number of valid pixels in the stack 285 memset(mask ->data.U8, 0, mask->n * sizeof(psU8)); // Reset the mask300 memset(maskData, 0, mask->n * sizeof(psU8)); // Reset the mask 286 301 for (int r = 0; r < inputs->n; r++) { 287 302 pmReadout *readout = inputs->data[r]; // Input readout … … 296 311 } 297 312 298 pixels ->data.F32[r] = image->data.F32[yIn][xIn];313 pixelsData[r] = image->data.F32[yIn][xIn]; 299 314 300 315 // Check mask 301 if (readout->mask && readout->mask->data.U8[yIn][xIn] & maskVal) { 302 mask->data.U8[r] = 1; 316 psImage *roMask = readout->mask; // The mask image 317 if (roMask && roMask->data.U8[yIn][xIn] & maskVal) { 318 maskData[r] = 1; 303 319 continue; 304 320 } … … 307 323 } 308 324 309 int yOut = i - output->row0; // y position on output readout310 int xOut = j - output->col0; // x position on output readout311 312 325 if (numValid == 0) { 313 output ->mask->data.U8[yOut][xOut] = PM_MASK_FLAT;314 output ->image->data.F32[yOut][xOut] = NAN;326 outputMask[yOut][xOut] = PM_MASK_FLAT; 327 outputImage[yOut][xOut] = NAN; 315 328 continue; 316 329 } … … 322 335 int numHigh = numValid * params->fracHigh; // Number of high pixels to clip 323 336 // Low pixels 337 psS32 *indexData = index->data.S32; // Dereference index 324 338 for (int k = 0, numMasked = 0; numMasked < numLow && k < index->n; k++) { 325 339 // Don't count the ones that are already masked 326 if (!mask ->data.U8[index->data.S32[k]]) {327 mask ->data.U8[index->data.S32[k]] = 1;340 if (!maskData[indexData[k]]) { 341 maskData[indexData[k]] = 1; 328 342 numMasked++; 329 343 } … … 332 346 for (int k = pixels->n - 1, numMasked = 0; numMasked < numHigh && k >= 0; k--) { 333 347 // Don't count the ones that are already masked 334 if (! mask ->data.U8[index->data.S32[k]]) {335 mask ->data.U8[index->data.S32[k]] = 1;348 if (! maskData[indexData[k]]) { 349 maskData[indexData[k]] = 1; 336 350 numMasked++; 337 351 } … … 341 355 // Combination 342 356 psVectorStats(stats, pixels, weights, mask, 1); 343 output ->image->data.F32[yOut][xOut] = getStat(stats, params->combine);357 outputImage[yOut][xOut] = getStat(stats, params->combine); 344 358 if (haveWeights) { 345 359 float stdev = getStat(stats, combineStdev); 346 output ->weight->data.F32[yOut][xOut] = PS_SQR(stdev); // Variance360 outputWeight[yOut][xOut] = PS_SQR(stdev); // Variance 347 361 } 348 362 }
Note:
See TracChangeset
for help on using the changeset viewer.
