Changeset 21183 for trunk/psModules/src/detrend/pmShutterCorrection.c
- Timestamp:
- Jan 26, 2009, 8:40:07 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmShutterCorrection.c
r19432 r21183 198 198 pmShutterCorrection *pmShutterCorrectionLinFit(const psVector *exptime, const psVector *counts, 199 199 const psVector *cntError, const psVector *mask, float offref, 200 int nIter, float rej , psMaskType maskVal)200 int nIter, float rej) 201 201 { 202 202 PS_ASSERT_VECTOR_NON_NULL(exptime, NULL); … … 241 241 stats->clipIter = nIter; 242 242 243 if (!psVectorClipFitPolynomial2D(line, stats, mask, maskVal, counts, cntError, x, y)) {243 if (!psVectorClipFitPolynomial2D(line, stats, mask, 0xff, counts, cntError, x, y)) { 244 244 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to fit shutter correction.\n"); 245 245 psFree(stats); … … 371 371 372 372 bool pmShutterCorrectionMeasure(pmReadout *output, const psArray *readouts, int size, psStatsOptions meanStat, 373 psStatsOptions stdevStat, int nIter, float rej, ps MaskType maskVal)373 psStatsOptions stdevStat, int nIter, float rej, psImageMaskType maskVal) 374 374 { 375 375 PS_ASSERT_ARRAY_NON_NULL(readouts, NULL); … … 457 457 masks->data[i] = psMemIncrRefCounter(mask); 458 458 459 if (mask->type.type != PS_TYPE_ U8) {459 if (mask->type.type != PS_TYPE_IMAGE_MASK) { 460 460 psError(PS_ERR_BAD_PARAMETER_TYPE, true, "Bad type for mask: %x\n", mask->type.type); 461 461 goto MEASURE_ERROR; … … 582 582 psImage *shutter = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Shutter correction image 583 583 psImage *pattern = psImageAlloc(numCols, numRows, PS_TYPE_F32); // Illumination pattern 584 psVector *mask = psVectorAlloc(num, PS_TYPE_ U8); // Mask for each image584 psVector *mask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for each image 585 585 psVectorInit(mask, 0); 586 586 psTrace("psModules.detrend", 2, "Performing linear fit on individual pixels...\n"); … … 592 592 psImage *maskImage; // Mask image 593 593 if (masks && (maskImage = masks->data[i])) { 594 mask->data. U8[i] = maskImage->data.U8[y][x];594 mask->data.PS_TYPE_VECTOR_MASK_DATA[i] = (maskImage->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal); 595 595 } 596 596 psImage *weight; // Weight image … … 602 602 } 603 603 604 pmShutterCorrection *corr = pmShutterCorrectionLinFit(exptimes, counts, errors, mask, meanRef, 605 nIter, rej, maskVal); 604 pmShutterCorrection *corr = pmShutterCorrectionLinFit(exptimes, counts, errors, mask, meanRef, nIter, rej); 606 605 shutter->data.F32[y][x] = corr->offset; 607 606 pattern->data.F32[y][x] = corr->scale; … … 665 664 666 665 float exptime = PS_SCALAR_VALUE(job->args->data[3],F32); 667 ps MaskType blank = PS_SCALAR_VALUE(job->args->data[4],U8);666 psImageMaskType blank = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 668 667 int rowStart = PS_SCALAR_VALUE(job->args->data[5],S32); 669 668 int rowStop = PS_SCALAR_VALUE(job->args->data[6],S32); … … 672 671 673 672 bool pmShutterCorrectionApplyScan(psImage *image, const psImage *shutterImage, psImage *mask, float exptime, 674 ps MaskType blank, int rowStart, int rowStop)673 psImageMaskType blank, int rowStart, int rowStop) 675 674 { 676 675 for (int y = rowStart; y < rowStop; y++) { 677 676 for (int x = 0; x < image->numCols; x++) { 678 677 if (mask && !isfinite(shutterImage->data.F32[y][x])) { 679 mask->data.PS_TYPE_ MASK_DATA[y][x] |= blank;678 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= blank; 680 679 image->data.F32[y][x] = NAN; 681 680 continue; … … 687 686 } 688 687 689 bool pmShutterCorrectionApply(pmReadout *readout, const pmReadout *shutter, ps MaskType blank)688 bool pmShutterCorrectionApply(pmReadout *readout, const pmReadout *shutter, psImageMaskType blank) 690 689 { 691 690 PS_ASSERT_PTR_NON_NULL(readout, false); … … 746 745 for (int x = 0; x < image->numCols; x++) { 747 746 if (mask && !isfinite(shutterImage->data.F32[y][x])) { 748 mask->data.PS_TYPE_ MASK_DATA[y][x] |= blank;747 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= blank; 749 748 image->data.F32[y][x] = NAN; 750 749 continue; … … 770 769 psArrayAdd(job->args, 1, mask); 771 770 PS_ARRAY_ADD_SCALAR(job->args, exptime, PS_TYPE_F32); 772 PS_ARRAY_ADD_SCALAR(job->args, blank, PS_TYPE_ MASK);771 PS_ARRAY_ADD_SCALAR(job->args, blank, PS_TYPE_IMAGE_MASK); 773 772 PS_ARRAY_ADD_SCALAR(job->args, rowStart, PS_TYPE_S32); 774 773 PS_ARRAY_ADD_SCALAR(job->args, rowStop, PS_TYPE_S32); … … 860 859 psStatsOptions meanStat, ///< Statistic to use for mean 861 860 psStatsOptions stdevStat, ///< Statistic to use for stdev 862 ps MaskType maskVal, ///< Mask value861 psImageMaskType maskVal, ///< Mask value 863 862 psRandom *rng ///< Random number generator 864 863 ) … … 876 875 if (readout->mask) { 877 876 PS_ASSERT_IMAGE_NON_NULL(readout->mask, NULL); 878 PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_ MASK, NULL);877 PS_ASSERT_IMAGE_TYPE(readout->mask, PS_TYPE_IMAGE_MASK, NULL); 879 878 PS_ASSERT_IMAGE_SIZE(readout->mask, data->numCols, data->numRows, NULL); 880 879 } … … 1022 1021 1023 1022 bool pmShutterCorrectionGeneratePrepare(pmReadout *shutter, pmReadout *pattern, const psArray *inputs, 1024 ps MaskType maskVal)1023 psImageMaskType maskVal) 1025 1024 { 1026 1025 PS_ASSERT_PTR_NON_NULL(shutter, false); … … 1084 1083 bool pmShutterCorrectionGenerate(pmReadout *shutter, pmReadout *pattern, const psArray *inputs, 1085 1084 float reference, const pmShutterCorrectionData *data, 1086 int nIter, float rej, ps MaskType maskVal)1085 int nIter, float rej, psImageMaskType maskVal) 1087 1086 { 1088 1087 PS_ASSERT_PTR_NON_NULL(shutter, false); … … 1116 1115 psVector *counts = psVectorAlloc(num, PS_TYPE_F32); // Counts in each image 1117 1116 psVector *errors = psVectorAlloc(num, PS_TYPE_F32); // Counts in each image 1118 psVector *mask = psVectorAlloc(num, PS_TYPE_ MASK); // Mask for each image1117 psVector *mask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for each image 1119 1118 psTrace("psModules.detrend", 2, "Performing linear fit on individual pixels...\n"); 1120 1119 for (int i = minInputRows; i < maxInputRows; i++) { … … 1132 1131 counts->data.F32[r] = image->data.F32[yIn][xIn] * ref; 1133 1132 if (readout->mask) { 1134 mask->data.PS_TYPE_ MASK_DATA[r] = readout->mask->data.PS_TYPE_MASK_DATA[yIn][xIn];1133 mask->data.PS_TYPE_VECTOR_MASK_DATA[r] = (readout->mask->data.PS_TYPE_IMAGE_MASK_DATA[yIn][xIn] & maskVal); 1135 1134 } 1136 1135 if (readout->weight) { … … 1142 1141 } 1143 1142 1144 pmShutterCorrection *corr = pmShutterCorrectionLinFit(data->exptimes, counts, errors, mask, 1145 reference, nIter, rej, maskVal); 1143 pmShutterCorrection *corr = pmShutterCorrectionLinFit(data->exptimes, counts, errors, mask, reference, nIter, rej); 1146 1144 if (!corr) { 1147 1145 // Nothing we can do about it
Note:
See TracChangeset
for help on using the changeset viewer.
