[ITK] [ITK-users] Binary Erosion failed

Bradley Lowekamp blowekamp at mail.nih.gov
Thu Aug 13 20:18:04 EDT 2015


Hello,

The problem likely relates to defining the "white" box  on a "back" background in terms of a binary image.

You should set the "BackgroundValue"[1] and the "ForegroundValue"[2] in the filter to you "white" pixel intensity value, and "black" pixel intensity value. Those methods a little tricky to find since they are in the parent class. Be careful to note if there are pixels of other values in the image.

HTH,
Brad

[1] SetBackgroundValue
[2] SetForegroundValue


On Aug 13, 2015, at 8:00 PM, Emma Ryan via Insight-users <insight-users at itk.org> wrote:

> Hi,
> 
>  I am attempting a simple erosion on a binary input image which is pretty much a white box on a black background.
> 
>  The following is my code snippet. Not sure why it fails to erode the image. Am I missing something ? 
> 
> typedef itk::FlatStructuringElement<2 >    StructuralElementType;
> StructuralElementType::RadiusType radius;
> radius.Fill(7 );
> StructuralElementType structural_element =   StructuralElementType::Box( radius );
>     
> 
>     typedef itk::BinaryErodeImageFilter <UCharImageType, UCharImageType, StrelType>    BinaryErodeImageFilterType;
>     BinaryErodeImageFilterType::Pointer erodeFilter    = BinaryErodeImageFilterType::New();
>     erodeFilter->SetInput(my_binary_image);
>     erodeFilter->SetKernel(structural_element);
>     try
>     {
>         erodeFilter->Update();
>     }
> catch(...)
> {
>     cout<<"Failure";
> }
> 
> UCharImageType::Pointer new_image = erodeFilter->GetOutput();
> 
> thanks,
> Emma
> 
> 
> 
> _____________________________________
> 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://public.kitware.com/mailman/listinfo/insight-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20150813/6cb8d0c1/attachment.html>
-------------- next part --------------
_____________________________________
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://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list