de.unihalle.informatik.MiToBo.morphology
Class ImgErode

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDOperator
      extended by de.unihalle.informatik.MiToBo.core.operator.MTBOperator
          extended by de.unihalle.informatik.MiToBo.morphology.ImgErode
All Implemented Interfaces:
de.unihalle.informatik.Alida.datatypes.ALDConfigurationValidator

@ALDAOperator(genericExecutionMode=ALL,
              level=APPLICATION)
public class ImgErode
extends MTBOperator

This class implements morphological erosion on 2D binary/grayscale images.

If the given image only contains two pixel values it is interpreted as binary image. In the resulting image the background pixels will be set to the smaller value, while the foreground pixels will be set to the larger ones.

The structuring element is a square matrix of size 'masksize' x 'masksize', with reference pixel in the center of the matrix. Attention: if masksize is even, errors result due to non-given symmetry

Author:
moeller

Nested Class Summary
 
Nested classes/interfaces inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
de.unihalle.informatik.Alida.operator.ALDOperator.HidingMode
 
Field Summary
private  MTBImage inImg
           
private  int masksize
           
private  MTBImage resultImg
           
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
completeDAG, name, portHashAccess, verbose, versionProvider
 
Constructor Summary
ImgErode()
          Default constructor.
ImgErode(MTBImage inimg, int ms)
          Constructor.
 
Method Summary
private  MTBImage applyMask(MTBImage mImg, int msize)
          Invokes erosion.
private  MTBImage applyMaskBinary(MTBImage mImg, int msize, int minVal, int maxVal)
          Applies an erosion mask to the given binary image.
private  MTBImage applyMaskGray(MTBImage mImg, int msize)
          Applies an erosion mask to the given intensity image.
 MTBImage getInputImage()
          Returns the input image, null if not set.
 int getMasksize()
          Returns the given mask size, 0 if not set.
 MTBImage getResultImage()
          Returns the eroded image, null if not available.
protected  void operate()
          This method does the actual work.
private  void setResultImage(MTBImage result)
          Set result image.
 
Methods inherited from class de.unihalle.informatik.MiToBo.core.operator.MTBOperator
readResolve
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDOperator
deserializeFromXmlFile, fieldContained, getALDPortHashAccessKey, getConstructionMode, getInInoutNames, getInInoutNames, getInNames, getInOutNames, getMissingRequiredInputs, getName, getNumParameters, getOutInoutNames, getOutNames, getParameter, getParameterDescriptor, getParameterNames, getSupplementalNames, getVerbose, getVersion, isConfigured, parametersToXmlObject, print, print, print, printInterface, printInterface, readHistory, reinitializeParameterDescriptors, runOp, runOp, runOp, serializeToXmlFile, setConstructionMode, setName, setParameter, setParametersFromXml, setParametersFromXml, setVerbose, toStringVerbose, unconfiguredItems, validate, validateCustom, validateGeneric, writeHistory, writeHistory, writeHistory, writeParametersToXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inImg

@Parameter(label="Input Image",
           required=true,
           dataIOOrder=0,
           direction=IN,
           description="Input image")
private transient MTBImage inImg

masksize

@Parameter(label="Masksize",
           required=true,
           dataIOOrder=1,
           direction=IN,
           description="Masksize")
private int masksize

resultImg

@Parameter(label="Result Image",
           required=true,
           direction=OUT,
           description="Result image")
private transient MTBImage resultImg
Constructor Detail

ImgErode

public ImgErode()
         throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Default constructor.

Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException

ImgErode

public ImgErode(MTBImage inimg,
                int ms)
         throws de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Constructor.

Parameters:
inimg - Input image.
masksize - Size of square mask.
Throws:
de.unihalle.informatik.Alida.exceptions.ALDOperatorException
Method Detail

applyMask

private MTBImage applyMask(MTBImage mImg,
                           int msize)
Invokes erosion.

The method first checks if image is binary or not. Subsequently the corresponding erosion function is called.

Parameters:
mImg - Input image.
msize - Size of square mask.
Returns:
Eroded image.

applyMaskBinary

private MTBImage applyMaskBinary(MTBImage mImg,
                                 int msize,
                                 int minVal,
                                 int maxVal)
Applies an erosion mask to the given binary image. Pixels with larger gray value are assumed to belong to the foreground while pixels with smaller intensities are handled as background pixels.

Parameters:
ip - Input image for erosion.
msize - Size of squared erosion mask.
minVal - Minimal intensity in image.
maxVal - Maximal intensity in image.
Returns:
Eroded result image.

applyMaskGray

private MTBImage applyMaskGray(MTBImage mImg,
                               int msize)
Applies an erosion mask to the given intensity image.

Parameters:
ip - Input image for erosion.
msize - Size of squared erosion mask.
Returns:
Eroded result image.

getInputImage

public MTBImage getInputImage()
Returns the input image, null if not set.


getMasksize

public int getMasksize()
Returns the given mask size, 0 if not set.


getResultImage

public MTBImage getResultImage()
Returns the eroded image, null if not available.


operate

protected void operate()
This method does the actual work.

Specified by:
operate in class de.unihalle.informatik.Alida.operator.ALDOperator

setResultImage

private void setResultImage(MTBImage result)
Set result image.