Changeset 25383 for trunk/psModules/src/camera/pmFPAMosaic.c
- Timestamp:
- Sep 15, 2009, 12:45:01 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
psModules/src/camera/pmFPAMosaic.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/pap (added) merged: 25238,25241-25243,25246,25258-25267,25278,25302,25309-25312,25326-25329,25331-25339
- Property svn:mergeinfo changed
-
trunk/psModules/src/camera/pmFPAMosaic.c
r21363 r25383 740 740 static bool chipMosaic(psImage **mosaicImage, // The mosaic image, to be returned 741 741 psImage **mosaicMask, // The mosaic mask, to be returned 742 psImage **mosaicVariance s, // The mosaic variances, to be returned742 psImage **mosaicVariance, // The mosaic variance, to be returned 743 743 int *xBinChip, int *yBinChip, // The binning in x and y, to be returned 744 744 const pmChip *chip, // Chip to mosaic … … 749 749 assert(mosaicImage); 750 750 assert(mosaicMask); 751 assert(mosaicVariance s);751 assert(mosaicVariance); 752 752 assert(xBinChip); 753 753 assert(yBinChip); … … 826 826 if (allGood) { 827 827 *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, BLANK_VALUE); 828 *mosaicVariance s= imageMosaic(variances, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, BLANK_VALUE);828 *mosaicVariance = imageMosaic(variances, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, BLANK_VALUE); 829 829 *mosaicMask = imageMosaic(masks, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, blank); 830 830 } … … 847 847 static bool fpaMosaic(psImage **mosaicImage, // The mosaic image, to be returned 848 848 psImage **mosaicMask, // The mosaic mask, to be returned 849 psImage **mosaicVariance s, // The mosaic variances, to be returned849 psImage **mosaicVariance, // The mosaic variance, to be returned 850 850 int *xBinFPA, int *yBinFPA, // The binning in x and y, to be returned 851 851 const pmFPA *fpa, // FPA to mosaic … … 857 857 assert(mosaicImage); 858 858 assert(mosaicMask); 859 assert(mosaicVariance s);859 assert(mosaicVariance); 860 860 assert(xBinFPA); 861 861 assert(yBinFPA); … … 960 960 if (allGood) { 961 961 *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, BLANK_VALUE); 962 *mosaicVariance s= imageMosaic(variances, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, BLANK_VALUE);962 *mosaicVariance = imageMosaic(variances, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, BLANK_VALUE); 963 963 *mosaicMask = imageMosaic(masks, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, blank); 964 964 } … … 1025 1025 psImage *mosaicImage = NULL; // The mosaic image 1026 1026 psImage *mosaicMask = NULL; // The mosaic mask 1027 psImage *mosaicVariance s= NULL; // The mosaic variances1027 psImage *mosaicVariance = NULL; // The mosaic variances 1028 1028 1029 1029 // Find the HDU … … 1052 1052 } 1053 1053 if (hdu->variances) { 1054 mosaicVariance s= psImageSubset(hdu->variances->data[0], bounds);1055 if (!mosaicVariance s) {1054 mosaicVariance = psImageSubset(hdu->variances->data[0], bounds); 1055 if (!mosaicVariance) { 1056 1056 psError(PS_ERR_UNKNOWN, false, "Unable to select variance pixels.\n"); 1057 1057 return false; … … 1061 1061 // Case 2 --- we need to mosaic by cut and paste 1062 1062 psTrace("psModules.camera", 1, "Case 2 mosaicking: cut and paste.\n"); 1063 if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicVariance s, &xBin, &yBin, source, targetCell, blank)) {1063 if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicVariance, &xBin, &yBin, source, targetCell, blank)) { 1064 1064 psError(PS_ERR_UNKNOWN, false, "Unable to mosaic cells.\n"); 1065 1065 return false; … … 1069 1069 } 1070 1070 psTrace("psModules.camera", 1, "xBin,yBin: %d,%d\n", xBin, yBin); 1071 1071 1072 1072 1073 // Set the concepts for the target cell … … 1090 1091 target->parent->concepts = psMetadataCopy(target->parent->concepts, source->parent->concepts); // FPA lvl 1091 1092 1093 // Average the covariances 1094 psList *covariances = psListAlloc(NULL); // Input covariance matrices 1095 for (int i = 0; i < source->cells->n; i++) { 1096 pmCell *cell = source->cells->data[i]; // Cell of interest 1097 if (!cell || !cell->data_exists) { 1098 continue; 1099 } 1100 pmReadout *ro = cell->readouts->data[0]; // Readout of interest 1101 if (!ro || !ro->covariance) { 1102 continue; 1103 } 1104 psListAdd(covariances, PS_LIST_TAIL, ro->covariance); 1105 } 1106 psKernel *mosaicCovariance = NULL; // Covariance for mosaic 1107 if (psListLength(covariances) > 0) { 1108 psArray *covarArray = psListToArray(covariances); // Array with covariances 1109 mosaicCovariance = psImageCovarianceAverage(covarArray); 1110 psFree(covarArray); 1111 } 1112 psFree(covariances); 1113 1092 1114 // Now make a new readout to go in the target cell 1093 1115 pmReadout *newReadout = pmReadoutAlloc(targetCell); // New readout 1094 1116 newReadout->image = mosaicImage; 1095 1117 newReadout->mask = mosaicMask; 1096 newReadout->variance = mosaicVariances; 1118 newReadout->variance = mosaicVariance; 1119 newReadout->covariance = mosaicCovariance; 1097 1120 psFree(newReadout); // Drop reference 1098 1121 … … 1334 1357 target->concepts = psMetadataCopy(target->concepts, source->concepts); 1335 1358 1359 // Average the covariances 1360 psList *covariances = psListAlloc(NULL); // Input covariance matrices 1361 for (int i = 0; i < covariances->n; i++) { 1362 pmChip *chip = chips->data[i]; // Chip of interest 1363 if (!chip || !chip->data_exists) { 1364 continue; 1365 } 1366 psArray *cells = chip->cells; // Cells in chip 1367 for (long j = 0; j < cells->n; j++) { 1368 pmCell *cell = cells->data[i]; // Cell of interest 1369 if (!cell || !cell->data_exists) { 1370 continue; 1371 } 1372 pmReadout *ro = cell->readouts->data[0]; // Readout of interest 1373 if (!ro || !ro->covariance) { 1374 continue; 1375 } 1376 psListAdd(covariances, PS_LIST_TAIL, ro->covariance); 1377 } 1378 } 1379 psKernel *mosaicCovariances = NULL; // Covariance for mosaic 1380 if (psListLength(covariances) > 0) { 1381 psArray *covarArray = psListToArray(covariances); // Array with covariances 1382 mosaicCovariances = psImageCovarianceAverage(covarArray); 1383 psFree(covarArray); 1384 } 1385 psFree(covariances); 1386 1336 1387 // Now make a new readout to go in the new cell 1337 1388 pmReadout *newReadout = pmReadoutAlloc(targetCell); // New readout … … 1339 1390 newReadout->mask = mosaicMask; 1340 1391 newReadout->variance = mosaicVariances; 1392 newReadout->covariance = mosaicCovariances; 1341 1393 psFree(newReadout); // Drop reference 1342 1394
Note:
See TracChangeset
for help on using the changeset viewer.
