Index: /trunk/psLib/src/fits/psFitsScale.c
===================================================================
--- /trunk/psLib/src/fits/psFitsScale.c	(revision 16196)
+++ /trunk/psLib/src/fits/psFitsScale.c	(revision 16197)
@@ -105,9 +105,24 @@
     assert(options);
 
-    double mean = options->mean, stdev = options->stdev; // Mean and standard deviation
+    // Measure the mean and stdev
+    // psImageBackground automatically excludes pixels that are non-finite, so we don't need to bother about a
+    // mask.
+    psU64 seed = p_psRandomGetSystemSeed(false);
+    psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, seed);
+    psStats *stats = psStatsAlloc(MEAN_STAT | STDEV_STAT); // Statistics object
+    if (!psImageBackground(stats, NULL, image, NULL, 0, rng)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to perform statistics on image");
+        psFree(rng);
+        psFree(stats);
+        return false;
+    }
+    psFree(rng);
+
+    double mean = psStatsGetValue(stats, MEAN_STAT); // Mean
+    double stdev = psStatsGetValue(stats, STDEV_STAT); // Standard deviation
+    psFree(stats);
     if (!isfinite(mean) || !isfinite(stdev)) {
         psError(PS_ERR_BAD_PARAMETER_VALUE, true,
-                "Mean (%f) or stdev (%f) is non-finite. Did you forget to call psFitsScaleMeasure()?",
-                mean, stdev);
+                "Mean (%f) or stdev (%f) is non-finite.", mean, stdev);
         return false;
     }
@@ -149,54 +164,4 @@
 // Public functions
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-
-// Measure statistics on the image for the PS_FITS_SCALE_STDEV_* scaling options
-bool psFitsScaleMeasure(psFits *fits,
-                        const psImage *image,
-                        const psImage *mask,
-                        psMaskType maskVal,
-                        psRandom *rng // Random number generator, or NULL
-    )
-{
-    PS_ASSERT_FITS_NON_NULL(fits, false);
-    PS_ASSERT_IMAGE_NON_NULL(image, false);
-    // Let psImageBackground worry about the mask
-    // If we don't have a RNG, we will allocate one
-
-    psFitsOptions *options = fits->options; // FITS options
-    if (!options) {
-        // No scaling desired
-        return true;
-    }
-
-    if (options->scaling != PS_FITS_SCALE_STDEV_POSITIVE &&
-        options->scaling != PS_FITS_SCALE_STDEV_NEGATIVE &&
-        options->scaling != PS_FITS_SCALE_STDEV_BOTH) {
-        // No need to do anything
-        return true;
-    }
-
-    if (!psMemIncrRefCounter(rng)) {
-        psU64 seed = p_psRandomGetSystemSeed(false);
-        rng = psRandomAlloc(PS_RANDOM_TAUS, seed);
-    }
-
-    psStats *stats = psStatsAlloc(MEAN_STAT | STDEV_STAT); // Statistics object
-    if (!psImageBackground(stats, NULL, image, mask, maskVal, rng)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to perform statistics on image");
-        psFree(rng);
-        psFree(stats);
-        return false;
-    }
-    psFree(rng);
-
-    options->mean = psStatsGetValue(stats, MEAN_STAT); // Mean
-    options->stdev = psStatsGetValue(stats, STDEV_STAT); // Standard deviation
-    psFree(stats);
-
-    return true;
-}
-
 
 bool psFitsScaleDetermine(double *bscale, // Scaling, to return
Index: /trunk/psLib/src/fits/psFitsScale.h
===================================================================
--- /trunk/psLib/src/fits/psFitsScale.h	(revision 16196)
+++ /trunk/psLib/src/fits/psFitsScale.h	(revision 16197)
@@ -6,18 +6,4 @@
 #include <psType.h>
 #include <psRandom.h>
-
-/// Measure statistics on the image for the PS_FITS_SCALE_STDEV_ options
-///
-/// NB: It is the user's responsibility to call this function if there is the possibility of scaling being
-/// performed.  The reason this is required is that this function takes a mask (required for measuring the
-/// statistics properly), whereas we would like to avoid having to pass a mask to all the other FITS
-/// functions.  Therefore, since the other FITS functions don't have the mask, while the user may, it is the
-/// user's responsibility to call this function.
-bool psFitsScaleMeasure(psFits *fits,   ///< FITS file
-                        const psImage *image, ///< Image to measure
-                        const psImage *mask, ///< Mask image, or NULL
-                        psMaskType maskVal, ///< Value to mask
-                        psRandom *rng ///< Random number generator, or NULL
-    );
 
 /// Determine BSCALE and BZERO for an image
