Changeset 34199 for trunk/psModules/src/objects/pmFootprintFind.c
- Timestamp:
- Jul 24, 2012, 3:35:32 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/objects/pmFootprintFind.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/objects/pmFootprintFind.c
r29004 r34199 24 24 25 25 // XXX EAM : why use WSPAN in here rather than pmSpan? 26 // XXX WES : can't use pmSpan because does not have an id 26 27 typedef struct { /* run-length code for part of object*/ 27 28 int id; /* ID for object */ … … 114 115 115 116 in_span = 0; /* not in a span */ 117 int id_last_connection = 0; 116 118 for (j = 0; j < numCols; j++) { 117 119 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. 118 121 if (pixVal < threshold) { 122 // below threshold. If in a span close it out 119 123 if (in_span) { 120 124 if(nspan >= size_spans) { … … 130 134 131 135 in_span = 0; 136 id_last_connection = 0; 132 137 } 133 138 } 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) 134 151 if(idc[j - 1] != 0) { 135 152 id = idc[j - 1]; … … 157 174 * Do we need to merge ID numbers? If so, make suitable entries in aliases[] 158 175 */ 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 } 164 192 } 165 193 }
Note:
See TracChangeset
for help on using the changeset viewer.
