Changeset 7802 for trunk/psModules/src/imcombine/pmReadoutCombine.c
- Timestamp:
- Jul 3, 2006, 2:19:11 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/imcombine/pmReadoutCombine.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/imcombine/pmReadoutCombine.c
r7741 r7802 5 5 * @author GLG, MHPCC 6 6 * 7 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $8 * @date $Date: 2006-0 6-29 00:30:36$7 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2006-07-04 00:19:11 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 122 122 // Step through each readout in the input image list to determine how big of an output image is needed to 123 123 // combine these input images. 124 long maxInputCols = 0; // The largest input column value 125 long maxInputRows = 0; // The largest input row value 126 long minInputCols = LONG_MAX; // The smallest input column value 127 long minInputRows = LONG_MAX; // The smallest input row value 124 int maxInputCols = 0; // The largest input column value 125 int maxInputRows = 0; // The largest input row value 126 int minInputCols = INT_MAX; // The smallest input column value 127 int minInputRows = INT_MAX; // The smallest input row value 128 int xSize = 0, ySize = 0; // The size of the output image 128 129 129 130 bool haveWeights = false; // Do we have weight images? 130 131 bool valid = false; // Do we have a single valid input? 131 for ( inti = 0; i < inputs->n; i++) {132 for (long i = 0; i < inputs->n; i++) { 132 133 pmReadout *readout = inputs->data[i]; // Readout of interest 134 pmCell *cell = readout->parent; // The parent cell 135 133 136 if (!readout || !readout->image) { 134 137 psError(PS_ERR_UNEXPECTED_NULL, true, "Input readout %d is NULL or has NULL image.\n", i); 135 138 return false; 139 } 140 141 bool mdok = true; // Status of MD lookup 142 psRegion *trimsec = psMetadataLookupPtr(&mdok, cell->concepts, "CELL.TRIMSEC"); // Trim section 143 if (!mdok || !trimsec || psRegionIsNaN(*trimsec)) { 144 psLogMsg(__func__, PS_LOG_WARN, "CELL.TRIMSEC is not set for readout %ld --- ignored.\n", i); 145 } else { 146 xSize = PS_MAX(xSize, trimsec->x1 - trimsec->x0); 147 ySize = PS_MAX(ySize, trimsec->y1 - trimsec->y0); 136 148 } 137 149 … … 150 162 valid = true; 151 163 152 // Size ofoutput image164 // Range of pixels on output image 153 165 minInputRows = PS_MIN(minInputRows, readout->row0); 154 166 maxInputRows = PS_MAX(maxInputRows, readout->row0 + readout->image->numRows); … … 182 194 } 183 195 184 // If there's existing images, we need to extend them185 long minOutputRows = (output->image || output->mask || output->weight) ?186 PS_MIN(minInputRows, output->row0) : minInputRows; // Smallest output row value187 long minOutputCols = (output->image || output->mask || output->weight) ?188 PS_MIN(minInputCols, output->col0) : minInputCols; // Smallest output column value189 psTrace(__func__, 7, "Output minimum: %d,%d\n", minOutputCols, minOutputRows);190 191 196 // Update the origin 192 *(psS32 *) &(output->col0) = minOutputCols;193 *(psS32 *) &(output->row0) = minOutputRows;194 195 // Generate the new output image by extending the current one, or making a whole new one196 psImage *newImage = psImageAlloc(maxInputCols - minOutputCols, maxInputRows - minOutputRows, PS_TYPE_F32);197 psImageInit(newImage, 0.0);198 197 if (output->image) { 198 *(psS32 *) &(output->col0) = PS_MIN(minInputCols, output->col0); 199 *(psS32 *) &(output->row0) = PS_MIN(minInputRows, output->row0); 200 } else { 201 *(psS32 *) &(output->col0) = minInputCols; 202 *(psS32 *) &(output->row0) = minInputRows; 203 } 204 psTrace(__func__, 7, "Output minimum: %d,%d\n", output->col0, output->row0); 205 206 // Allocate the output products 207 208 if (!output->image) { 209 output->image = psImageAlloc(xSize, ySize, PS_TYPE_F32); 210 } 211 if (output->image->numCols < xSize || output->image->numRows < ySize) { 212 // Generate the new output image by extending the current one, or making a whole new one 213 psImage *newImage = psImageAlloc(xSize, ySize, PS_TYPE_F32); 214 psImageInit(newImage, 0.0); 199 215 psImageOverlaySection(newImage, output->image, output->col0, output->row0, "="); 200 216 psFree(output->image); 201 } 202 output->image = newImage; 203 204 psImage *newMask = psImageAlloc(maxInputCols - minOutputCols, maxInputRows - minOutputRows, PS_TYPE_U8); 205 psImageInit(newMask, 0); 206 if (output->mask) { 217 output->image = newImage; 218 } 219 220 if (!output->mask) { 221 output->mask = psImageAlloc(xSize, ySize, PS_TYPE_U8); 222 } 223 if (output->mask->numCols < xSize || output->mask->numRows < ySize) { 224 psImage *newMask = psImageAlloc(xSize, ySize, PS_TYPE_U8); 225 psImageInit(newMask, 0); 207 226 psImageOverlaySection(newMask, output->mask, output->col0, output->row0, "="); 208 227 psFree(output->mask); 209 }210 output->mask = newMask;228 output->mask = newMask; 229 } 211 230 212 231 psStatsOptions combineStdev = 0; // Statistics option for weights 213 232 if (haveWeights) { 214 psImage *newWeight = psImageAlloc(maxInputCols - minOutputCols, maxInputRows - minOutputRows, 215 PS_TYPE_F32); 216 psImageInit(newWeight, 0.0); 217 if (output->weight) { 233 234 if (!output->weight) { 235 output->weight = psImageAlloc(xSize, ySize, PS_TYPE_F32); 236 } 237 if (output->weight->numCols < xSize || output->weight->numRows < ySize) { 238 psImage *newWeight = psImageAlloc(xSize, ySize, PS_TYPE_F32); 239 psImageInit(newWeight, 0.0); 218 240 psImageOverlaySection(newWeight, output->weight, output->col0, output->row0, "="); 219 241 psFree(output->weight); 220 }221 output->weight = newWeight;242 output->weight = newWeight; 243 } 222 244 223 245 // Get the correct statistics option for weights
Note:
See TracChangeset
for help on using the changeset viewer.
