Changeset 18893 for trunk/psModules/src/detrend/pmShutterCorrection.c
- Timestamp:
- Aug 4, 2008, 3:24:47 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmShutterCorrection.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmShutterCorrection.c
r18860 r18893 14 14 #include "pmConceptsAverage.h" 15 15 #include "pmReadoutStack.h" 16 #include "pmDetrendThreads.h" 16 17 17 18 #include "pmShutterCorrection.h" … … 655 656 656 657 658 bool pmShutterCorrectionApplyScan_Threaded (psThreadJob *job) { 659 psImage *image = job->args->data[0]; 660 psImage *shutterImage = job->args->data[1]; 661 psImage *mask = job->args->data[2]; 662 663 float exptime = PS_SCALAR_VALUE(job->args->data[3],F32); 664 psMaskType blank = PS_SCALAR_VALUE(job->args->data[4],U8); 665 int rowStart = PS_SCALAR_VALUE(job->args->data[5],S32); 666 int rowStop = PS_SCALAR_VALUE(job->args->data[6],S32); 667 bool status = pmShutterCorrectionApplyScan (image, shutterImage, mask, exptime, blank, rowStart, rowStop); 668 return status; 669 } 670 671 bool pmShutterCorrectionApplyScan(psImage *image, psImage *shutterImage, psImage *mask, float exptime, psMaskType blank, int rowStart, int rowStop) 672 { 673 for (int y = rowStart; y < rowStop; y++) { 674 for (int x = 0; x < image->numCols; x++) { 675 if (mask && !isfinite(shutterImage->data.F32[y][x])) { 676 mask->data.PS_TYPE_MASK_DATA[y][x] |= blank; 677 image->data.F32[y][x] = NAN; 678 continue; 679 } 680 image->data.F32[y][x] *= exptime / (exptime + shutterImage->data.F32[y][x]); 681 } 682 } 683 return true; 684 } 685 657 686 bool pmShutterCorrectionApply(pmReadout *readout, const pmReadout *shutter, psMaskType blank) 658 687 { … … 700 729 psImage *image = readout->image; // Image to correct 701 730 psImage *mask = readout->mask; // Corresponding mask 731 732 bool threaded = true; 733 int scanRows = pmDetrendGetScanRows(); 734 if (scanRows == 0) { 735 threaded = false; 736 scanRows = image->numRows; 737 } 702 738 703 739 if (exptime <= 0.0) { … … 720 756 psFree (line); 721 757 } else { 722 for (int y = 0; y < image->numRows; y++) { 723 for (int x = 0; x < image->numCols; x++) { 724 if (mask && !isfinite(shutterImage->data.F32[y][x])) { 725 mask->data.PS_TYPE_MASK_DATA[y][x] |= blank; 726 image->data.F32[y][x] = NAN; 727 continue; 728 } 729 image->data.F32[y][x] *= exptime / (exptime + shutterImage->data.F32[y][x]); 730 } 731 } 758 for (int rowStart = 0; rowStart < image->numRows; rowStart += scanRows) { 759 int rowStop = PS_MIN (rowStart + scanRows, image->numRows); 760 761 # define PS_ARRAY_ADD_SCALAR(ARRAY, VALUE, TYPE) { \ 762 psScalar *scalar = psScalarAlloc(VALUE, TYPE); \ 763 psArrayAdd(ARRAY, 1, scalar); \ 764 psFree (scalar); } 765 766 if (threaded) { 767 // allocate a job, construct the arguments for this job 768 psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_SHUTTER"); 769 psArrayAdd (job->args, 1, image); 770 psArrayAdd (job->args, 1, shutterImage); 771 psArrayAdd (job->args, 1, mask); 772 PS_ARRAY_ADD_SCALAR (job->args, exptime, PS_TYPE_F32); 773 PS_ARRAY_ADD_SCALAR (job->args, blank, PS_TYPE_MASK); 774 PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32); 775 PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32); 776 777 // ppImageDetrendReadout(config, options, view) 778 if (!psThreadJobAddPending (job)) { 779 return false; 780 } 781 } else { 782 pmShutterCorrectionApplyScan (image, shutterImage, mask, exptime, blank, rowStart, rowStop); 783 } 784 } 785 if (threaded) { 786 // wait here for the threaded jobs to finish 787 if (!psThreadPoolWait ()) { 788 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 789 return false; 790 } 791 fprintf (stderr, "success for threaded jobs\n"); 792 793 // free the done jobs 794 psThreadJob *job = NULL; 795 while ((job = psThreadJobGetDone()) != NULL) { 796 psFree (job); 797 } 798 } 732 799 } 733 800 psFree(shutterImage);
Note:
See TracChangeset
for help on using the changeset viewer.
