Index: /branches/eam_branches/ipp-20110213/psModules/src/objects/pmFootprintCullPeaks.c
===================================================================
--- /branches/eam_branches/ipp-20110213/psModules/src/objects/pmFootprintCullPeaks.c	(revision 30751)
+++ /branches/eam_branches/ipp-20110213/psModules/src/objects/pmFootprintCullPeaks.c	(revision 30752)
@@ -70,5 +70,5 @@
     // XXX test point
     // pmPeak *myPeak = fp->peaks->data[0];
-    // if ((fabs(myPeak->x - 320) < 30) && (fabs(myPeak->y - 430) < 30)) {
+    // if ((fabs(myPeak->x - 205) < 100) && (fabs(myPeak->y - 806) < 100)) {
     // 	fprintf (stderr, "test peak\n");
     // }
@@ -138,5 +138,6 @@
         bool keep = true;
         for (int j = 0; keep && !peak->assigned && (j < brightPeaks->n); j++) {
-            const pmPeak *peak2 = fp->peaks->data[j];
+            // const pmPeak *peak2 = fp->peaks->data[j]; XXX isn't this an error?  we only care about the kept brighter peak, right?
+            const pmPeak *peak2 = brightPeaks->data[j];
             int x2 = peak2->x - subImg->col0;
             int y2 = peak2->y - subImg->row0;
@@ -150,5 +151,4 @@
 	    continue;
 	}
-
         psArrayAdd (brightPeaks, 128, fp->peaks->data[i]);
     }
Index: /branches/eam_branches/ipp-20110213/psModules/src/objects/pmFootprintFindAtPoint.c
===================================================================
--- /branches/eam_branches/ipp-20110213/psModules/src/objects/pmFootprintFindAtPoint.c	(revision 30751)
+++ /branches/eam_branches/ipp-20110213/psModules/src/objects/pmFootprintFindAtPoint.c	(revision 30752)
@@ -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;
 	    }
