[Insight-users] ConnectedComponentImageFilter

Kiên Kiêu kien.kieu at jouy.inra.fr
Fri Jun 15 12:49:52 EDT 2012


Dear Miriam,

I am using ITK through python (WrapITK). Here is a piece of python code

import itk
reader = itk.ImageFileReader.IUC2.New(FileName="my_image.tif")
lmf = itk.BinaryImageToShapeLabelMapFilter.IUC2LM2.New()
lmf.SetInput(reader)
lmf.SetInputForegroundValue(200)
lmf.UpdateLargestPossibleRegion()
lm = lmf.GetOutput()
for l in lm.GetLabels():
     print lm.GetLabelObject(l).GetNumberOfPixels()

I hope you can easily translate it into C++ if you are using C++.

Le 15 juin 12 à 14:08, Miriam Pini a écrit :

> That's perfect, thank you: my region are given all the same label.  
> Sorry, one more question: once I have created the different label  
> objects, how can I choose each single region to get the dimension  
> only of one particular region?
>
> Thank you so much again,
>
> Miriam
>
> From: kien.kieu at jouy.inra.fr
> To: insight-users at itk.org
> Date: Fri, 15 Jun 2012 13:57:47 +0200
> Subject: Re: [Insight-users] ConnectedComponentImageFilter
>
> Yes. Note that BinaryImageToShapeLabelMapFilter is convenient in the  
> case all regions are given the same label. In case separate regions  
> have different labels, use LabelImageToShapeLabelMapFilter.
>
> Le 15 juin 12 à 12:21, Miriam Pini a écrit :
>
> Hi Kien,
>
> thank you for your help! I'm trying to use tha class you suggested:  
> am I correct saying that the foreground value is the the colour that  
> can be chosen for the lable objects??
>
> Thank you very much,
>
> Miriam
>
> From: kien.kieu at jouy.inra.fr
> To: insight-users at itk.org
> Date: Fri, 15 Jun 2012 09:16:14 +0200
> Subject: Re: [Insight-users] ConnectedComponentImageFilter
>
> Hi,
>
> you may use BinaryImageToShapeLabelMapFilter. Eventually you will  
> have to adjust the ForegroundValue attribute. Then use either the  
> methods GetNumberOfPixels or GetPhysicalSize of ShapeLabelObject to  
> get the size you wish for each object (connected component).
>
> Le 14 juin 12 à 19:57, Miriam Pini a écrit :
>
> Hi guys,
>
> I have an image with separated regions of the same colour and I'd  
> like to get the dimension of each of them. Is the  
> ConnectedComponentImageFilter the best class to do that?
>
> Any suggestion is greatly appreciated,
>
> thank you all,
>
> Miriam
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
> ---
> Kiên Kiêu                    tel  : + 33 (0)1 34 65 28 16
> Unité MIA, INRA              fax  : + 33 (0)1 34 65 22 17
> Domaine de Vilvert           email: Kien.Kieu at jouy.inra.fr
> F-78350 Jouy-en-Josas        url  : http://www.inra.fr/miaj/
>
>
>
>
>
> _____________________________________ Powered by www.kitware.com  
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.htmlKitware 
>  offers ITK Training Courses, for more information visit: http://www.kitware.com/products/protraining.php 
>  Please keep messages on-topic and check the ITK FAQ at:http://www.itk.org/Wiki/ITK_FAQ 
>  Follow this link to subscribe/unsubscribe: http://www.itk.org/mailman/listinfo/insight-users
>
> ---
> Kiên Kiêu                    tel  : + 33 (0)1 34 65 28 16
> Unité MIA, INRA              fax  : + 33 (0)1 34 65 22 17
> Domaine de Vilvert           email: Kien.Kieu at jouy.inra.fr
> F-78350 Jouy-en-Josas        url  : http://www.inra.fr/miaj/
>
>
>
>
>
> _____________________________________ Powered by www.kitware.com  
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.htmlKitware 
>  offers ITK Training Courses, for more information visit: http://www.kitware.com/products/protraining.php 
>  Please keep messages on-topic and check the ITK FAQ at:http://www.itk.org/Wiki/ITK_FAQ 
>  Follow this link to subscribe/unsubscribe: http://www.itk.org/mailman/listinfo/insight-users

---
Kiên Kiêu                    tel  : + 33 (0)1 34 65 28 16
Unité MIA, INRA              fax  : + 33 (0)1 34 65 22 17
Domaine de Vilvert           email: Kien.Kieu at jouy.inra.fr
F-78350 Jouy-en-Josas        url  : http://www.inra.fr/miaj/




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120615/a74fd4a6/attachment.htm>


More information about the Insight-users mailing list