Changeset 7606
- Timestamp:
- Jun 20, 2006, 11:10:29 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPAMosaic.c (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPAMosaic.c
r7605 r7606 447 447 // Set up the image 448 448 // Since both upper and lower values are inclusive, we need to add one to the size 449 float xSize = (float)(xMax - xMin+ 1) / (float)xBinTarget;449 float xSize = (float)(xMax + 1) / (float)xBinTarget; 450 450 if (xSize - (int)xSize > 0) { 451 451 xSize += 1; 452 452 } 453 float ySize = (float)(yMax - yMin+ 1) / (float)yBinTarget;453 float ySize = (float)(yMax + 1) / (float)yBinTarget; 454 454 if (ySize - (int)ySize > 0) { 455 455 ySize += 1; … … 629 629 int *xBinMin, // The minimum x binning, returned 630 630 int *yBinMin, // The minimum y binning, returned 631 bool chipStuff // Worry about chip stuff as well? 631 bool chipStuff, // Worry about chip stuff as well? 632 int x0Target, int y0Target, // Target x0 and y0 offsets 633 int xParityTarget, int yParityTarget // Target parities 632 634 ) 633 635 { … … 743 745 744 746 // Set the flips on the basis of the parity 745 if (xParityCell * xParityChip == -1) { 747 if (xParityCell * xParityChip == xParityTarget) { 748 xFlip->data.U8[index] = 0; 749 } else { 746 750 xFlip->data.U8[index] = 1; 751 } 752 if (yParityCell * yParityChip == yParityTarget) { 753 yFlip->data.U8[index] = 0; 747 754 } else { 748 xFlip->data.U8[index] = 0;749 }750 if (yParityCell * yParityChip == -1) {751 755 yFlip->data.U8[index] = 1; 752 } else { 753 yFlip->data.U8[index] = 0; 754 } 755 756 x0->data.S32[index] = x0Chip + x0Cell; 757 y0->data.S32[index] = y0Chip + y0Cell; 756 } 757 758 x0->data.S32[index] = x0Chip + x0Cell - x0Target; 759 y0->data.S32[index] = y0Chip + y0Cell - y0Target; 758 760 759 761 // Add the readout to the array of images to be mosaicked … … 783 785 psImage **mosaicWeights, // The mosaic weights, to be returned 784 786 int *xBinChip, int *yBinChip, // The binning in x and y, to be returned 785 const pmChip *chip // Chip to mosaic 787 const pmChip *chip, // Chip to mosaic 788 const pmCell *targetCell // Cell to which to mosaic 786 789 ) 787 790 { … … 789 792 assert(mosaicMask); 790 793 assert(mosaicWeights); 794 assert(xBinChip); 795 assert(yBinChip); 791 796 assert(chip); 797 assert(targetCell); 792 798 793 799 psArray *images = psArrayAlloc(0); // Array of images that will be mosaicked … … 801 807 psVector *yFlip = psVectorAlloc(0, PS_TYPE_U8); // Flip in y? 802 808 809 // Get the target characteristics 810 bool mdok = true; // Status of MD lookup 811 int x0Target = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.X0"); 812 if (!mdok) { 813 psLogMsg(__func__, PS_LOG_WARN, "CELL.X0 is not set for the target cell; assuming 0.\n"); 814 } 815 int y0Target = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.Y0"); 816 if (!mdok) { 817 psLogMsg(__func__, PS_LOG_WARN, "CELL.Y0 is not set for the target cell; assuming 0.\n"); 818 } 819 int xParityTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.XPARITY"); 820 if (!mdok || (xParityTarget != -1 && xParityTarget != 1)) { 821 psLogMsg(__func__, PS_LOG_WARN, "CELL.XPARITY is not set for the target cell; assuming 1.\n"); 822 xParityTarget = 1; 823 } 824 int yParityTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.YPARITY"); 825 if (!mdok || (yParityTarget != -1 && yParityTarget != 1)) { 826 psLogMsg(__func__, PS_LOG_WARN, "CELL.YPARITY is not set for the target cell; assuming 1.\n"); 827 yParityTarget = 1; 828 } 829 803 830 // Binning for the mosaicked chip is the minimum binning allowed by the cells 804 831 *xBinChip = INT_MAX; … … 814 841 } 815 842 allGood |= addCell(images, masks, weights, x0, y0, xBin, yBin, xFlip, yFlip, 816 cell, xBinChip, yBinChip, false); 843 cell, xBinChip, yBinChip, false, x0Target, y0Target, 844 xParityTarget, yParityTarget); 845 } 846 847 // Check to see if the target has a smaller binning in mind 848 int xBinTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.XBIN"); 849 if (!mdok || xBinTarget == 0) { 850 psLogMsg(__func__, PS_LOG_WARN, "CELL.XBIN is not set for the target cell; assuming %d.\n",*xBinChip); 851 } else { 852 *xBinChip = xBinTarget; 853 } 854 int yBinTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.YBIN"); 855 if (!mdok || yBinTarget == 0) { 856 psLogMsg(__func__, PS_LOG_WARN, "CELL.YBIN is not set for the target cell; assuming %d.\n",*yBinChip); 857 } else { 858 *yBinChip = yBinTarget; 817 859 } 818 860 … … 843 885 psImage **mosaicWeights, // The mosaic weights, to be returned 844 886 int *xBinFPA, int *yBinFPA, // The binning in x and y, to be returned 845 const pmFPA *fpa // FPA to mosaic 887 const pmFPA *fpa, // FPA to mosaic 888 const pmChip *targetChip, // Chip to which to mosaic 889 const pmCell *targetCell // Cell to which to mosaic 846 890 ) 847 891 { … … 849 893 assert(mosaicMask); 850 894 assert(mosaicWeights); 895 assert(xBinFPA); 896 assert(yBinFPA); 851 897 assert(fpa); 898 assert(targetChip); 899 assert(targetCell); 852 900 853 901 psArray *images = psArrayAlloc(0); // Array of images that will be mosaicked … … 861 909 psVector *yFlip = psVectorAlloc(0, PS_TYPE_U8); // Flip in y? 862 910 911 // Get the target characteristics 912 bool mdok = true; // Status of MD lookup 913 int x0Target = psMetadataLookupS32(&mdok, targetChip->concepts, "CHIP.X0"); 914 if (!mdok) { 915 psLogMsg(__func__, PS_LOG_WARN, "CHIP.X0 is not set for the target chip; assuming 0.\n"); 916 } 917 int y0Target = psMetadataLookupS32(&mdok, targetChip->concepts, "CHIP.Y0"); 918 if (!mdok) { 919 psLogMsg(__func__, PS_LOG_WARN, "CHIP.Y0 is not set for the target chip; assuming 0.\n"); 920 } 921 x0Target += psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.X0"); 922 if (!mdok) { 923 psLogMsg(__func__, PS_LOG_WARN, "CELL.X0 is not set for the target cell; assuming 0.\n"); 924 } 925 y0Target += psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.Y0"); 926 if (!mdok) { 927 psLogMsg(__func__, PS_LOG_WARN, "CELL.Y0 is not set for the target cell; assuming 0.\n"); 928 } 929 int xParityChipTarget = psMetadataLookupS32(&mdok, targetChip->concepts, "CHIP.XPARITY"); 930 if (!mdok || (xParityChipTarget != -1 && xParityChipTarget != 1)) { 931 psLogMsg(__func__, PS_LOG_WARN, "CHIP.XPARITY is not set for the target chip; assuming 1.\n"); 932 xParityChipTarget = 1; 933 } 934 int yParityChipTarget = psMetadataLookupS32(&mdok, targetChip->concepts, "CHIP.YPARITY"); 935 if (!mdok || (yParityChipTarget != -1 && yParityChipTarget != 1)) { 936 psLogMsg(__func__, PS_LOG_WARN, "CHIP.YPARITY is not set for the target chip; assuming 1.\n"); 937 yParityChipTarget = 1; 938 } 939 int xParityCellTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.XPARITY"); 940 if (!mdok || (xParityCellTarget != -1 && xParityCellTarget != 1)) { 941 psLogMsg(__func__, PS_LOG_WARN, "CELL.XPARITY is not set for the target cell; assuming 1.\n"); 942 xParityCellTarget = 1; 943 } 944 int yParityCellTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.YPARITY"); 945 if (!mdok || (yParityCellTarget != -1 && yParityCellTarget != 1)) { 946 psLogMsg(__func__, PS_LOG_WARN, "CELL.YPARITY is not set for the target cell; assuming 1.\n"); 947 yParityCellTarget = 1; 948 } 949 int xParityTarget = xParityChipTarget * xParityCellTarget; 950 int yParityTarget = yParityChipTarget * yParityCellTarget; 951 863 952 // Binning for the mosaicked chip is the minimum binning allowed by the cells 864 953 *xBinFPA = INT_MAX; … … 880 969 } 881 970 allGood |= addCell(images, masks, weights, x0, y0, xBin, yBin, xFlip, yFlip, 882 cell, xBinFPA, yBinFPA, true); 883 } 971 cell, xBinFPA, yBinFPA, true, x0Target, y0Target, 972 xParityTarget, yParityTarget); 973 } 974 } 975 976 // Check to see if the target has a smaller binning in mind 977 int xBinTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.XBIN"); 978 if (!mdok || xBinTarget == 0) { 979 psLogMsg(__func__, PS_LOG_WARN, "CELL.XBIN is not set for the target cell; assuming %d.\n", *xBinFPA); 980 } else { 981 *xBinFPA = xBinTarget; 982 } 983 int yBinTarget = psMetadataLookupS32(&mdok, targetCell->concepts, "CELL.YBIN"); 984 if (!mdok || yBinTarget == 0) { 985 psLogMsg(__func__, PS_LOG_WARN, "CELL.YBIN is not set for the target cell; assuming %d.\n", *yBinFPA); 986 } else { 987 *yBinFPA = yBinTarget; 884 988 } 885 989 … … 975 1079 // Case 2 --- we need to mosaic by cut and paste 976 1080 psTrace(__func__, 1, "Case 2 mosaicking: cut and paste.\n"); 977 if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source )) {1081 if (!chipMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source, targetCell)) { 978 1082 psError(PS_ERR_UNKNOWN, false, "Unable to mosaic cells.\n"); 979 1083 return false; … … 1056 1160 // Case 2 --- we need to mosaic by cut and paste 1057 1161 psTrace(__func__, 1, "Case 2 mosaicking: cut and paste.\n"); 1058 if (!fpaMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source)) { 1162 if (!fpaMosaic(&mosaicImage, &mosaicMask, &mosaicWeights, &xBin, &yBin, source, 1163 targetChip, targetCell)) { 1059 1164 psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chips.\n"); 1060 1165 return false;
Note:
See TracChangeset
for help on using the changeset viewer.
