Changeset 6080 for branches/eam_rel9_p0/psModules/src/astrom/pmChipMosaic.c
- Timestamp:
- Jan 19, 2006, 11:47:06 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_rel9_p0/psModules/src/astrom/pmChipMosaic.c
r6062 r6080 37 37 int yMin = INT_MAX; 38 38 int yMax = - INT_MAX; 39 psElemType type = 0; 39 40 for (int i = 0; i < source->n; i++) { 40 41 psImage *image = source->data[i]; // The image of interest … … 43 44 } 44 45 45 assert(image->type.type == PS_TYPE_F32); // Only implemented for F32 images so far. 46 // Only implemented for F32 and U8 images so far. 47 assert(image->type.type == PS_TYPE_F32 || image->type.type == PS_TYPE_U8); 48 // All input types must be the same 49 if (type == 0) { 50 type = image->type.type; 51 } 52 assert(type == image->type.type); 46 53 47 54 // Size of cell in x and y … … 71 78 72 79 psTrace(__func__, 3, "Spliced image will be %dx%d\n", (int)xSize, (int)ySize); 73 psImage *mosaic = psImageAlloc((int)xSize, (int)ySize, PS_TYPE_F32); // The mosaic image80 psImage *mosaic = psImageAlloc((int)xSize, (int)ySize, type); // The mosaic image 74 81 psImageInit(mosaic, 0.0); 75 82 … … 96 103 // In case the original image is binned but the mosaic is not, we need to fill in the 97 104 // values in the mosaic. 98 for (int j = 0; j < yBinSource->data.S32[i]; j++) { 99 int yTarget = (int)(yTargetBase + yParity * (float)j / (float)yBinTarget); 100 for (int i = 0; i < xBinSource->data.S32[i]; i++) { 101 int xTarget = (int)(xTargetBase + xParity * (float)i / (float)xBinTarget); 102 103 mosaic->data.F32[yTarget][xTarget] += image->data.F32[y][x]; 104 } 105 } // Iterating over mosaic image for binned input image 105 #define FILL_IN(TYPE) \ 106 for (int j = 0; j < yBinSource->data.S32[i]; j++) { \ 107 int yTarget = (int)(yTargetBase + yParity * (float)j / (float)yBinTarget); \ 108 for (int i = 0; i < xBinSource->data.S32[i]; i++) { \ 109 int xTarget = (int)(xTargetBase + xParity * (float)i / (float)xBinTarget); \ 110 mosaic->data.TYPE[yTarget][xTarget] += image->data.TYPE[y][x]; \ 111 } \ 112 } 113 114 switch (type) { 115 case PS_TYPE_F32: 116 FILL_IN(F32); 117 break; 118 case PS_TYPE_U8: 119 FILL_IN(U8); 120 break; 121 default: 122 psAbort(__func__, "Should never get here.\n"); 123 } 124 106 125 } 107 126 } // Iterating over input image … … 158 177 } 159 178 160 // Trim the image to get rid of the overscan161 psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");162 psTrace(__func__, 7, "Cell %d trimsec: [%.0f:%.0f,%.0f:%.0f]\n", i, trimsec->x0, trimsec->x1,163 trimsec->y0, trimsec->y1);164 179 psArray *readouts = cell->readouts; // The array of readouts 165 180 if (readouts->n > 1) { … … 167 182 "be mosaicked.\n", i); 168 183 } 169 p sImage *image = ((pmReadout*)readouts->data[0])->image; // The image to put into the mosaic170 psImage *weight = ((pmReadout*)readouts->data[0])->weight; 171 psImage *mask = ((pmReadout*)readouts->data[0])->weight;172 images->data[i] = psImageSubset(image, *trimsec); // Trimmed image173 weights->data[i] = weight ? psImageSubset(weight, *trimsec) : NULL;174 masks->data[i] = mask ? psImageSubset(mask, *trimsec) : NULL;184 pmReadout *readout = readouts->data[0]; // The only readout we'll bother with 185 186 // The images to put into the mosaic 187 images->data[i] = readout->image; 188 weights->data[i] = readout->weight; 189 masks->data[i] = readout->mask; 175 190 } 176 191 // Mosaic the images together and we're done
Note:
See TracChangeset
for help on using the changeset viewer.
