[vtkusers] Identifying/Extracting the largest object (fwd)

Michael S. Vaz gte631d at mail.gatech.edu
Wed Jun 11 10:49:25 EDT 2003


I need to identify and extract the largest object from a binary 3D image
and can't seem to find a function in VTK to do this.  In MATLAB R13 this
is rather simple:

con_param = 26 % set connectivity parameter to the strictest setting

% T1 is the eroded binary 3D image (3D mtx)

[L,num_connected_objs] = bwlabeln(T1,con_param);

a = hist(L(:),[0:num_connected_objs]);

[v,ind] = max([a(2:end)]); %v = max (single value), "ind" is vect.

T2 = (L==ind); % T2 will set just the largest object to 1
	     % while everything else will be the background (=0)

As am unable to find an eqivalent function to bwlabeln in python or vtk.
I found a reference to some python code that will remove all the small
objects from a Google search of [+python +segment +"largest object"], but
unfortunately the source code no longer exists in the library the that
link points to.

If you know of some function code that will help me please let me know.
Also, if anyone has suggestions to make the solution elegant,
should the function need to be implemented, please let me know.  The
MATLAB algorithm is not exposed for bwlabeln().

Thanks,
Sarju

Michael S. Vaz
324607 Georgia Tech Station
Atlanta Georgia, 30332
Internet: gte631d at prism.gatech.edu





More information about the vtkusers mailing list