Index: trunk/psModules/src/objects/pmFootprintFindAtPoint.c
===================================================================
--- trunk/psModules/src/objects/pmFootprintFindAtPoint.c	(revision 29004)
+++ trunk/psModules/src/objects/pmFootprintFindAtPoint.c	(revision 31153)
@@ -31,4 +31,8 @@
  *
  * This is the guts of pmFootprintsFindAtPoint
+ * 
+ * This function is/was ill-defined if pixel values are NAN.  we should either treat NAN as >
+ * threshold or < threshold, but the current (r29004) code is ambiguous.
+ * EAM : change code so NAN is always > threshold
  */
 bool pmFootprintSpansBuild(pmFootprint *fp, // the footprint that we're building
@@ -103,5 +107,6 @@
         for (int j = x0 - 1; j >= -1; j--) {
             double pixVal = (j < 0) ? threshold - 100 : (F32 ? imgRowF32[j] : imgRowS32[j]);
-            if ((maskRow[j] & PM_STARTSPAN_DETECTED) || pixVal < threshold) {
+	    bool belowThreshold = (pixVal < threshold) && isfinite(pixVal);
+            if ((maskRow[j] & PM_STARTSPAN_DETECTED) || belowThreshold)  {
                 if (j < x0 - 1) {       // we found some pixels above threshold
                     nx0 = j + 1;
@@ -119,5 +124,6 @@
             for (int j = nx0 + 1; j <= numCols; j++) {
                 double pixVal = (j >= numCols) ? threshold - 100 : (F32 ? imgRowF32[j] : imgRowS32[j]);
-                if ((maskRow[j] & PM_STARTSPAN_DETECTED) || pixVal < threshold) {
+		bool belowThreshold = (pixVal < threshold) && isfinite(pixVal);
+                if ((maskRow[j] & PM_STARTSPAN_DETECTED) || belowThreshold) {
                     nx1 = j - 1;
                     break;
@@ -146,10 +152,12 @@
         for (int j = nx1 + 1; j <= x1 + 1; j++) {
             double pixVal = (j >= numCols) ? threshold - 100 : (F32 ? imgRowF32[j] : imgRowS32[j]);
-            if (!(maskRow[j] & PM_STARTSPAN_DETECTED) && pixVal >= threshold) {
+	    bool aboveThreshold = (pixVal >= threshold) || !isfinite(pixVal);
+            if (!(maskRow[j] & PM_STARTSPAN_DETECTED) && aboveThreshold) {
                 int sx0 = j++;          // span that we're working on is sx0:sx1
                 int sx1 = -1;           // We know that if we got here, we'll also set sx1
                 for (; j <= numCols; j++) {
                     double pixVal = (j >= numCols) ? threshold - 100 : (F32 ? imgRowF32[j] : imgRowS32[j]);
-                    if ((maskRow[j] & PM_STARTSPAN_DETECTED) || pixVal < threshold) { // end of span
+		    bool belowThreshold = (pixVal < threshold) && isfinite(pixVal);
+                    if ((maskRow[j] & PM_STARTSPAN_DETECTED) || belowThreshold) { // end of span
                         sx1 = j;
                         break;
@@ -306,5 +314,6 @@
 	for (i = col; i >= 0; i--) {
 	    pixVal = F32 ? imgRowF32[i] : imgRowS32[i];
-	    if ((maskRow[i] & PM_STARTSPAN_DETECTED) || pixVal < threshold) {
+	    bool belowThreshold = (pixVal < threshold) && isfinite(pixVal);
+	    if ((maskRow[i] & PM_STARTSPAN_DETECTED) || belowThreshold) {
 		break;
 	    }
@@ -313,5 +322,6 @@
 	for (i = col; i < numCols; i++) {
 	    pixVal = F32 ? imgRowF32[i] : imgRowS32[i];
-	    if ((maskRow[i] & PM_STARTSPAN_DETECTED) || pixVal < threshold) {
+	    bool belowThreshold = (pixVal < threshold) && isfinite(pixVal);
+	    if ((maskRow[i] & PM_STARTSPAN_DETECTED) || belowThreshold) {
 		break;
 	    }
