Changeset 21363 for trunk/psModules/src/camera/pmFPAMosaic.c
- Timestamp:
- Feb 5, 2009, 4:31:25 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAMosaic.c (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAMosaic.c
r21183 r21363 554 554 // We have to do all of the hard work ourselves 555 555 switch (type) { 556 FILL_IN(U8);557 FILL_IN(U16);558 FILL_IN(U32);559 FILL_IN(U64);560 FILL_IN(S8);561 FILL_IN(S16);562 FILL_IN(S32);563 FILL_IN(S64);564 FILL_IN(F32);565 FILL_IN(F64);556 FILL_IN(U8); 557 FILL_IN(U16); 558 FILL_IN(U32); 559 FILL_IN(U64); 560 FILL_IN(S8); 561 FILL_IN(S16); 562 FILL_IN(S32); 563 FILL_IN(S64); 564 FILL_IN(F32); 565 FILL_IN(F64); 566 566 default: 567 567 psAbort("Should never get here.\n"); … … 575 575 static bool addCell(psArray *images, // Array of images 576 576 psArray *masks, // Array of masks 577 psArray * weights, // Array of weights577 psArray *variances, // Array of variances 578 578 psVector *x0, // Array of X0 579 579 psVector *y0, // Array of Y0 … … 604 604 images = psArrayRealloc(images, index + CELL_LIST_BUFFER); 605 605 masks = psArrayRealloc(masks, index + CELL_LIST_BUFFER); 606 weights = psArrayRealloc(weights, index + CELL_LIST_BUFFER);606 variances = psArrayRealloc(variances, index + CELL_LIST_BUFFER); 607 607 x0 = psVectorRealloc(x0, index+ CELL_LIST_BUFFER); 608 608 y0 = psVectorRealloc(y0, index+ CELL_LIST_BUFFER); … … 615 615 images->n = index + 1; 616 616 masks->n = index + 1; 617 weights->n = index + 1;617 variances->n = index + 1; 618 618 x0->n = index + 1; 619 619 y0->n = index + 1; … … 726 726 // The images to put into the mosaic 727 727 images->data[index] = psMemIncrRefCounter(readout->image); 728 weights->data[index] = psMemIncrRefCounter(readout->weight);728 variances->data[index] = psMemIncrRefCounter(readout->variance); 729 729 masks->data[index] = psMemIncrRefCounter(readout->mask); 730 730 … … 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 **mosaic Weights, // The mosaic weights, to be returned742 psImage **mosaicVariances, // The mosaic variances, 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(mosaic Weights);751 assert(mosaicVariances); 752 752 assert(xBinChip); 753 753 assert(yBinChip); … … 756 756 757 757 psArray *images = psArrayAlloc(0); // Array of images that will be mosaicked 758 psArray * weights = psArrayAlloc(0); // Array of weightimages to be mosaicked758 psArray *variances = psArrayAlloc(0); // Array of variance images to be mosaicked 759 759 psArray *masks = psArrayAlloc(0); // Array of mask images to be mosaicked 760 760 psVector *x0 = psVectorAlloc(0, PS_TYPE_S32); // Origin x coordinates … … 802 802 continue; 803 803 } 804 allGood &= addCell(images, masks, weights, x0, y0, xBin, yBin, xFlip, yFlip,804 allGood &= addCell(images, masks, variances, x0, y0, xBin, yBin, xFlip, yFlip, 805 805 cell, xBinChip, yBinChip, false, x0Target, y0Target, 806 806 xParityTarget, yParityTarget); … … 826 826 if (allGood) { 827 827 *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, BLANK_VALUE); 828 *mosaic Weights = imageMosaic(weights, xFlip, yFlip, xBin, yBin, *xBinChip, *yBinChip, x0, y0, BLANK_VALUE);828 *mosaicVariances = 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 } … … 832 832 // Clean up 833 833 psFree(images); 834 psFree( weights);834 psFree(variances); 835 835 psFree(masks); 836 836 psFree(xFlip); … … 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 **mosaic Weights, // The mosaic weights, to be returned849 psImage **mosaicVariances, // The mosaic variances, 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(mosaic Weights);859 assert(mosaicVariances); 860 860 assert(xBinFPA); 861 861 assert(yBinFPA); … … 865 865 866 866 psArray *images = psArrayAlloc(0); // Array of images that will be mosaicked 867 psArray * weights = psArrayAlloc(0); // Array of weightimages to be mosaicked867 psArray *variances = psArrayAlloc(0); // Array of variance images to be mosaicked 868 868 psArray *masks = psArrayAlloc(0); // Array of mask images to be mosaicked 869 869 psVector *x0 = psVectorAlloc(0, PS_TYPE_S32); // Origin x coordinates … … 941 941 continue; 942 942 } 943 allGood |= addCell(images, masks, weights, x0, y0, xBin, yBin, xFlip, yFlip,943 allGood |= addCell(images, masks, variances, x0, y0, xBin, yBin, xFlip, yFlip, 944 944 cell, xBinFPA, yBinFPA, true, x0Target, y0Target, 945 945 xParityTarget, yParityTarget); … … 960 960 if (allGood) { 961 961 *mosaicImage = imageMosaic(images, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, BLANK_VALUE); 962 *mosaic Weights = imageMosaic(weights, xFlip, yFlip, xBin, yBin, *xBinFPA, *yBinFPA, x0, y0, BLANK_VALUE);962 *mosaicVariances = 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 } … … 966 966 // Clean up 967 967 psFree(images); 968 psFree( weights);968 psFree(variances); 969 969 psFree(masks); 970 970 psFree(xFlip); … … 1025 1025 psImage *mosaicImage = NULL; // The mosaic image 1026 1026 psImage *mosaicMask = NULL; // The mosaic mask 1027 psImage *mosaic Weights = NULL; // The mosaic weights1027 psImage *mosaicVariances = NULL; // The mosaic variances 1028 1028 1029 1029 // Find the HDU … … 1051 1051 } 1052 1052 } 1053 if (hdu-> weights) {1054 mosaic Weights = psImageSubset(hdu->weights->data[0], bounds);1055 if (!mosaic Weights) {1056 psError(PS_ERR_UNKNOWN, false, "Unable to select weightpixels.\n");1053 if (hdu->variances) { 1054 mosaicVariances = psImageSubset(hdu->variances->data[0], bounds); 1055 if (!mosaicVariances) { 1056 psError(PS_ERR_UNKNOWN, false, "Unable to select variance pixels.\n"); 1057 1057 return false; 1058 1058 } … … 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, &mosaic Weights, &xBin, &yBin, source, targetCell, blank)) {1063 if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicVariances, &xBin, &yBin, source, targetCell, blank)) { 1064 1064 psError(PS_ERR_UNKNOWN, false, "Unable to mosaic cells.\n"); 1065 1065 return false; … … 1094 1094 newReadout->image = mosaicImage; 1095 1095 newReadout->mask = mosaicMask; 1096 newReadout-> weight = mosaicWeights;1096 newReadout->variance = mosaicVariances; 1097 1097 psFree(newReadout); // Drop reference 1098 1098 … … 1262 1262 psImage *mosaicImage = NULL; // The mosaic image 1263 1263 psImage *mosaicMask = NULL; // The mosaic mask 1264 psImage *mosaic Weights = NULL; // The mosaic weights1264 psImage *mosaicVariances = NULL; // The mosaic variances 1265 1265 1266 1266 // Find the HDU … … 1275 1275 mosaicMask = psImageSubset(hdu->masks->data[0], *fpaRegion); 1276 1276 } 1277 if (hdu-> weights) {1278 mosaic Weights = psImageSubset(hdu->weights->data[0], *fpaRegion);1277 if (hdu->variances) { 1278 mosaicVariances = psImageSubset(hdu->variances->data[0], *fpaRegion); 1279 1279 } 1280 1280 } else { 1281 1281 // Case 2 --- we need to mosaic by cut and paste 1282 1282 psTrace("psModules.camera", 1, "Case 2 mosaicking: cut and paste.\n"); 1283 if (!fpaMosaic(&mosaicImage, &mosaicMask, &mosaic Weights, &xBin, &yBin, source,1283 if (!fpaMosaic(&mosaicImage, &mosaicMask, &mosaicVariances, &xBin, &yBin, source, 1284 1284 targetChip, targetCell, blank)) { 1285 1285 psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chips.\n"); … … 1338 1338 newReadout->image = mosaicImage; 1339 1339 newReadout->mask = mosaicMask; 1340 newReadout-> weight = mosaicWeights;1340 newReadout->variance = mosaicVariances; 1341 1341 psFree(newReadout); // Drop reference 1342 1342
Note:
See TracChangeset
for help on using the changeset viewer.
