Index: /branches/eam_branches/ipp-20101205/psLib/src/imageops/psImageBackground.c
===================================================================
--- /branches/eam_branches/ipp-20101205/psLib/src/imageops/psImageBackground.c	(revision 30956)
+++ /branches/eam_branches/ipp-20101205/psLib/src/imageops/psImageBackground.c	(revision 30957)
@@ -95,5 +95,5 @@
     } else {
         // 2011/03/16 - MWV: Hmmm... this overwites the previously defined Npixels that only counted finite-valued pixels.
-        Npixels = nx * ny; 
+        Npixels = nx * ny;
 
         // Subsample all pixels
@@ -108,6 +108,6 @@
         //   2) Go through this ordering up to Nsubset to select pixels
         psVector *frndPixelOrder = psVectorAlloc(Npixels, PS_TYPE_F32);
-        for (long i = 0; i < Npixels; i++) {  
-            frndPixelOrder->data.F32[i] = psRandomUniform(rng);  
+        for (long i = 0; i < Npixels; i++) {
+            frndPixelOrder->data.F32[i] = psRandomUniform(rng);
         }
         // Now sort the array so that we end up with a list of the pixels in random order
@@ -115,10 +115,5 @@
         // Now loop in our new sorted order
         //  Paul Price suggests fixing this up so that it gets all Nsubset pixels, skipping over the masked ones.
-        //  This would be implemented with a while loop.  I'm leaving this comment-out till I test the simpler version that just makes this one conceptual change.
-        //  Ah, we can just use n
-        int i=0;
-        while ((n < Nsubset) && (i < Npixels)) {
-            i++;
-//        for (long i = 0; i < Nsubset; i++) {
+        for (long i = 0; n < Nsubset && i < Npixels; i++) {
             int pixel = frndSortedPixelOrder->data.S32[i];
             int ix = pixel % nx;
