Changeset 20180 for trunk/dvoTools/src/dvoApplyCorrReadout.c
- Timestamp:
- Oct 15, 2008, 5:51:49 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/dvoTools/src/dvoApplyCorrReadout.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/dvoTools/src/dvoApplyCorrReadout.c
r11862 r20180 5 5 #include "dvoApplyCorr.h" 6 6 7 // this function is operating on each readout, assuming there is a correspondence between 8 // readouts in the input (raw) flat-field image and the correction frame. this is not really 9 // true 7 // this function is operating on each cell (well, readout) of the flat to be corrected. The 8 // input chip is supplied, but may be in a different format (eg, chip-mosaic vs single cell) 10 9 11 bool dvoApplyCorrReadout (pmC onfig *config, pmFPAview *view, char *inName, char *corrName) {10 bool dvoApplyCorrReadout (pmCell *inCell, pmChip *corrChip) { 12 11 12 // XXX for now, let's just assume the input is per-cell, and the correction is per-chip 13 // Also, let's assume they are both binned 1x1 14 13 15 bool status; 14 16 15 pmFPAfile *inFile = psMetadataLookupPtr (&status, config->files, inName); 16 pmFPAfile *corrFile = psMetadataLookupPtr (&status, config->files, corrName); 17 assert (inFile); 18 assert (corrFile); 17 pmCell *corrCell = corrChip->cells->data[0]; 18 pmReadout *corrRO = corrCell->readouts->data[0]; 19 psImage *corrImage = corrRO->image; 19 20 20 pmReadout *inData = pmFPAviewThisReadout (view, inFile->fpa); 21 pmReadout *corrData = pmFPAviewThisReadout (view, corrFile->fpa); 22 assert (inData); 23 assert (corrData); 21 pmReadout *inRO = inCell->readouts->data[0]; 22 psImage *inImage = inRO->image; 24 23 25 // dimensions of input image: 26 assert (inData->image->numCols == corrData->image->numCols); 27 assert (inData->image->numRows == corrData->image->numRows); 24 int x0 = psMetadataLookupS32(&status, inCell->concepts, "CELL.X0"); // Position of (0,0) on chip 25 if (!status) { 26 psError(PS_ERR_UNKNOWN, true, "CELL.X0 hasn't been set for cell.\n"); 27 return false; 28 } 29 int y0 = psMetadataLookupS32(&status, inCell->concepts, "CELL.Y0"); // Position of (0,0) on chip 30 if (!status) { 31 psError(PS_ERR_UNKNOWN, true, "CELL.Y0 hasn't been set for cell.\n"); 32 return false; 33 } 28 34 29 // NOTE : the output pmFPA points at the same pixels as the input pmFPA 35 int xParity = psMetadataLookupS32(&status, inCell->concepts, "CELL.XPARITY"); // Parity in x 36 if (!status) { 37 psError(PS_ERR_UNKNOWN, true, "CELL.XPARITY hasn't been set for cell.\n"); 38 return false; 39 } 40 int yParity = psMetadataLookupS32(&status, inCell->concepts, "CELL.YPARITY"); // Parity in y 41 if (!status) { 42 psError(PS_ERR_UNKNOWN, true, "CELL.YPARITY hasn't been set for cell.\n"); 43 return false; 44 } 30 45 31 // the corr image is a multiplicative factor 32 for (int j = 0; j < inData->image->numRows; j++) { 33 for (int i = 0; i < inData->image->numCols; i++) { 34 inData->image->data.F32[j][i] *= corrData->image->data.F32[j][i]; 46 // The corr image is a multiplicative factor. Need to convert the input flat pixel 47 // coordinates to the correction cell/pixel coords. 48 for (int j = 0; j < inImage->numRows; j++) { 49 int jC = (yParity < 0) ? y0 + j*yParity : y0 + j*yParity + 1; 50 for (int i = 0; i < inImage->numCols; i++) { 51 int iC = (xParity < 0) ? x0 + i*xParity : x0 + i*xParity + 1; 52 inImage->data.F32[j][i] *= corrImage->data.F32[jC][iC]; 35 53 } 36 54 } 37 38 // psFits *fits = psFitsOpen ("tmp.fits", "w");39 // psFitsWriteImage (fits, NULL, inData->image, 0, NULL);40 // psFitsClose (fits);41 // exit (0);42 43 55 return true; 44 56 }
Note:
See TracChangeset
for help on using the changeset viewer.
