Changeset 26893 for trunk/psModules/src/camera/pmFPAMaskWeight.c
- Timestamp:
- Feb 10, 2010, 7:34:39 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAMaskWeight.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAMaskWeight.c
r26076 r26893 370 370 371 371 psImage *image = readout->image, *mask = readout->mask, *variance = readout->variance; // Readout parts 372 373 372 int numCols = image->numCols, numRows = image->numRows; // Size of image 374 int numPix = numCols * numRows; // Number of pixels 375 int num = PS_MAX(sample, numPix); // Number we care about 373 374 int xMin, xMax, yMin, yMax; // Bounds of image 375 if (mask) { 376 xMin = numCols; 377 xMax = 0; 378 yMin = numRows; 379 yMax = 0; 380 for (int y = 0; y < numRows; y++) { 381 for (int x = 0; x < numCols; x++) { 382 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 383 continue; 384 } 385 xMin = PS_MIN(xMin, x); 386 xMax = PS_MAX(xMax, x); 387 yMin = PS_MIN(yMin, y); 388 yMax = PS_MAX(yMax, y); 389 } 390 } 391 } else { 392 xMin = 0; 393 xMax = numCols; 394 yMin = 0; 395 yMax = numRows; 396 } 397 398 int xNum = xMax - xMin, yNum = yMax - yMin; // Number of pixels 399 400 int numPix = xNum * yNum; // Number of pixels 401 int num = PS_MIN(sample, numPix); // Number we care about 376 402 psVector *signoise = psVectorAllocEmpty(num, PS_TYPE_F32); // Signal-to-noise values 377 403 … … 379 405 // We have an image smaller than Nsubset, so just loop over the image pixels 380 406 int index = 0; // Index for vector 381 for (int y = 0; y < numRows; y++) {382 for (int x = 0; x < numCols; x++) {407 for (int y = yMin; y < yMax; y++) { 408 for (int x = xMin; x < xMax; x++) { 383 409 if ((mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) || 384 410 !isfinite(image->data.F32[y][x]) || !isfinite(variance->data.F32[y][x])) { … … 397 423 // Pixel coordinates 398 424 int pixel = numPix * psRandomUniform(rng); 399 int x = pixel % numCols;400 int y = pixel / numCols;425 int x = xMin + pixel % xNum; 426 int y = yMin + pixel / xNum; 401 427 402 428 if ((mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) || … … 428 454 // Check valid range of correction factor 429 455 if ((isfinite(minValid) && correction < minValid) || (isfinite(maxValid) && correction > maxValid)) { 430 psWarning("Variance renormalisation is outside valid range: %f vs %f:%f --- no correction made", 431 correction, minValid, maxValid); 432 return true; 433 } 434 435 psBinaryOp(variance, variance, "*", psScalarAlloc(PS_SQR(correction), PS_TYPE_F32)); 456 psError(PS_ERR_UNKNOWN, true, "Variance renormalisation is outside valid range: %f vs %f:%f --- no correction made", correction, minValid, maxValid); 457 psMetadataAddF32(readout->analysis, PS_LIST_TAIL, PM_READOUT_ANALYSIS_RENORM, 0, "Renormalisation of variance", PS_SQR(correction)); 458 return false; 459 } 460 461 psImage *subImage = psImageSubset(variance, psRegionSet(xMin, xMax, yMin, yMax)); // Smaller image 462 psBinaryOp(subImage, subImage, "*", psScalarAlloc(PS_SQR(correction), PS_TYPE_F32)); 463 psFree(subImage); 436 464 437 465 pmHDU *hdu = pmHDUFromReadout(readout); // HDU for readout
Note:
See TracChangeset
for help on using the changeset viewer.
