[ITK-users] Binary Erosion failed

Emma Ryan eryanvtk at yahoo.com
Fri Aug 14 01:15:14 EDT 2015


Hi Brad,
Thanks for your reply.  Unfortunately, this does not seem to be the case.  I think by default, the foreground is considered to be the highest value in the input image. Nonetheless, I did try to set both the values, but the filter still fails to erode the image.
thanks,Emma

 


     On Thursday, August 13, 2015 5:18 PM, Bradley Lowekamp <blowekamp at mail.nih.gov> wrote:
   

 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/insight-users/attachments/20150814/b4cdb0d3/attachment.html>


More information about the Insight-users mailing list