[Insight-users] Sobel operator gives fat edges

Emma Ryan eryanvtk at yahoo.com
Tue Mar 13 21:59:59 EDT 2012



Hi ,

   I am using the sobelOperator provided in itk.  The following is my code snippet. I would like to understand

1.  the default setting of the sobel and 
2. how I can tune it. There dont seem to be too many member functions to manipulate the sobel.
3. If I need to use Erosion filter to thin the edges, how do I design a 'line' structuring element. My code ( also added below) does not seem to allow line (which I am guessing derives from Box, line = 1-D Box)

Any help/suggestions is truly appreciated.

Thank you,
Emma


typedef itk::ConstNeighborhoodIterator<ImageType> NeighborhoodIteratorType;
    typedef itk::ImageRegionIterator< ImageType>        IteratorType;

    itk::SobelOperator<PixelType, 2> sobel;
    sobel.SetDirection(1);  
    itk::Size<2> radius_s;
    radius_s.Fill(1);
    sobel.CreateToRadius(radius_s);

   
    NeighborhoodIteratorType::RadiusType radius = sobel.GetRadius();
    NeighborhoodIteratorType it( radius, my_image, my_image->GetRequestedRegion() );
    itk::NeighborhoodInnerProduct<ImageType> inner_product;

    ImageType::Pointer output = ImageType::New();
    output->SetRegions(my_image->GetRequestedRegion());
    output->Allocate();
  
    IteratorType out(output, my_image->GetRequestedRegion());
    
    for (it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out)
    {
     out.Set( inner_product( it, sobel ) );
    }

    output->Update();
    

//Erosion Structuring Element: The following fails to compile if I use '1' instead of '2'
typedef itk::FlatStructuringElement<2> StructuringElementType;
    StructuringElementType::RadiusType element_radius;
    element_radius.Fill(5);
 
    StructuringElementType strel = StructuringElementType::Box(element_radius);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120313/0328be50/attachment.htm>


More information about the Insight-users mailing list