Changeset 7194
- Timestamp:
- May 23, 2006, 7:08:52 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmReadoutCombine.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmReadoutCombine.c
r7059 r7194 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1. 8$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-05- 04 02:38:20$7 * @version $Revision: 1.9 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-05-24 05:08:52 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 144 144 psVector *colLower = psVectorAlloc(inputs->n, PS_TYPE_U32); // The lower x bound for each image 145 145 psVector *colUpper = psVectorAlloc(inputs->n, PS_TYPE_U32); // The upper x bound for each image 146 rowLower->n = inputs->n; 147 rowUpper->n = inputs->n; 148 colLower->n = inputs->n; 149 colUpper->n = inputs->n; 146 150 psVector *mask = psVectorAlloc(inputs->n, PS_TYPE_U8); // Mask for stack 151 mask->n = inputs->n; 147 152 psVectorInit(mask, 0); 148 153 bool haveWeights = false; // Do we have weight images? … … 180 185 colUpper->data.U32[i] = readout->col0 + readout->image->numCols; 181 186 } 182 183 // Reset output readout components 184 *(psS32 *) &(output->col0) = minInputCols; 185 *(psS32 *) &(output->row0) = minInputRows; 186 output->image = psImageRecycle(output->image, maxInputCols - minInputCols, maxInputRows - minInputRows, 187 PS_TYPE_F32); 188 output->mask = psImageRecycle(output->mask, maxInputCols - minInputCols, maxInputRows - minInputRows, 189 PS_TYPE_U8); 190 psImageInit(output->mask, 0); 191 psStatsOptions combineStdev = 0; // Statistics option for weights 187 if (!valid) { 188 psError(PS_ERR_IO, true, "No valid inputs.\n"); 189 return NULL; 190 } 191 192 // If there's existing images, we need to extend them 193 long minOutputRows = (output->image || output->mask || output->weight) ? 194 PS_MIN(minInputRows, output->row0) : minInputRows; // Smallest row value, considering the output 195 long minOutputCols = (output->image || output->mask || output->weight) ? 196 PS_MIN(minInputCols, output->col0) : minInputCols; // Smallest column value, considering the output 197 198 // Update the origin 199 *(psS32 *) &(output->col0) = minOutputCols; 200 *(psS32 *) &(output->row0) = minOutputRows; 201 202 // Generate the new output image by extending the current one, or making a whole new one 203 psImage *newImage = psImageAlloc(maxInputCols - minOutputCols, maxInputRows - minOutputRows, PS_TYPE_F32); 204 psImageInit(newImage, 0.0); 205 if (output->image) { 206 psImageOverlaySection(newImage, output->image, output->col0, output->row0, "="); 207 psFree(output->image); 208 } 209 output->image = newImage; 210 211 psImage *newMask = psImageAlloc(maxInputCols - minOutputCols, maxInputRows - minOutputRows, PS_TYPE_U8); 212 psImageInit(newMask, 0); 213 if (output->mask) { 214 psImageOverlaySection(newMask, output->mask, output->col0, output->row0, "="); 215 psFree(output->mask); 216 } 217 output->mask = newMask; 218 219 psStatsOptions combineStdev = 0; // Statistics option for weights 192 220 if (haveWeights) { 193 output->weight = psImageRecycle(output->weight, maxInputCols - minInputCols, 194 maxInputRows - minInputRows, PS_TYPE_F32); 221 psImage *newWeight = psImageAlloc(maxInputCols - minOutputCols, maxInputRows - minOutputRows, 222 PS_TYPE_F32); 223 psImageInit(newWeight, 0.0); 224 if (output->weight) { 225 psImageOverlaySection(newWeight, output->weight, output->col0, output->row0, "="); 226 psFree(output->weight); 227 } 228 output->weight = newWeight; 229 230 // Get the correct statistics option for weights 195 231 switch (params->combine) { 196 232 case PS_STAT_SAMPLE_MEAN: … … 231 267 psMaskType maskVal = params->maskVal; // The mask value 232 268 233 for (int i = output->row0; i < output->row0 + output->image->numRows; i++) {234 for (int j = output->col0; j < output->col0 + output->image->numCols; j++) {269 for (int i = minInputRows; i < maxInputRows; i++) { 270 for (int j = minInputCols; j < maxInputCols; j++) { 235 271 236 272 int numValid = 0; // Number of valid pixels in the stack … … 246 282 247 283 pmReadout *readout = inputs->data[r]; // Input readout 248 int y = i - readout->row0; // y position on input readout249 int x = j - readout->col0; // x position on input readout250 if (readout->mask && readout->mask->data.U8[y ][x] & maskVal) {284 int yIn = i - readout->row0; // y position on input readout 285 int xIn = j - readout->col0; // x position on input readout 286 if (readout->mask && readout->mask->data.U8[yIn][xIn] & maskVal) { 251 287 mask->data.U8[r] &= PM_READOUT_COMBINE_MASKED; 252 288 continue; 253 289 } 254 290 255 pixels->data.F32[r] = readout->image->data.F32[y ][x];291 pixels->data.F32[r] = readout->image->data.F32[yIn][xIn]; 256 292 257 293 // Apply zero and scale … … 264 300 265 301 if (haveWeights) { 266 weights->data.F32[r] = readout->weight->data.F32[y ][x];302 weights->data.F32[r] = readout->weight->data.F32[yIn][xIn]; 267 303 if (scale) { 268 304 weights->data.F32[r] /= scale->data.F32[r] * scale->data.F32[r]; … … 272 308 } 273 309 310 int yOut = i - output->row0; // y position on output readout 311 int xOut = j - output->col0; // x position on output readout 312 psTrace(__func__, 10, "Output pixel: %d %d\n", xOut, yOut); 313 274 314 if (numValid == 0) { 275 output->mask->data.U8[ i][j] = PM_MASK_FLAT;315 output->mask->data.U8[yOut][xOut] = PM_MASK_FLAT; 276 316 continue; 277 317 } … … 298 338 } 299 339 } 300 psFree(index);301 340 } 302 341 303 342 // Combination 304 343 psVectorStats(stats, pixels, weights, mask, PM_READOUT_COMBINE_BAD | PM_READOUT_COMBINE_CLIPPED); 305 output->image->data.F32[ i][j] = getStat(stats, params->combine);344 output->image->data.F32[yOut][xOut] = getStat(stats, params->combine); 306 345 if (haveWeights) { 307 output->weight->data.F32[i][j] = getStat(stats, combineStdev); 308 output->weight->data.F32[i][j] *= output->weight->data.F32[i][j]; // Squared for variance 346 output->weight->data.F32[yOut][xOut] = PS_SQR(getStat(stats, combineStdev)); // Variance 309 347 } 310 348 … … 315 353 } 316 354 355 psFree(index); 317 356 psFree(rowLower); 318 357 psFree(rowUpper);
Note:
See TracChangeset
for help on using the changeset viewer.
