IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34199


Ignore:
Timestamp:
Jul 24, 2012, 3:35:32 PM (14 years ago)
Author:
bills
Message:

When building footprints save the highest id in an alias chain in the current span.
Searching for aliases is more efficient that way. This speeds up the analysis if
really complex footprints during pmFootprintCullPeaks when the input image has a lot
of NAN pixels.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmFootprintFind.c

    r29004 r34199  
    2424
    2525// XXX EAM : why use WSPAN in here rather than pmSpan?
     26// XXX WES : can't use pmSpan because does not have an id
    2627typedef struct {                        /* run-length code for part of object*/
    2728   int id;                              /* ID for object */
     
    114115
    115116       in_span = 0;                      /* not in a span */
     117       int id_last_connection = 0;
    116118       for (j = 0; j < numCols; j++) {
    117119           double pixVal = floatImg->data.F32[i][j]; // Value of pixel
     120           // If pixVal is less than threshold and we are working on a, span end it.
    118121           if (pixVal < threshold) {
     122               // below threshold. If in a span close it out
    119123               if (in_span) {
    120124                   if(nspan >= size_spans) {
     
    130134
    131135                   in_span = 0;
     136                   id_last_connection = 0;
    132137               }
    133138           } else {                       /* a pixel to fix */
     139               // Above theshold. There are 5 choices for the id of this pixel based on whether they are
     140               // part of a span (non-zero)
     141               // This diagram shows the priority which we check
     142               //       
     143               //                       col
     144               //                   j-1   j   j+1
     145               // row i              1    5
     146               // row i + 1          2    3    4
     147               //
     148               // In case 4 we have a pixel that is not connected to the left are connecting with
     149               // an existing span so need to identify whether it is connected
     150               // to the same footprint as the current span (if we are in one)
    134151               if(idc[j - 1] != 0) {
    135152                   id = idc[j - 1];
     
    157174                * Do we need to merge ID numbers? If so, make suitable entries in aliases[]
    158175                */
    159                if(idp[j + 1] != 0 && idp[j + 1] != id) {
    160                    aliases[resolve_alias(aliases, idp[j + 1])] =
    161                        resolve_alias(aliases, id);
    162 
    163                    idc[j] = id = idp[j + 1];
     176               if (idp[j + 1] != 0 && idp[j + 1] != id && idp[j + 1] != id_last_connection) {
     177                   int resolved_lower_right = resolve_alias(aliases, idp[j + 1]);
     178                   int resolved_current = resolve_alias(aliases, id);
     179                   aliases[resolved_lower_right] = resolved_current;
     180
     181                   // now we choose the id to continue to use to set pixels in the current span.
     182                   // We choose the higher value because future alias resolutions will be faster
     183                   // since the alias chain goes from lower ids to higher. This is about 4 times
     184                   // faster for complex footprints.
     185                   if (resolved_current <= idp[j + 1]) {
     186                       idc[j] = id = idp[j + 1];
     187                       id_last_connection = 0;
     188                   } else {
     189                       idc[j] = id = resolved_current;
     190                       id_last_connection = idp[j + 1];
     191                   }
    164192               }
    165193           }
Note: See TracChangeset for help on using the changeset viewer.