Changeset 42379 for trunk/psModules/src/camera/pmFPABin.c
- Timestamp:
- Feb 8, 2023, 11:54:08 AM (3 years ago)
- Location:
- trunk/psModules
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/camera/pmFPABin.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20220316/psModules (added) merged: 42145,42147,42160,42166,42168,42215,42227,42347,42352,42371,42375
- Property svn:mergeinfo changed
-
trunk/psModules/src/camera/pmFPABin.c
r34843 r42379 31 31 psImage *outImage; // Output image 32 32 if (out->image && out->image->numCols >= numColsOut && out->image->numRows >= numRowsOut) { 33 outImage = out->image;33 outImage = out->image; 34 34 } else { 35 outImage = out->image = psImageRecycle(out->image, numColsOut, numRowsOut, PS_TYPE_F32);35 outImage = out->image = psImageRecycle(out->image, numColsOut, numRowsOut, PS_TYPE_F32); 36 36 } 37 37 38 38 psImage *outMask; // Output mask 39 39 if (out->mask && out->mask->numCols >= numColsOut && out->mask->numRows >= numRowsOut) { 40 outMask = out->mask;40 outMask = out->mask; 41 41 } else { 42 outMask = out->mask = psImageRecycle(out->mask, numColsOut, numRowsOut, PS_TYPE_IMAGE_MASK);42 outMask = out->mask = psImageRecycle(out->mask, numColsOut, numRowsOut, PS_TYPE_IMAGE_MASK); 43 43 } 44 44 … … 50 50 int yStart = psImageBinningGetFineY(binning, 0); // Starting input y for binning 51 51 for (int yOut = 0; yOut < numRowsOut; yOut++) { 52 int yStop = psImageBinningGetFineY(binning, yOut + 1); // Stopping input y for binning53 yStop = PS_MIN(yStop, yLast);54 int xStart = psImageBinningGetFineX(binning, 0); // Starting input x for binning55 for (int xOut = 0; xOut < numColsOut; xOut++) {56 int xStop = psImageBinningGetFineX(binning, xOut + 1); // Stopping input x for binning57 xStop = PS_MIN(xStop, xLast);52 int yStop = psImageBinningGetFineY(binning, yOut + 1); // Stopping input y for binning 53 yStop = PS_MIN(yStop, yLast); 54 int xStart = psImageBinningGetFineX(binning, 0); // Starting input x for binning 55 for (int xOut = 0; xOut < numColsOut; xOut++) { 56 int xStop = psImageBinningGetFineX(binning, xOut + 1); // Stopping input x for binning 57 xStop = PS_MIN(xStop, xLast); 58 58 59 float sum = 0.0; // Sum of pixels60 int numPix = 0; // Number of pixels59 float sum = 0.0; // Sum of pixels 60 int numPix = 0; // Number of pixels 61 61 62 62 for (int j = 0; j < Nbits; j++) { // Reset bit counter 63 bitcounter[j] = 0;63 bitcounter[j] = 0; 64 64 } 65 65 pxlcount = 0; 66 66 67 for (int y = yStart; y < yStop; y++) { 68 for (int x = xStart; x < xStop; x++) { 69 if (inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] != 0)) { 70 for (int j = 0; j < Nbits; j++) { 71 psImageMaskType M = (psImageMaskType) pow(2,j); 72 if (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & M) { 73 bitcounter[j]++; 67 for (int y = yStart; y < yStop; y++) { 68 for (int x = xStart; x < xStop; x++) { 69 if (false && inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] != 0)) { 70 for (int j = 0; j < Nbits; j++) { 71 psImageMaskType M = (psImageMaskType) pow(2,j); 72 if (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & M) { 73 bitcounter[j]++; 74 } 74 75 } 75 }76 76 } 77 77 78 if (inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) {79 continue;80 }81 if (!isfinite(inImage->data.F32[y][x])) {82 continue;83 }84 sum += inImage->data.F32[y][x];85 numPix++;78 if (inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] & maskVal)) { 79 continue; 80 } 81 if (!isfinite(inImage->data.F32[y][x])) { 82 continue; 83 } 84 sum += inImage->data.F32[y][x]; 85 numPix++; 86 86 87 87 88 } 89 } 90 88 } 89 } 91 90 92 91 // Values to set 93 float imageValue;92 float imageValue; 94 93 psImageMaskType maskValue; 95 if (numPix > 0) { 96 imageValue = sum / numPix; 97 maskValue = 0; 98 } else { 99 imageValue = NAN; 100 maskValue = maskVal; 101 } 102 outImage->data.F32[yOut][xOut] = imageValue; 103 if (0) { 104 outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = maskValue; 94 if (numPix > 0) { 95 imageValue = sum / numPix; 96 maskValue = 0; 105 97 } else { 106 outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = 0; 98 imageValue = NAN; 99 maskValue = maskVal; 107 100 } 108 for (int j = 0; j < Nbits; j++) { 109 if (bitcounter[j] > 0.5 * pxlcount) { 110 outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] |= (int) pow(2,j); 111 } 101 outImage->data.F32[yOut][xOut] = imageValue; 102 if (true) { 103 outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = maskValue; 104 } else { 105 outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = 0; 112 106 } 113 xStart = xStop; 114 } 115 yStart = yStop; 107 // this loop is pointless if pxlcount == 0 (all masked) 108 if (false) { 109 if (pxlcount) { 110 for (int j = 0; j < Nbits; j++) { 111 if (bitcounter[j] > 0.5 * pxlcount) { 112 outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] |= (1 << j); 113 } 114 } 115 } else { 116 outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = maskValue; 117 } 118 } 119 xStart = xStop; 120 } 121 yStart = yStop; 116 122 } 117 123 … … 120 126 out->data_exists = true; 121 127 if (out->parent) { 122 pmCell *outCell = out->parent; // Output cell123 outCell->data_exists = outCell->parent->data_exists = true;128 pmCell *outCell = out->parent; // Output cell 129 outCell->data_exists = outCell->parent->data_exists = true; 124 130 125 // We would copy the concepts from the input cell, except that is done by pmFPACopy,126 // pmChipCopyStructure, etc. This function just does the mechanics of binning.127 // We don't even update the CELL.XBIN, CELL.YBIN because that would apply the correction twice.131 // We would copy the concepts from the input cell, except that is done by pmFPACopy, 132 // pmChipCopyStructure, etc. This function just does the mechanics of binning. 133 // We don't even update the CELL.XBIN, CELL.YBIN because that would apply the correction twice. 128 134 } 129 135
Note:
See TracChangeset
for help on using the changeset viewer.
