Class AbstractStrel

java.lang.Object
All Implemented Interfaces:
Algo, Strel, Strel3D
Direct Known Subclasses:
AbstractInPlaceStrel, AbstractSeparableStrel, ChamferStrel, OrientedLineStrel

public abstract class AbstractStrel
extends AbstractStrel3D
implements Strel
Implementation basis for planar structuring elements. The aim of this class is mostly to allow the application of 2D structuring elements to 3D stacks, without having to write specific code in derived classes. Default implementations for 2D morphological operations are also provided. Morphological operations for stacks are implemented such that the planar strel is applied to each slice, and the result is added to the result stack.
Author:
David Legland
  • Nested Class Summary

    Nested classes/interfaces inherited from interface inra.ijpb.morphology.Strel

    Strel.Shape

    Nested classes/interfaces inherited from interface inra.ijpb.morphology.Strel3D

    Strel3D.Shape
  • Field Summary

    Fields inherited from interface inra.ijpb.morphology.Strel

    BACKGROUND, FOREGROUND

    Fields inherited from interface inra.ijpb.morphology.Strel3D

    BACKGROUND, FOREGROUND
  • Constructor Summary

    Constructors
    Constructor Description
    AbstractStrel()  
  • Method Summary

    Modifier and Type Method Description
    ij.process.ImageProcessor addBorder​(ij.process.ImageProcessor image)
    Adds a border around the image, to avoid edge effects when performing morphological closing or opening.
    ij.ImageStack closing​(ij.ImageStack stack)
    Performs a morphological closing on the input stack, by applying first a dilation, then an erosion with the reversed structuring element.
    ij.process.ImageProcessor closing​(ij.process.ImageProcessor image)
    Performs a morphological closing on the input image, by applying first a dilation, then an erosion with the reversed structuring element.
    ij.process.ImageProcessor cropBorder​(ij.process.ImageProcessor image)
    Retrieve the portion of image that corresponds to the original image before adding border.
    ij.ImageStack dilation​(ij.ImageStack stack)
    Implements a default algorithm for dilation, that consists in iterating over the neighbors of each pixel to compute the maximum value.
    ij.process.ImageProcessor dilation​(ij.process.ImageProcessor image)
    Implements a default algorithm for dilation, that consists in iterating over the neighbors of each pixel to compute the maximum value.
    ij.ImageStack erosion​(ij.ImageStack stack)
    Implements a default algorithm for erosion, that consists in iterating over the neighbors of each pixel to compute the minimum value.
    ij.process.ImageProcessor erosion​(ij.process.ImageProcessor image)
    Implements a default algorithm for erosion, that consists in iterating over the neighbors of each pixel to compute the minimum value.
    java.lang.String getChannelName()
    Returns the name of the channel currently processed, or null by default.
    int[][][] getMask3D()
    Returns the structuring element as a mask.
    int[][] getShifts3D()
    Returns the structuring element as a set of shifts.
    ij.ImageStack opening​(ij.ImageStack stack)
    Performs a morphological opening on the input stack, by applying first an erosion, then a dilation with the reversed structuring element.
    ij.process.ImageProcessor opening​(ij.process.ImageProcessor image)
    Performs a morphological opening on the input image, by applying first an erosion, then a dilation with the reversed structuring element.
    void setChannelName​(java.lang.String channelName)
    Sets the name of the currently processed channel.

    Methods inherited from class inra.ijpb.morphology.strel.AbstractStrel3D

    addBorder, cropBorder, showProgress, showProgress

    Methods inherited from class inra.ijpb.algo.AlgoStub

    addAlgoListener, removeAlgoListener

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface inra.ijpb.algo.Algo

    addAlgoListener, removeAlgoListener

    Methods inherited from interface inra.ijpb.morphology.Strel

    getMask, getOffset, getShifts, getSize, reverse

    Methods inherited from interface inra.ijpb.morphology.Strel3D

    showProgress, showProgress
  • Constructor Details

    • AbstractStrel

      public AbstractStrel()
  • Method Details

    • addBorder

      public ij.process.ImageProcessor addBorder​(ij.process.ImageProcessor image)
      Adds a border around the image, to avoid edge effects when performing morphological closing or opening. The size of the border is determined by Strel size and offset. Replicated border strategy is used to expand image.
      Parameters:
      image - the image to pad
      Returns:
      the image with border extended.
      See Also:
      cropBorder(ImageProcessor)
    • cropBorder

      public ij.process.ImageProcessor cropBorder​(ij.process.ImageProcessor image)
      Retrieve the portion of image that corresponds to the original image before adding border. The crop parameters are retrieved from strel size and offset. This method works together with the addBorder method. In practice, we retrieve the input image if we perform the following:
      
       ImageProcessor result = strel.cropBorder(strel.addBorder(inputImage));
       
      Parameters:
      image - the image to crop
      Returns:
      the image with strel padding removed.
      See Also:
      addBorder(ImageProcessor)
    • dilation

      public ij.process.ImageProcessor dilation​(ij.process.ImageProcessor image)
      Implements a default algorithm for dilation, that consists in iterating over the neighbors of each pixel to compute the maximum value. The neighbors are obtained via the getShifts() method.
      Specified by:
      dilation in interface Strel
      Parameters:
      image - the input image
      Returns:
      the result of dilation with this structuring element
      See Also:
      Strel.getShifts(), erosion(ImageProcessor)
    • erosion

      public ij.process.ImageProcessor erosion​(ij.process.ImageProcessor image)
      Implements a default algorithm for erosion, that consists in iterating over the neighbors of each pixel to compute the minimum value. The neighbors are obtained via the getShifts() method.
      Specified by:
      erosion in interface Strel
      Parameters:
      image - the input image
      Returns:
      the result of erosion with this structuring element
      See Also:
      Strel.getShifts(), dilation(ImageProcessor)
    • closing

      public ij.process.ImageProcessor closing​(ij.process.ImageProcessor image)
      Performs a morphological closing on the input image, by applying first a dilation, then an erosion with the reversed structuring element.
      Specified by:
      closing in interface Strel
      Parameters:
      image - the input image
      Returns:
      the result of closing with this structuring element
      See Also:
      dilation(ij.process.ImageProcessor), erosion(ij.process.ImageProcessor), opening(ij.process.ImageProcessor), Strel3D.reverse()
    • opening

      public ij.process.ImageProcessor opening​(ij.process.ImageProcessor image)
      Performs a morphological opening on the input image, by applying first an erosion, then a dilation with the reversed structuring element.
      Specified by:
      opening in interface Strel
      Parameters:
      image - the input image
      Returns:
      the result of opening with this structuring element
      See Also:
      dilation(ij.process.ImageProcessor), erosion(ij.process.ImageProcessor), closing(ij.process.ImageProcessor), Strel3D.reverse()
    • getMask3D

      public int[][][] getMask3D()
      Description copied from interface: Strel3D
      Returns the structuring element as a mask. Each value is either 0 or 255. The first index corresponds to the z position, the second index to the y direction, and the third one to the x position.
      Specified by:
      getMask3D in interface Strel3D
      Returns:
      the mask of the structuring element
    • getShifts3D

      public int[][] getShifts3D()
      Description copied from interface: Strel3D
      Returns the structuring element as a set of shifts. The size of the result is N-by-3, where N is the number of elements of the structuring element. The first value corresponds to the shift in the x direction.
      Specified by:
      getShifts3D in interface Strel3D
      Returns:
      a set of shifts
    • setChannelName

      public void setChannelName​(java.lang.String channelName)
      Sets the name of the currently processed channel.
      Specified by:
      setChannelName in interface Strel
      Parameters:
      channelName - the name of the currently processed channel
    • getChannelName

      public java.lang.String getChannelName()
      Returns the name of the channel currently processed, or null by default.
      Specified by:
      getChannelName in interface Strel
      Returns:
      the name of the currently processed channel
    • dilation

      public ij.ImageStack dilation​(ij.ImageStack stack)
      Description copied from class: AbstractStrel3D
      Implements a default algorithm for dilation, that consists in iterating over the neighbors of each pixel to compute the maximum value. The neighbors are obtained via the getShifts() method.
      Specified by:
      dilation in interface Strel3D
      Overrides:
      dilation in class AbstractStrel3D
      Parameters:
      stack - the input image
      Returns:
      the result of dilation with this structuring element
      See Also:
      Strel3D.getShifts3D(), AbstractStrel3D.erosion(ImageStack)
    • erosion

      public ij.ImageStack erosion​(ij.ImageStack stack)
      Description copied from class: AbstractStrel3D
      Implements a default algorithm for erosion, that consists in iterating over the neighbors of each pixel to compute the minimum value. The neighbors are obtained via the getShifts() method.
      Specified by:
      erosion in interface Strel3D
      Overrides:
      erosion in class AbstractStrel3D
      Parameters:
      stack - the input image
      Returns:
      the result of erosion with this structuring element
      See Also:
      Strel3D.getShifts3D(), AbstractStrel3D.dilation(ImageStack)
    • closing

      public ij.ImageStack closing​(ij.ImageStack stack)
      Description copied from class: AbstractStrel3D
      Performs a morphological closing on the input stack, by applying first a dilation, then an erosion with the reversed structuring element.
      Specified by:
      closing in interface Strel3D
      Overrides:
      closing in class AbstractStrel3D
      Parameters:
      stack - the input image
      Returns:
      the result of closing with this structuring element
      See Also:
      AbstractStrel3D.dilation(ImageStack), AbstractStrel3D.erosion(ImageStack), AbstractStrel3D.opening(ImageStack), Strel3D.reverse()
    • opening

      public ij.ImageStack opening​(ij.ImageStack stack)
      Description copied from class: AbstractStrel3D
      Performs a morphological opening on the input stack, by applying first an erosion, then a dilation with the reversed structuring element.
      Specified by:
      opening in interface Strel3D
      Overrides:
      opening in class AbstractStrel3D
      Parameters:
      stack - the input image
      Returns:
      the result of closing with this structuring element
      See Also:
      AbstractStrel3D.dilation(ImageStack), AbstractStrel3D.erosion(ImageStack), AbstractStrel3D.closing(ImageStack), Strel3D.reverse()