Index: /trunk/ppBackground/src/ppBackground.h
===================================================================
--- /trunk/ppBackground/src/ppBackground.h	(revision 28295)
+++ /trunk/ppBackground/src/ppBackground.h	(revision 28296)
@@ -39,5 +39,6 @@
 /// Restore the background to an image
 bool ppBackgroundRestore(
-    pmChip *chip,                       // Input chip
+    pmChip *out,                        // Output chip
+    const pmChip *chip,                 // Input chip
     const pmChip *background,           // Chip with background model
     const pmChip *pattern,              // Chip with pattern
Index: /trunk/ppBackground/src/ppBackgroundLoop.c
===================================================================
--- /trunk/ppBackground/src/ppBackgroundLoop.c	(revision 28295)
+++ /trunk/ppBackground/src/ppBackgroundLoop.c	(revision 28296)
@@ -125,10 +125,11 @@
             }
             pmFPAfileActivate(config->files, true, NULL);
-            pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");
+            //            pmFPAfileActivate(config->files, false, "PPBACKGROUND.PATTERN");
         }
 
+        pmChip *outChip = pmFPAfileThisChip(config->files, view, "PPBACKGROUND.OUTPUT"); // Chip for output
         pmChip *patternChip = patternFile ? pmFPAviewThisChip(view, patternMosaic) : NULL; // Chip with pattern
         pmChip *bgChip = bgFile ? pmFPAviewThisChip(view, bgFile->fpa) : NULL; // Chip with background model
-        if (!ppBackgroundRestore(chip, bgChip, patternChip, view, config)) {
+        if (!ppBackgroundRestore(outChip, chip, bgChip, patternChip, view, config)) {
             psError(psErrorCodeLast(), false, "Unable to replace background");
             return false;
Index: /trunk/ppBackground/src/ppBackgroundRestore.c
===================================================================
--- /trunk/ppBackground/src/ppBackgroundRestore.c	(revision 28295)
+++ /trunk/ppBackground/src/ppBackgroundRestore.c	(revision 28296)
@@ -6,7 +6,8 @@
 #include "ppBackground.h"
 
-bool ppBackgroundRestore(pmChip *chip, const pmChip *background, const pmChip *pattern,
+bool ppBackgroundRestore(pmChip *out, const pmChip *chip, const pmChip *background, const pmChip *pattern,
                          const pmFPAview *oldView, pmConfig *config)
 {
+    PS_ASSERT_PTR_NON_NULL(out, false);
     PS_ASSERT_PTR_NON_NULL(chip, false);
     PS_ASSERT_PTR_NON_NULL(oldView, false);
@@ -17,15 +18,25 @@
     view->readout = 0;
 
-    pmReadout *ro = pmFPAviewThisReadout(view, chip->parent);
-    if (!ro || !ro->data_exists) {
+    pmReadout *inRO = pmFPAviewThisReadout(view, chip->parent);
+    if (!inRO || !inRO->data_exists) {
         psError(PPBACKGROUND_ERR_CONFIG, true, "Readout has no data");
         return false;
     }
-    psImage *image = ro->image, *mask = ro->mask;           // Image to correct
-    int numCols = image->numCols, numRows = image->numRows; // Size of image
+    const psImage *inImage = inRO->image, *inMask = inRO->mask;   // Input image
+    int numCols = inImage->numCols, numRows = inImage->numRows; // Size of image
+
+    pmReadout *outRO = pmFPAviewThisReadout(view, out->parent);
+    if (!outRO) {
+        pmCell *outCell = pmFPAviewThisCell(view, out->parent);
+        outRO = pmReadoutAlloc(outCell);
+        psFree(outRO);                  // Drop reference
+    }
+    outRO->image = psImageCopy(outRO->image, inImage, PS_TYPE_F32);
+    outRO->mask = psImageCopy(outRO->mask, inMask, PS_TYPE_IMAGE_MASK);
+    psImage *outImage = outRO->image, *outMask = outRO->mask; // Output image
 
     if (background) {
         pmReadout *bgRO = pmFPAviewThisReadout(view, background->parent); // Readout with background
-        psImageBinning *binning = psphotBackgroundBinning(image, config);
+        psImageBinning *binning = psphotBackgroundBinning(outImage, config);
         if (!binning) {
             psError(psErrorCodeLast(), false, "Unable to find background binning");
@@ -49,5 +60,5 @@
         for (int y = 0; y < numRows; y++) {
             for (int x = 0; x < numCols; x++) {
-                image->data.F32[y][x] += bgImage->data.F32[y][x];
+                outImage->data.F32[y][x] += bgImage->data.F32[y][x];
             }
         }
@@ -61,13 +72,13 @@
         for (int y = 0; y < numRows; y++) {
             for (int x = 0; x < numCols; x++) {
-                image->data.F32[y][x] += patternImage->data.F32[y][x];
-                mask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= patternMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x];
+                outImage->data.F32[y][x] = patternImage->data.F32[y][x];
+                outMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] |= patternMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x];
             }
         }
     }
 
-    ro->data_exists = true;
-    ro->parent->data_exists = true;
-    ro->parent->parent->data_exists = true;
+    outRO->data_exists = true;
+    outRO->parent->data_exists = true;
+    outRO->parent->parent->data_exists = true;
 
     return true;
