Index: trunk/ppMerge/src/ppMergeLoop.c
===================================================================
--- trunk/ppMerge/src/ppMergeLoop.c	(revision 24797)
+++ trunk/ppMerge/src/ppMergeLoop.c	(revision 24837)
@@ -65,4 +65,6 @@
     int fringeSmoothX = psMetadataLookupS32(NULL, arguments, "FRINGE.XSMOOTH"); // Smoothing regions in x
     int fringeSmoothY = psMetadataLookupS32(NULL, arguments, "FRINGE.YSMOOTH"); // Smoothing regions in y
+    bool fringeSmooth = psMetadataLookupBool(NULL, arguments, "FRINGE.SMOOTH"); // Smooth the output image?
+    float fringeSmoothSigma = psMetadataLookupF32(NULL, arguments, "FRINGE.SMOOTH.SIGMA"); // Smooth the output image?
 
     // set the mask and mark bit values based on the named masks
@@ -416,6 +418,15 @@
             // Put the new readout into the cell after the existing readouts.
             if (type == PPMERGE_TYPE_FRINGE && outRO) {
-                pmFringeRegions *regions = pmFringeRegionsAlloc(fringeNum, fringeSize, fringeSize,
-                                                                fringeSmoothX, fringeSmoothY);
+		if (fringeSmooth) {
+		    if (outRO->mask) {
+			psImage *smoothed = psImageSmoothMask (NULL, outRO->image, outRO->mask, maskVal, fringeSmoothSigma, 3, 0.2);
+			psFree (outRO->image);
+			outRO->image = smoothed;
+		    } else {
+			psImageSmooth (outRO->image, fringeSmoothSigma, 3);
+		    }
+		}
+
+                pmFringeRegions *regions = pmFringeRegionsAlloc(fringeNum, fringeSize, fringeSize, fringeSmoothX, fringeSmoothY);
                 pmFringeStats *fringe = pmFringeStatsMeasure(regions, outRO, maskVal);
                 psFree(regions);
@@ -429,5 +440,9 @@
                 fringes->data[0] = fringe;
 
-                pmFringesFormat(outCell, NULL, fringes);
+                // XXX replaced this : pmFringesFormat(outCell, NULL, fringes);
+		if (!psMetadataAdd(outCell->analysis, PS_LIST_TAIL, "FRINGE.MEASUREMENTS", PS_DATA_ARRAY, "Fringes", fringes)) {
+		    psError(PS_ERR_UNKNOWN, false, "Unable to add fringe to analysis metadata\n");
+		    goto ERROR;
+		}
                 psFree(fringes);        // Drop reference
             }
