Index: branches/eam_branches/ipp-20220316/psModules/src/camera/pmFPABin.c
===================================================================
--- branches/eam_branches/ipp-20220316/psModules/src/camera/pmFPABin.c	(revision 42168)
+++ branches/eam_branches/ipp-20220316/psModules/src/camera/pmFPABin.c	(revision 42215)
@@ -67,5 +67,5 @@
             for (int y = yStart; y < yStop; y++) {
                 for (int x = xStart; x < xStop; x++) {
-		  if (inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] != 0)) {
+		  if (false && inMask && (inMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] != 0)) {
 		      for (int j = 0; j < Nbits; j++) {
 			psImageMaskType M = (psImageMaskType) pow(2,j);
@@ -89,5 +89,4 @@
             }
 	    
-	    
 	    // Values to set
             float imageValue;
@@ -101,15 +100,22 @@
             }
             outImage->data.F32[yOut][xOut] = imageValue;
-	    if (0) {
+	    if (true) {
 	      outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = maskValue;
 	    } else {
 	      outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = 0;
 	    }
-	    for (int j = 0; j < Nbits; j++) {
-	      if (bitcounter[j] > 0.5 * pxlcount) {
-		outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] |= (int) pow(2,j);
+	    // this loop is pointless if pxlcount == 0 (all masked)
+	    if (false) {
+	      if (pxlcount) {
+		for (int j = 0; j < Nbits; j++) {
+		  if (bitcounter[j] > 0.5 * pxlcount) {
+		    outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] |= (1 << j);
+		  }
+		}
+	      } else {
+		outMask->data.PS_TYPE_IMAGE_MASK_DATA[yOut][xOut] = maskValue;
 	      }
 	    }
-            xStart = xStop;
+	    xStart = xStop;
         }
         yStart = yStop;
