Index: trunk/psModules/src/objects/pmFootprintFind.c
===================================================================
--- trunk/psModules/src/objects/pmFootprintFind.c	(revision 29004)
+++ trunk/psModules/src/objects/pmFootprintFind.c	(revision 34199)
@@ -24,4 +24,5 @@
 
 // XXX EAM : why use WSPAN in here rather than pmSpan?
+// XXX WES : can't use pmSpan because does not have an id
 typedef struct {                        /* run-length code for part of object*/
    int id;                              /* ID for object */
@@ -114,7 +115,10 @@
 
        in_span = 0;                      /* not in a span */
+       int id_last_connection = 0;
        for (j = 0; j < numCols; j++) {
            double pixVal = floatImg->data.F32[i][j]; // Value of pixel
+           // If pixVal is less than threshold and we are working on a, span end it.
            if (pixVal < threshold) {
+               // below threshold. If in a span close it out
                if (in_span) {
                    if(nspan >= size_spans) {
@@ -130,6 +134,19 @@
 
                    in_span = 0;
+                   id_last_connection = 0;
                }
            } else {                       /* a pixel to fix */
+               // Above theshold. There are 5 choices for the id of this pixel based on whether they are
+               // part of a span (non-zero)
+               // This diagram shows the priority which we check
+               //       
+               //                       col
+               //                   j-1   j   j+1
+               // row i              1    5 
+               // row i + 1          2    3    4
+               //
+               // In case 4 we have a pixel that is not connected to the left are connecting with 
+               // an existing span so need to identify whether it is connected
+               // to the same footprint as the current span (if we are in one)
                if(idc[j - 1] != 0) {
                    id = idc[j - 1];
@@ -157,9 +174,20 @@
                 * Do we need to merge ID numbers? If so, make suitable entries in aliases[]
                 */
-               if(idp[j + 1] != 0 && idp[j + 1] != id) {
-                   aliases[resolve_alias(aliases, idp[j + 1])] =
-                       resolve_alias(aliases, id);
-
-                   idc[j] = id = idp[j + 1];
+               if (idp[j + 1] != 0 && idp[j + 1] != id && idp[j + 1] != id_last_connection) {
+                   int resolved_lower_right = resolve_alias(aliases, idp[j + 1]);
+                   int resolved_current = resolve_alias(aliases, id);
+                   aliases[resolved_lower_right] = resolved_current;
+
+                   // now we choose the id to continue to use to set pixels in the current span.
+                   // We choose the higher value because future alias resolutions will be faster
+                   // since the alias chain goes from lower ids to higher. This is about 4 times
+                   // faster for complex footprints.
+                   if (resolved_current <= idp[j + 1]) {
+                       idc[j] = id = idp[j + 1];
+                       id_last_connection = 0;
+                   } else {
+                       idc[j] = id = resolved_current;
+                       id_last_connection = idp[j + 1];
+                   }
                }
            }
