changeset 584:01e312295406

Remove zero padding from bwlabeln output
author jordigh
date Wed, 05 Sep 2012 20:02:40 +0000
parents 319cadd33084
children 67d43bf75000
files src/bwlabeln.cc src/union-find.h++
diffstat 2 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/bwlabeln.cc
+++ b/src/bwlabeln.cc
@@ -412,14 +412,17 @@
           ids_to_label[id] = label;
         }
       else
-        {
           label = try_label -> second;
-        }
 
       L_vec[*idx] = label;
     }
 
-  rval(0) = L;
+  // Remove the zero padding...
+  Array<idx_vector> inner_slice (dim_vector (size_vec.length (), 1));
+  for (octave_idx_type i = 0; i < padded_size.length (); i++)
+    inner_slice(i) = idx_vector (1, padded_size(i) - 1);
+
+  rval(0) = L.index (inner_slice);
   rval(1) = ids_to_label.size ();
   return rval;
 }
--- a/src/union-find.h++
+++ b/src/union-find.h++
@@ -71,8 +71,6 @@
     voxel *v1 = voxels[root1], *v2 = voxels[root2];
     if (root1 != root2)
       {
-
-
         if ( v1->rank > v2->rank)
           v1->parent = root2;
         else if (v1->rank < v2->rank)