Changeset 25266
- Timestamp:
- Sep 3, 2009, 5:05:24 PM (17 years ago)
- File:
-
- 1 edited
-
branches/pap/psModules/src/camera/pmFPAMosaic.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap/psModules/src/camera/pmFPAMosaic.c
r21363 r25266 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; 1120 psFree(covariances); 1097 1121 psFree(newReadout); // Drop reference 1098 1122 … … 1334 1358 target->concepts = psMetadataCopy(target->concepts, source->concepts); 1335 1359 1360 // Average the covariances 1361 psList *covariances = psListAlloc(NULL); // Input covariance matrices 1362 for (int i = 0; i < covariances->n; i++) { 1363 pmChip *chip = chips->data[i]; // Chip of interest 1364 if (!chip || !chip->data_exists) { 1365 continue; 1366 } 1367 psArray *cells = chip->cells; // Cells in chip 1368 for (long j = 0; j < cells->n; j++) { 1369 pmCell *cell = cells->data[i]; // Cell of interest 1370 if (!cell || !cell->data_exists) { 1371 continue; 1372 } 1373 pmReadout *ro = cell->readouts->data[0]; // Readout of interest 1374 if (!ro || !ro->covariance) { 1375 continue; 1376 } 1377 psListAdd(covariances, PS_LIST_TAIL, ro->covariance); 1378 } 1379 } 1380 psKernel *mosaicCovariances = NULL; // Covariance for mosaic 1381 if (psListLength(covariances) > 0) { 1382 psArray *covarArray = psListToArray(covariances); // Array with covariances 1383 mosaicCovariances = psImageCovarianceAverage(covarArray); 1384 psFree(covarArray); 1385 } 1386 psFree(covariances); 1387 1336 1388 // Now make a new readout to go in the new cell 1337 1389 pmReadout *newReadout = pmReadoutAlloc(targetCell); // New readout … … 1339 1391 newReadout->mask = mosaicMask; 1340 1392 newReadout->variance = mosaicVariances; 1393 newReadout->covariance = mosaicCovariances; 1341 1394 psFree(newReadout); // Drop reference 1342 1395
Note:
See TracChangeset
for help on using the changeset viewer.
