[ITK Community] [Insight-developers] Detect holes in binary images

Bradley Lowekamp blowekamp at mail.nih.gov
Fri Feb 7 09:27:33 EST 2014


Seems to work for me. Here is a little ipython notebook I create to demonstate:
http://nbviewer.ipython.org/url/erie.nlm.nih.gov/~blowek1/Notebooks/Detect_Holes.ipynb?create=1

You can find more information about SimpleITK here:
http://www.itk.org/Wiki/SimpleITK

And more SimpleITK Notebooks here:
http://simpleitk.github.io/SimpleITK-Notebooks/

On Feb 7, 2014, at 8:38 AM, elhadj meljane <elhadj.meljane at gmail.com> wrote:

> Hi Brad,
> I tried with a toy image, I get labels for the shapes and labels for
> the holes inside these shapes. How to select the labels that
> correspond only to the holes? Also, taken the image or the invert of
> the image didn't change the output of the connected components? Here's
> one of the toy image that I used with the output of the connected
> components.
> 
> A =
> 00000000
> 00111100
> 00100100
> 00111100
> 00000000
> 
> output =
> 00000000
> 00111100
> 00122100
> 00111100
> 00000000
> 
> 
> Thank you.
> 
> Best,
> 
> 
> On Fri, Feb 7, 2014 at 8:00 AM, Bradley Lowekamp <blowekamp at mail.nih.gov> wrote:
>> Hello,
>> 
>> Hole come in a variety of shapes sized and definitions.  Depending on there exact morphological shape that you are interested in it may very how to detect them. ITK has a large number of morphological filter which can be used to.
>> 
>> At a basic level to get you started, I'd suggest inverting you binary image, with the NotImageFilter. Then running ConnectedComponentImageFilter, to give each isolated hole a unique label. Then the LabelStatisticsImageFilter to get basic size and shape information.
>> 
>> If additional morphological filtering is needed I'd recommend try out SimpleITK in Python, so that a large number of filters can be played with to get the desired filtered effect.
>> 
>> Hope that helps,
>> Brad
>> 
>> On Feb 7, 2014, at 7:32 AM, elhadj meljane <elhadj.meljane at gmail.com> wrote:
>> 
>>> Hi all,
>>> I would appreciate suggestions to detect holes in binary images. The
>>> holes are of different sizes (small medium).  I am not looking to fill
>>> these holes but just to detect their locations.
>>> 
>>> Thank you.
>>> 
>>> Best,
>>> Elhadj
>>> _______________________________________________
>>> 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://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-developers
>> 

_______________________________________________
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://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-developers



More information about the Community mailing list