Index: trunk/psphot/src/psphotImageMedian.c
===================================================================
--- trunk/psphot/src/psphotImageMedian.c	(revision 10172)
+++ trunk/psphot/src/psphotImageMedian.c	(revision 10277)
@@ -116,5 +116,15 @@
 
             // XXX the value of the upper and lower cuts probably should be studied...
-            psStats *stats = psImageBackground(subset, submask, 0xff, 0.25, 0.75, MAX_SAMPLE_PIXELS, statsOption, rng);
+            psStats *stats = psImageBackground(subset, submask, 0xff, 0.25, 0.75, MAX_SAMPLE_PIXELS,
+					       statsOption, rng);
+	    if (stats == NULL) {
+		stats = psImageBackground(subset, submask, 0xff, 0.25, 0.75, MAX_SAMPLE_PIXELS,
+					  PS_STAT_ROBUST_MEDIAN, rng);
+		if (stats == NULL) {
+		    psAbort(PS_FILE_LINE, "Failed to estimate background using ROBUST_MEDIAN for "
+			    "(%dx%d, (row0,col0) = (%d,%d)",
+			    subset->numRows, subset->numCols, subset->row0, subset->col0);
+		}
+	    }
 	    if (stats->options & PS_STAT_ROBUST_QUARTILE) {
 		modelData[iy][ix] = stats->robustMedian + SKY_BIAS;
