[Insight-users] count segments in binary image

Gaëtan Lehmann gaetan.lehmann at jouy.inra.fr
Sat Dec 4 02:20:50 EST 2010


Le 3 déc. 10 à 23:32, igor schneider a écrit :

> Hi,
>
> i want to count the number of segments in a binary image, and detect  
> their bounding boxes.
> Does Itk have something to accomplish this, or do i have to use  
> something handcrafted for this?
>

Hi,

You can do both with the classes in this contribution, which are now  
in ITK:

   http://hdl.handle.net/1926/584

Here is an example (in python):

   import itk
   reader = itk.ImageFileReader.IUC3.New(FileName="foo.nrrd")
   bi2lm = itk.BinaryImageToShapeLabelMapFilter.IUC3LM3.New(reader)
   print bi2lm()[0].GetNumberOfLabelObjects()
   for lo in bi2lm[0]:
     print lo.GetBoundingBox()

You'll find several C++ examples in the link above.

Regards,

Gaëtan


-- 
Gaëtan Lehmann
Biologie du Développement et de la Reproduction
INRA de Jouy-en-Josas (France)
tel: +33 1 34 65 29 66    fax: 01 34 65 29 09
http://voxel.jouy.inra.fr  http://www.itk.org
http://www.mandriva.org  http://www.bepo.fr



More information about the Insight-users mailing list