Changeset 19432 for trunk/psModules/src/detrend/pmShutterCorrection.c
- Timestamp:
- Sep 8, 2008, 6:10:14 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmShutterCorrection.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmShutterCorrection.c
r19299 r19432 661 661 662 662 psImage *image = job->args->data[0]; 663 psImage *shutterImage = job->args->data[1];663 const psImage *shutterImage = job->args->data[1]; 664 664 psImage *mask = job->args->data[2]; 665 665 … … 668 668 int rowStart = PS_SCALAR_VALUE(job->args->data[5],S32); 669 669 int rowStop = PS_SCALAR_VALUE(job->args->data[6],S32); 670 bool status =pmShutterCorrectionApplyScan (image, shutterImage, mask, exptime, blank, rowStart, rowStop);671 return status; 672 } 673 674 bool pmShutterCorrectionApplyScan(psImage *image, psImage *shutterImage, psImage *mask, float exptime,psMaskType blank, int rowStart, int rowStop)670 return pmShutterCorrectionApplyScan (image, shutterImage, mask, exptime, blank, rowStart, rowStop); 671 } 672 673 bool pmShutterCorrectionApplyScan(psImage *image, const psImage *shutterImage, psImage *mask, float exptime, 674 psMaskType blank, int rowStart, int rowStop) 675 675 { 676 676 for (int y = rowStart; y < rowStop; y++) { … … 753 753 } 754 754 } 755 psMetadataAddF32 (cell->concepts, PS_LIST_TAIL, "CELL.EXPOSURE", PS_META_REPLACE, "exposure time re-normalized to 1.0", 1.0); // Exposure time 755 psMetadataAddF32(cell->concepts, PS_LIST_TAIL, "CELL.EXPOSURE", PS_META_REPLACE, 756 "exposure time re-normalized to 1.0", 1.0); // Exposure time 756 757 psString line = NULL; 757 psStringAppend (&line, "extreme exposure time %f, re-normalized to 1.0", exptime);758 psStringAppend(&line, "extreme exposure time %f, re-normalized to 1.0", exptime); 758 759 psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK, line, ""); 759 psFree (line);760 psFree(line); 760 761 } else { 761 762 for (int rowStart = 0; rowStart < image->numRows; rowStart += scanRows) { … … 764 765 if (threaded) { 765 766 // allocate a job, construct the arguments for this job 766 psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_SHUTTER"); 767 psArrayAdd (job->args, 1, image); 768 psArrayAdd (job->args, 1, shutterImage); 769 psArrayAdd (job->args, 1, mask); 770 PS_ARRAY_ADD_SCALAR (job->args, exptime, PS_TYPE_F32); 771 PS_ARRAY_ADD_SCALAR (job->args, blank, PS_TYPE_MASK); 772 PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32); 773 PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32); 774 775 // ppImageDetrendReadout(config, options, view) 776 if (!psThreadJobAddPending (job)) { 767 psThreadJob *job = psThreadJobAlloc("PSMODULES_DETREND_SHUTTER"); 768 psArrayAdd(job->args, 1, image); 769 psArrayAdd(job->args, 1, shutterImage); 770 psArrayAdd(job->args, 1, mask); 771 PS_ARRAY_ADD_SCALAR(job->args, exptime, PS_TYPE_F32); 772 PS_ARRAY_ADD_SCALAR(job->args, blank, PS_TYPE_MASK); 773 PS_ARRAY_ADD_SCALAR(job->args, rowStart, PS_TYPE_S32); 774 PS_ARRAY_ADD_SCALAR(job->args, rowStop, PS_TYPE_S32); 775 776 if (!psThreadJobAddPending(job)) { 777 777 psFree(job); 778 778 return false; 779 779 } 780 780 psFree(job); 781 } else { 782 pmShutterCorrectionApplyScan (image, shutterImage, mask, exptime, blank, rowStart, rowStop); 781 } else if (!pmShutterCorrectionApplyScan(image, shutterImage, mask, exptime, blank, 782 rowStart, rowStop)) { 783 psError(PS_ERR_UNKNOWN, false, "Unable to apply shutter correction."); 784 psFree(shutterImage); 785 return false; 783 786 } 784 787 } 785 788 if (threaded) { 786 789 // wait here for the threaded jobs to finish 787 if (!psThreadPoolWait(false)) { 788 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 790 if (!psThreadPoolWait(true)) { 791 psError(PS_ERR_UNKNOWN, false, "Unable to apply shutter correction."); 792 psFree(shutterImage); 789 793 return false; 790 }791 fprintf (stderr, "success for threaded jobs\n");792 793 // free the done jobs794 psThreadJob *job = NULL;795 while ((job = psThreadJobGetDone()) != NULL) {796 psFree (job);797 794 } 798 795 } … … 1024 1021 } 1025 1022 1026 bool pmShutterCorrectionGeneratePrepare(pmReadout *shutter, pmReadout *pattern, const psArray *inputs, psMaskType maskVal) 1023 bool pmShutterCorrectionGeneratePrepare(pmReadout *shutter, pmReadout *pattern, const psArray *inputs, 1024 psMaskType maskVal) 1027 1025 { 1028 1026 PS_ASSERT_PTR_NON_NULL(shutter, false); … … 1043 1041 } 1044 1042 1045 psImage *nums = pmReadoutSetAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_COUNT, numCols, numRows, PS_TYPE_U16, 0); // Image with number fitted per pixel 1043 psImage *nums = pmReadoutSetAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_COUNT, numCols, numRows, 1044 PS_TYPE_U16, 0); // Image with number fitted per pixel 1046 1045 if (!nums) { 1047 1046 return false; 1048 1047 } 1049 psImage *sigma = pmReadoutSetAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_SIGMA, numCols, numRows, PS_TYPE_F32, NAN); // Image with stdev per pixel 1048 psImage *sigma = pmReadoutSetAnalysisImage(shutter, PM_READOUT_STACK_ANALYSIS_SIGMA, numCols, numRows, 1049 PS_TYPE_F32, NAN); // Image with stdev per pixel 1050 1050 if (!sigma) { 1051 1051 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
