[Insight-users] Dilate or erode in 2D on 3D image

Luis Ibanez luis . ibanez at kitware . com
Fri, 19 Dec 2003 19:59:43 -0500


Hi Radhika,

There is a better way,

In ITK you can define structuring elements with arbitrary shape.

In your case, you simply need to enable the pixels of the
structuring element along the 2D plane in which you want to
perform the morphological operation.

The structuring element is in general an  itk::Neighborhood<>.
http://www . itk . org/Insight/Doxygen/html/classitk_1_1Neighborhood . html

You may want to look at the files

    itkBinaryBallStructuringElement.h
    itkBinaryBallStructuringElement.txx

and

    itkBinaryCrossStructuringElement.h
    itkBinaryCrosstructuringElement.txx


in Insight/Code/Common

You could follow their example in order to create
a new class:

    itkBinary2DBallStructuringElement


The fundamental change is that you can remove the
Dimension as a template parameter since this will be
a class specific for 3D images. Then in the method

     CreateStructuringElement();

you select the pixels of the neighbor that will
make part of the Structuring element.

You will find details on the use of neighborhood
in the SoftwareGuide

     http://www . itk . org/ItkSoftwareGuide . pdf

Look at the nice chapter on iterators contributed
by Josh Cates. This is Chapter 11. pdf-page 481.

Neighborhood iterators are discussed in section 11.4
on pdf-page 498.



Regards,


    Luis


--------------------------------
Radhika Sivaramakrishna wrote:

> Hi Luis,
>  
> If I want to run a 2D dilate operation on each slice of a 3D image, is there
> a simple way to do this? The only way I can think of is extracting each 
> slice, running
> a 2D dilate operation on it, and putting it back. Is there some better 
> way of doing this?
> Thanks
> Radhika