Index: trunk/ppImage/src/ppImageLoop.c
===================================================================
--- trunk/ppImage/src/ppImageLoop.c	(revision 18556)
+++ trunk/ppImage/src/ppImageLoop.c	(revision 18724)
@@ -87,10 +87,4 @@
             ESCAPE ("Unable to mosaic chip");
 
-        if (!ppImageRebinChip(config, view, "PPIMAGE.BIN1"))
-            ESCAPE ("Unable to bin chip (level 1).");
-
-        if (!ppImageRebinChip(config, view, "PPIMAGE.BIN2"))
-            ESCAPE ("Unable to bin chip (level 2).");
-
         // we perform photometry on the readouts of this chip in the output
         if (options->doPhotom) {
@@ -103,4 +97,11 @@
 		ESCAPE ("Unable to replace masked pixels with background level");
 	}
+
+	// binning (used for display) must take place after the background is replaced, if desired
+        if (!ppImageRebinChip(config, view, options, "PPIMAGE.BIN1"))
+            ESCAPE ("Unable to bin chip (level 1).");
+
+        if (!ppImageRebinChip(config, view, options, "PPIMAGE.BIN2"))
+            ESCAPE ("Unable to bin chip (level 2).");
 
         // Close cells (XXX shouldn't pmFPAfileClose iterate down as needed?)
