Changeset 21183 for trunk/psModules/src/camera/pmFPAMaskWeight.c
- Timestamp:
- Jan 26, 2009, 8:40:07 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAMaskWeight.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAMaskWeight.c
r20749 r21183 42 42 continue; 43 43 } 44 masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_ U8);44 masks->data[i] = psImageAlloc(image->numCols, image->numRows, PS_TYPE_IMAGE_MASK); 45 45 psImageInit(masks->data[i], 0); 46 46 } … … 98 98 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 99 99 100 bool pmReadoutSetMask(pmReadout *readout, ps MaskType satMask, psMaskType badMask)100 bool pmReadoutSetMask(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask) 101 101 { 102 102 PS_ASSERT_PTR_NON_NULL(readout, false); … … 124 124 if (!readout->mask) { 125 125 // Generate a (throwaway) mask image, if required 126 readout->mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_ U8);126 readout->mask = psImageAlloc(image->numCols, image->numRows, PS_TYPE_IMAGE_MASK); 127 127 } 128 128 psImage *mask = readout->mask; // The mask pixels … … 131 131 // Dereference pointers for speed 132 132 psF32 **imageData = image->data.F32;// The image 133 ps U8 **maskData = mask->data.U8; // The mask133 psImageMaskType **maskData = mask->data.PS_TYPE_IMAGE_MASK_DATA; // The mask 134 134 135 135 for (int i = 0; i < image->numRows; i++) { … … 153 153 // pixels. currently, it will set mask bits if (value <= BAD) or (value >= SATURATION) 154 154 // should we optionally ignore these tests? 155 bool pmReadoutGenerateMask(pmReadout *readout, ps MaskType satMask, psMaskType badMask)155 bool pmReadoutGenerateMask(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask) 156 156 { 157 157 PS_ASSERT_PTR_NON_NULL(readout, false); … … 294 294 } 295 295 296 bool pmReadoutGenerateMaskWeight(pmReadout *readout, ps MaskType satMask, psMaskType badMask, bool poisson)296 bool pmReadoutGenerateMaskWeight(pmReadout *readout, psImageMaskType satMask, psImageMaskType badMask, bool poisson) 297 297 { 298 298 PS_ASSERT_PTR_NON_NULL(readout, false); … … 306 306 } 307 307 308 bool pmCellGenerateMaskWeight(pmCell *cell, ps MaskType satMask, psMaskType badMask, bool poisson)308 bool pmCellGenerateMaskWeight(pmCell *cell, psImageMaskType satMask, psImageMaskType badMask, bool poisson) 309 309 { 310 310 PS_ASSERT_PTR_NON_NULL(cell, false); … … 321 321 322 322 323 bool pmReadoutWeightRenormPixels(const pmReadout *readout, ps MaskType maskVal,323 bool pmReadoutWeightRenormPixels(const pmReadout *readout, psImageMaskType maskVal, 324 324 psStatsOptions meanStat, psStatsOptions stdevStat, psRandom *rng) 325 325 { … … 363 363 364 364 365 bool pmReadoutWeightRenormPhot(const pmReadout *readout, ps MaskType maskVal, int num, float width,365 bool pmReadoutWeightRenormPhot(const pmReadout *readout, psImageMaskType maskVal, int num, float width, 366 366 psStatsOptions meanStat, psStatsOptions stdevStat, psRandom *rng) 367 367 { … … 411 411 psVector *source = psVectorAlloc(num, PS_TYPE_F32); // Measurements of fake sources 412 412 psVector *guess = psVectorAlloc(num, PS_TYPE_F32); // Guess at significance 413 psVector *photMask = psVectorAlloc(num, PS_TYPE_ MASK); // Mask for fluxes413 psVector *photMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for fluxes 414 414 for (int i = 0; i < num; i++) { 415 415 // Coordinates of interest … … 433 433 float yGauss = gauss->data.F32[v]; // Value of Gaussian in y 434 434 for (int u = 0, x = xPix - size; u < fullSize; u++, x++) { 435 if (mask && mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal) {435 if (mask && mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 436 436 continue; 437 437 } … … 453 453 } 454 454 455 photMask->data.PS_TYPE_ MASK_DATA[i] = ((isfinite(sumNoise) && isfinite(sumSource) &&455 photMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = ((isfinite(sumNoise) && isfinite(sumSource) && 456 456 isfinite(sumWeight) && sumGauss > 0 && sumGauss2 > 0) ? 457 457 0 : 0xFF); … … 493 493 ratio->data.F32[i] = measuredSig / guess->data.F32[i]; 494 494 if (guess->data.F32[i] <= 0.0 || source->data.F32[i] <= 0.0 || !isfinite(ratio->data.F32[i])) { 495 photMask->data.PS_TYPE_ MASK_DATA[i] = 0xFF;495 photMask->data.PS_TYPE_VECTOR_MASK_DATA[i] = 0xFF; 496 496 } 497 497 psTrace("psModules.camera", 9, "Ratio %d: %f, %f, %f\n", … … 523 523 524 524 525 bool pmReadoutWeightRenorm(const pmReadout *readout, ps MaskType maskVal, psStatsOptions meanStat,525 bool pmReadoutWeightRenorm(const pmReadout *readout, psImageMaskType maskVal, psStatsOptions meanStat, 526 526 psStatsOptions stdevStat, int width, psRandom *rng) 527 527 { … … 591 591 592 592 593 bool pmReadoutMaskNonfinite(pmReadout *readout, ps MaskType maskVal)593 bool pmReadoutMaskNonfinite(pmReadout *readout, psImageMaskType maskVal) 594 594 { 595 595 PM_ASSERT_READOUT_NON_NULL(readout, false); … … 601 601 602 602 if (!readout->mask) { 603 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_ MASK);603 readout->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK); 604 604 } 605 605 psImage *mask = readout->mask; // Readout's mask … … 608 608 for (int x = 0; x < numCols; x++) { 609 609 if (!isfinite(image->data.F32[y][x]) || (weight && !isfinite(weight->data.F32[y][x]))) { 610 mask->data.PS_TYPE_ MASK_DATA[y][x] |= maskVal;610 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= maskVal; 611 611 } 612 612 } … … 618 618 619 619 620 bool pmReadoutMaskApply(pmReadout *readout, ps MaskType maskVal)620 bool pmReadoutMaskApply(pmReadout *readout, psImageMaskType maskVal) 621 621 { 622 622 PM_ASSERT_READOUT_NON_NULL(readout, false); … … 625 625 626 626 int numCols = readout->image->numCols, numRows = readout->image->numRows; // Size of image 627 ps MaskType **maskData = readout->mask->data.PS_TYPE_MASK_DATA; // Dereference mask627 psImageMaskType **maskData = readout->mask->data.PS_TYPE_IMAGE_MASK_DATA; // Dereference mask 628 628 psF32 **imageData = readout->image->data.F32;// Dereference image 629 629 psF32 **weightData = readout->weight ? readout->weight->data.F32 : NULL; // Dereference weight map … … 644 644 645 645 646 bool pmReadoutInterpolateBadPixels(pmReadout *readout, ps MaskType maskVal, psImageInterpolateMode mode,647 float poorFrac, ps MaskType maskPoor, psMaskType maskBad)646 bool pmReadoutInterpolateBadPixels(pmReadout *readout, psImageMaskType maskVal, psImageInterpolateMode mode, 647 float poorFrac, psImageMaskType maskPoor, psImageMaskType maskBad) 648 648 { 649 649 PM_ASSERT_READOUT_NON_NULL(readout, false); … … 667 667 psVector *imagePix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_F32); // Corresponding values for image 668 668 psVector *weightPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_F32); // Corresponding values for weight 669 psVector *maskPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_MASK); // Corresponding values for mask 669 psVector *maskPix = psVectorAllocEmpty(PIXELS_BUFFER, PS_TYPE_IMAGE_MASK); // Corresponding values for mask 670 // NOTE: maskPix carries the actual image mask values -- do NOT use 671 // PS_TYPE_VECTOR_MASK here; it is storage, and is not treated as a vector mask 670 672 671 673 long numBad = 0; // Number of bad pixels interpolated 672 674 for (int y = 0; y < numRows; y++) { 673 675 for (int x = 0; x < numCols; x++) { 674 if (mask->data.PS_TYPE_ MASK_DATA[y][x] & maskVal) {676 if (mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal) { 675 677 double imageValue, weightValue; // Image and weight value from interpolation 676 psMaskType maskValue = 0; // Mask value from interpolation 677 psImageInterpolateStatus status = psImageInterpolate(&imageValue, &weightValue, &maskValue, 678 x, y, interp); 678 psImageMaskType maskValue = 0; // Mask value from interpolation 679 psImageInterpolateStatus status = psImageInterpolate(&imageValue, &weightValue, &maskValue, x, y, interp); 679 680 if (status == PS_INTERPOLATE_STATUS_ERROR || status == PS_INTERPOLATE_STATUS_OFF) { 680 681 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate readout at %d,%d", x, y); … … 697 698 imagePix->data.F32[numBad] = imageValue; 698 699 weightPix->data.F32[numBad] = weightValue; 699 maskPix->data.PS_TYPE_ MASK_DATA[numBad] = maskValue;700 maskPix->data.PS_TYPE_IMAGE_MASK_DATA[numBad] = maskValue; 700 701 numBad++; 701 702 } … … 709 710 image->data.F32[y][x] = imagePix->data.F32[i]; 710 711 weight->data.F32[y][x] = weightPix->data.F32[i]; 711 mask->data.PS_TYPE_ MASK_DATA[y][x] = maskPix->data.PS_TYPE_MASK_DATA[i];712 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] = maskPix->data.PS_TYPE_IMAGE_MASK_DATA[i]; 712 713 } 713 714
Note:
See TracChangeset
for help on using the changeset viewer.
