Changeset 21457 for trunk/psModules/src/detrend/pmShutterCorrection.c
- Timestamp:
- Feb 12, 2009, 9:33:30 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmShutterCorrection.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmShutterCorrection.c
r21363 r21457 659 659 PS_ASSERT_THREAD_JOB_NON_NULL(job, false); 660 660 661 psImage *image = job->args->data[0]; 662 const psImage *shutterImage = job->args->data[1]; 663 psImage *mask = job->args->data[2]; 664 665 float exptime = PS_SCALAR_VALUE(job->args->data[3],F32); 666 psImageMaskType blank = PS_SCALAR_VALUE(job->args->data[4],PS_TYPE_IMAGE_MASK_DATA); 667 int rowStart = PS_SCALAR_VALUE(job->args->data[5],S32); 668 int rowStop = PS_SCALAR_VALUE(job->args->data[6],S32); 669 return pmShutterCorrectionApplyScan (image, shutterImage, mask, exptime, blank, rowStart, rowStop); 670 } 671 672 bool pmShutterCorrectionApplyScan(psImage *image, const psImage *shutterImage, psImage *mask, float exptime, 661 psImage *image = job->args->data[0]; 662 psImage *mask = job->args->data[1]; 663 psImage *var = job->args->data[2]; 664 const psImage *shutterImage = job->args->data[3]; 665 666 float exptime = PS_SCALAR_VALUE(job->args->data[4], F32); 667 psImageMaskType blank = PS_SCALAR_VALUE(job->args->data[5], PS_TYPE_IMAGE_MASK_DATA); 668 int rowStart = PS_SCALAR_VALUE(job->args->data[6], S32); 669 int rowStop = PS_SCALAR_VALUE(job->args->data[7], S32); 670 return pmShutterCorrectionApplyScan(image, mask, var, shutterImage, exptime, blank, rowStart, rowStop); 671 } 672 673 bool pmShutterCorrectionApplyScan(psImage *image, psImage *mask, psImage *var, 674 const psImage *shutterImage, float exptime, 673 675 psImageMaskType blank, int rowStart, int rowStop) 674 676 { 677 // Neglecting asserts because inputs should have been checked already 678 679 int numCols = image->numCols; // Number of columns 680 675 681 for (int y = rowStart; y < rowStop; y++) { 676 for (int x = 0; x < image->numCols; x++) {682 for (int x = 0; x < numCols; x++) { 677 683 if (mask && !isfinite(shutterImage->data.F32[y][x])) { 678 684 mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= blank; 679 685 image->data.F32[y][x] = NAN; 686 if (var) { 687 var->data.F32[y][x] = NAN; 688 } 680 689 continue; 681 690 } 682 image->data.F32[y][x] *= exptime / (exptime + shutterImage->data.F32[y][x]); 691 float correction = exptime / (exptime + shutterImage->data.F32[y][x]); // Correction factor 692 image->data.F32[y][x] *= correction; 693 if (var) { 694 var->data.F32[y][x] *= PS_SQR(correction); 695 } 683 696 } 684 697 } … … 688 701 bool pmShutterCorrectionApply(pmReadout *readout, const pmReadout *shutter, psImageMaskType blank) 689 702 { 690 PS_ASSERT_PTR_NON_NULL(readout, false); 691 PS_ASSERT_PTR_NON_NULL(shutter, false); 692 PS_ASSERT_IMAGE_NON_NULL(readout->image, false); 693 PS_ASSERT_IMAGE_NON_NULL(shutter->image, false); 694 PS_ASSERT_IMAGE_TYPE(readout->image, PS_TYPE_F32, false); 695 PS_ASSERT_IMAGE_TYPE(shutter->image, PS_TYPE_F32, false); 703 PM_ASSERT_READOUT_NON_NULL(readout, false); 704 PM_ASSERT_READOUT_NON_NULL(shutter, false); 705 PM_ASSERT_READOUT_IMAGE(readout, false); 706 PM_ASSERT_READOUT_IMAGE(shutter, false); 696 707 697 708 psRegion region = psRegionSet(readout->col0, readout->col0 + readout->image->numCols, … … 731 742 psImage *image = readout->image; // Image to correct 732 743 psImage *mask = readout->mask; // Corresponding mask 744 psImage *var = readout->variance; // Corresponding variance map 733 745 734 746 bool threaded = true; … … 766 778 psThreadJob *job = psThreadJobAlloc("PSMODULES_DETREND_SHUTTER"); 767 779 psArrayAdd(job->args, 1, image); 780 psArrayAdd(job->args, 1, mask); 781 psArrayAdd(job->args, 1, var); 768 782 psArrayAdd(job->args, 1, shutterImage); 769 psArrayAdd(job->args, 1, mask);770 783 PS_ARRAY_ADD_SCALAR(job->args, exptime, PS_TYPE_F32); 771 784 PS_ARRAY_ADD_SCALAR(job->args, blank, PS_TYPE_IMAGE_MASK); … … 778 791 } 779 792 psFree(job); 780 } else if (!pmShutterCorrectionApplyScan(image, shutterImage, mask, exptime, blank,793 } else if (!pmShutterCorrectionApplyScan(image, mask, var, shutterImage, exptime, blank, 781 794 rowStart, rowStop)) { 782 795 psError(PS_ERR_UNKNOWN, false, "Unable to apply shutter correction.");
Note:
See TracChangeset
for help on using the changeset viewer.
