Changeset 18960 for trunk/psModules/src/detrend/pmBias.c
- Timestamp:
- Aug 8, 2008, 8:09:07 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/detrend/pmBias.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/detrend/pmBias.c
r18893 r18960 19 19 #include "pmBias.h" 20 20 21 bool pmBiasSubtractScan_Threaded (psThreadJob *job) { 21 bool pmBiasSubtractScan_Threaded(const psThreadJob *job) 22 { 23 PS_ASSERT_THREAD_JOB_NON_NULL(job, false); 22 24 pmReadout *in = job->args->data[0]; 23 25 pmReadout *sub = job->args->data[1]; … … 63 65 // image. The bias image is subtracted in place from the input image. 64 66 bool pmBiasSubtractFrame(pmReadout *in, // Input readout 65 pmReadout *sub, // Readout to be subtracted from input66 float scale // Scale to apply before subtracting67 pmReadout *sub, // Readout to be subtracted from input 68 float scale // Scale to apply before subtracting 67 69 ) 68 70 { … … 121 123 bool threaded = true; 122 124 int scanRows = pmDetrendGetScanRows(); 123 if (scanRows == 0) { 124 threaded = false;125 scanRows = inImage->numRows;125 if (scanRows == 0) { 126 threaded = false; 127 scanRows = inImage->numRows; 126 128 } 127 129 … … 129 131 int rowStop = PS_MIN (rowStart + scanRows, inImage->numRows); 130 132 131 # define PS_ARRAY_ADD_SCALAR(ARRAY, VALUE, TYPE) { \132 psScalar *scalar = psScalarAlloc(VALUE, TYPE); \133 psArrayAdd(ARRAY, 1, scalar); \134 psFree (scalar); }135 136 133 if (threaded) { 137 // allocate a job, construct the arguments for this job 138 psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_BIAS"); 139 psArrayAdd (job->args, 1, in); 140 psArrayAdd (job->args, 1, sub); 141 PS_ARRAY_ADD_SCALAR (job->args, scale, PS_TYPE_F32); 142 PS_ARRAY_ADD_SCALAR (job->args, xOffset, PS_TYPE_S32); 143 PS_ARRAY_ADD_SCALAR (job->args, yOffset, PS_TYPE_S32); 144 PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32); 145 PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32); 146 147 // ppImageDetrendReadout(config, options, view) 148 if (!psThreadJobAddPending (job)) { 149 return false; 150 } 134 // allocate a job, construct the arguments for this job 135 psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_BIAS"); 136 psArrayAdd (job->args, 1, in); 137 psArrayAdd (job->args, 1, sub); 138 PS_ARRAY_ADD_SCALAR (job->args, scale, PS_TYPE_F32); 139 PS_ARRAY_ADD_SCALAR (job->args, xOffset, PS_TYPE_S32); 140 PS_ARRAY_ADD_SCALAR (job->args, yOffset, PS_TYPE_S32); 141 PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32); 142 PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32); 143 144 // ppImageDetrendReadout(config, options, view) 145 if (!psThreadJobAddPending (job)) { 146 psFree(job); 147 return false; 148 } 149 psFree(job); 151 150 } else { 152 pmBiasSubtractScan (in, sub, scale, xOffset, yOffset, rowStart, rowStop);151 pmBiasSubtractScan (in, sub, scale, xOffset, yOffset, rowStart, rowStop); 153 152 } 154 153 } 155 154 156 155 if (threaded) { 157 // wait here for the threaded jobs to finish158 if (!psThreadPoolWait ()) {159 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");160 return false;161 }162 fprintf (stderr, "success for threaded jobs\n");163 164 // each job records its own goodPixel values; sum them here165 // we have only supplied one type of job, so we can assume the types here166 psThreadJob *job = NULL;167 while ((job = psThreadJobGetDone()) != NULL) {168 psFree (job);169 }156 // wait here for the threaded jobs to finish 157 if (!psThreadPoolWait(false)) { 158 psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image."); 159 return false; 160 } 161 fprintf (stderr, "success for threaded jobs\n"); 162 163 // each job records its own goodPixel values; sum them here 164 // we have only supplied one type of job, so we can assume the types here 165 psThreadJob *job = NULL; 166 while ((job = psThreadJobGetDone()) != NULL) { 167 psFree (job); 168 } 170 169 } 171 170
Note:
See TracChangeset
for help on using the changeset viewer.
