Index: trunk/pswarp/src/pswarpTransformReadout_Opt.c
===================================================================
--- trunk/pswarp/src/pswarpTransformReadout_Opt.c	(revision 17780)
+++ trunk/pswarp/src/pswarpTransformReadout_Opt.c	(revision 18179)
@@ -86,5 +86,5 @@
 
     // Iterate over the output image pixels (parent frame)
-    bool goodPixels = false;            // Any input pixels landing on the output image?
+    long goodPixels = 0;                // Number of input pixels landing on the output image
     for (int y = minY; y < maxY; y++) {
         if (y >= nextGridY) {
@@ -117,5 +117,5 @@
             if (inPix->y - inRow0 >= inImage->numRows) continue;
 
-            goodPixels = true;
+            goodPixels++;
 
             // XXX include mask
@@ -146,7 +146,28 @@
     psFree(grid);
 
+    // Store the variance factor and number of good pixels
+    if (goodPixels > 0) {
+        float varFactor = psImageInterpolateVarianceFactor(output->image->numCols, output->image->numRows,
+                                                           interp); // Variance factor: large --> small scale
+        psMetadataItem *vfItem = psMetadataLookup(output->analysis, PSWARP_ANALYSIS_VARFACTOR);
+        if (vfItem) {
+            psMetadataItem *goodpixItem = psMetadataLookup(output->analysis, PSWARP_ANALYSIS_GOODPIX);
+            psAssert(goodpixItem, "It should be where we left it!");
+            psAssert(vfItem->type == PS_TYPE_F32 && goodpixItem->type == PS_TYPE_S64,
+                     "Should be the type we said.");
+
+            vfItem->data.F32 += varFactor * goodPixels;
+            goodpixItem->data.S64 += goodPixels;
+        } else {
+            psMetadataAddF32(output->analysis, PS_LIST_TAIL, PSWARP_ANALYSIS_VARFACTOR, 0,
+                             "Variance factor weighted by the good pixels", varFactor * goodPixels);
+            psMetadataAddS64(output->analysis, PS_LIST_TAIL, PSWARP_ANALYSIS_GOODPIX, 0,
+                             "Number of good pixels", goodPixels);
+        }
+    }
+
     // Transform sources
     psArray *inSources = psMetadataLookupPtr(&mdok, input->analysis, "PSPHOT.SOURCES"); // Sources in source
-    if (goodPixels && mdok && inSources) {
+    if (goodPixels > 0 && mdok && inSources) {
         pswarpMapGrid *sourceGrid = pswarpMapGridFromImage(output, input, nGridX, nGridY); // Grid for sources
 
