Gray scale images can be processed as binary images by selecting a "ForegroundValued" (which subclasses may alias as "DilateValue" or "ErodeValue"). Pixel not matching the foreground value are considered "background". This is useful in processing segmented images where all pixels in segment #1 have value 1 and pixels in segment #2 have value 2, etc. A particular "segment number" can be processed. ForegroundValue defaults to the maximum possible value of the PixelType.

The structuring element is assumed to be composed of binary values (zero or one). Only elements of the structuring element having values > 0 are candidates for affecting the center pixel. A reasonable choice of structuring element is itk::BinaryBallStructuringElement.

We use hence the next property in order to compute minkoswki addition ( which will be written (+) ):

X (+) B = ( Xb0 UNION Xb1 UNION ... Xbn ) UNION ( BORDER(X) (+) B ),

where Xbi is the set X translated with respect to vector bi :

Xbi ={ x + bi, x belongs to X }

where BORDER(X) is the extracted border of X ( 8 connectivity in 2D, 26 in 3D )

Our implementation for dilation is defined as:

X (+) SYM(B) = DILATION(X)_B

Where DILATION(X)_B is the dilation of set with structuring element B. Where SYM(B) is the symmetric of the structuring element relatively to its center.

This code was contributed by Jerome Schmid from the University of Strasbourg who provided a fast dilation implementation. Gaetan Lehmann from INRA de Jouy-en-Josas then provided a fast erosion implementation based on Jerome's implementation. The common portions of these two implementations were then placed in this superclass.

Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.

Input and output images must be the same dimension. Set the value in the image to consider as "foreground". Defaults to maximum value of PixelType. Subclasses may alias this to DilateValue or ErodeValue.