Changeset 19432 for trunk/psModules/src/detrend/pmBias.c
- Timestamp:
- Sep 8, 2008, 6:10:14 PM (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
r19299 r19432 23 23 PS_ASSERT_THREAD_JOB_NON_NULL(job, false); 24 24 pmReadout *in = job->args->data[0]; 25 pmReadout *sub = job->args->data[1];25 const pmReadout *sub = job->args->data[1]; 26 26 float scale = PS_SCALAR_VALUE(job->args->data[2],F32); 27 27 int xOffset = PS_SCALAR_VALUE(job->args->data[3],S32); … … 29 29 int rowStart = PS_SCALAR_VALUE(job->args->data[5],S32); 30 30 int rowStop = PS_SCALAR_VALUE(job->args->data[6],S32); 31 bool status = pmBiasSubtractScan(in, sub, scale, xOffset, yOffset, rowStart, rowStop);32 return status; 33 } 34 35 bool pmBiasSubtractScan (pmReadout *in, pmReadout *sub, float scale, int xOffset, int yOffset, int rowStart, int rowStop) { 36 31 return pmBiasSubtractScan(in, sub, scale, xOffset, yOffset, rowStart, rowStop); 32 } 33 34 bool pmBiasSubtractScan(pmReadout *in, const pmReadout *sub, float scale, 35 int xOffset, int yOffset, int rowStart, int rowStop) 36 { 37 37 psImage *inImage = in->image; // The input image 38 38 psImage *inMask = in->mask; // The input mask 39 psImage *subImage = sub->image;// The image to be subtracted40 psImage *subMask = sub->mask;// The mask for the subtraction image39 const psImage *subImage = sub->image; // The image to be subtracted 40 const psImage *subMask = sub->mask; // The mask for the subtraction image 41 41 42 42 if (scale == 1.0) { … … 62 62 } 63 63 64 // pmBiasSubtractFrame(): this routine will take as input a readout for the input image and a readout for the bias 64 // pmBiasSubtractFrame(): 65 // this routine will take as input a readout for the input image and a readout for the bias 65 66 // image. The bias image is subtracted in place from the input image. 66 67 bool pmBiasSubtractFrame(pmReadout *in, // Input readout … … 129 130 130 131 for (int rowStart = 0; rowStart < inImage->numRows; rowStart += scanRows) { 131 int rowStop = PS_MIN(rowStart + scanRows, inImage->numRows);132 133 if (threaded) {134 // allocate a job, construct the arguments for this job135 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);150 } else {151 pmBiasSubtractScan (in, sub, scale, xOffset, yOffset, rowStart, rowStop);152 }132 int rowStop = PS_MIN(rowStart + scanRows, inImage->numRows); 133 134 if (threaded) { 135 // allocate a job, construct the arguments for this job 136 psThreadJob *job = psThreadJobAlloc("PSMODULES_DETREND_BIAS"); 137 psArrayAdd(job->args, 1, in); 138 psArrayAdd(job->args, 1, sub); 139 PS_ARRAY_ADD_SCALAR(job->args, scale, PS_TYPE_F32); 140 PS_ARRAY_ADD_SCALAR(job->args, xOffset, PS_TYPE_S32); 141 PS_ARRAY_ADD_SCALAR(job->args, yOffset, PS_TYPE_S32); 142 PS_ARRAY_ADD_SCALAR(job->args, rowStart, PS_TYPE_S32); 143 PS_ARRAY_ADD_SCALAR(job->args, rowStop, PS_TYPE_S32); 144 145 if (!psThreadJobAddPending(job)) { 146 psFree(job); 147 return false; 148 } 149 psFree(job); 150 } else if (!pmBiasSubtractScan(in, sub, scale, xOffset, yOffset, rowStart, rowStop)) { 151 psError(PS_ERR_UNKNOWN, false, "Unable to apply bias correction."); 152 return false; 153 } 153 154 } 154 155 155 156 if (threaded) { 156 157 // 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); 158 if (!psThreadPoolWait(true)) { 159 psError(PS_ERR_UNKNOWN, false, "Unable to apply bias correction."); 160 return false; 168 161 } 169 162 }
Note:
See TracChangeset
for help on using the changeset viewer.
