Class Morphology

java.lang.Object
inra.ijpb.morphology.Morphology

public class Morphology
extends java.lang.Object

Collection of static methods for morphological filters, as well as an enumeration of available methods.

Example of use:


 ImageProcessor image = IJ.getImage().getProcessor();
 Strel se = SquareStrel.fromDiameter(5);
 ImageProcessor grad = Morphology.gradient(image, se);
 ImagePlus res = new ImagePlus("Gradient", grad);
 res.show(); 
 

Example of use with 3D image (stack):


 ImageStack image = IJ.getImage().getStack();
 Strel3D se = CubeStrel.fromDiameter(3);
 ImageStack grad = Morphology.gradient(image, se);
 ImagePlus res = new ImagePlus("Gradient3D", grad);
 res.show(); 
 

Or directly with an instance of ImagePlus:


 ImagePlus image = IJ.getImage();
 Strel se = SquareStrel.fromDiameter(5);
 ImagePlus res = Morphology.gradient(image, se);
 res.show(); 
 
Author:
David Legland
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  Morphology.Operation
    A pre-defined set of basis morphological operations, that can be easily used with a GenericDialog.
  • Method Summary

    Modifier and Type Method Description
    static ij.ImagePlus blackTopHat​(ij.ImagePlus imagePlus, Strel3D strel)
    Computes black top hat (or "bottom hat") of the original image.
    static ij.ImageStack blackTopHat​(ij.ImageStack image, Strel3D strel)
    Computes black top hat (or "bottom hat") of the original image.
    static ij.process.ImageProcessor blackTopHat​(ij.process.ImageProcessor image, Strel strel)
    Computes black top hat (or "bottom hat") of the original image.
    static ij.ImagePlus closing​(ij.ImagePlus imagePlus, Strel3D strel)
    Performs morphological closing on the input image.
    static ij.ImageStack closing​(ij.ImageStack image, Strel3D strel)
    Performs morphological closing on the input 3D image.
    static ij.process.ImageProcessor closing​(ij.process.ImageProcessor image, Strel strel)
    Performs closing on the input image.
    static ij.ImagePlus dilation​(ij.ImagePlus imagePlus, Strel3D strel)
    Performs morphological dilation on the input image.
    static ij.ImageStack dilation​(ij.ImageStack image, Strel3D strel)
    Performs morphological dilation on the input 3D image.
    static ij.process.ImageProcessor dilation​(ij.process.ImageProcessor image, Strel strel)
    Performs morphological dilation on the input image.
    static ij.ImagePlus erosion​(ij.ImagePlus imagePlus, Strel3D strel)
    Performs morphological erosion on the input image.
    static ij.ImageStack erosion​(ij.ImageStack image, Strel3D strel)
    Performs morphological erosion on the input 3D image.
    static ij.process.ImageProcessor erosion​(ij.process.ImageProcessor image, Strel strel)
    Performs morphological erosion on the input image.
    static ij.ImagePlus externalGradient​(ij.ImagePlus imagePlus, Strel3D strel)
    Computes the morphological external gradient of the input image.
    static ij.ImageStack externalGradient​(ij.ImageStack image, Strel3D strel)
    Computes the morphological external gradient of the input 3D image.
    static ij.process.ImageProcessor externalGradient​(ij.process.ImageProcessor image, Strel strel)
    Computes the morphological external gradient of the input image.
    static ij.ImagePlus gradient​(ij.ImagePlus imagePlus, Strel3D strel)
    Computes the morphological gradient of the input image.
    static ij.ImageStack gradient​(ij.ImageStack image, Strel3D strel)
    Computes the morphological gradient of the input 3D image.
    static ij.process.ImageProcessor gradient​(ij.process.ImageProcessor image, Strel strel)
    Computes the morphological gradient of the input image.
    static ij.ImagePlus internalGradient​(ij.ImagePlus imagePlus, Strel3D strel)
    Computes the morphological internal gradient of the input image.
    static ij.ImageStack internalGradient​(ij.ImageStack image, Strel3D strel)
    Computes the morphological internal gradient of the 3D input image.
    static ij.process.ImageProcessor internalGradient​(ij.process.ImageProcessor image, Strel strel)
    Computes the morphological internal gradient of the input image.
    static ij.ImagePlus laplacian​(ij.ImagePlus imagePlus, Strel3D strel)
    Computes the morphological Laplacian of the 3D input image.
    static ij.ImageStack laplacian​(ij.ImageStack image, Strel3D strel)
    Computes the morphological Laplacian of the 3D input image.
    static ij.process.ImageProcessor laplacian​(ij.process.ImageProcessor image, Strel strel)
    Computes the morphological Laplacian of the input image.
    static ij.ImagePlus opening​(ij.ImagePlus imagePlus, Strel3D strel)
    Performs morphological opening on the input image.
    static ij.ImageStack opening​(ij.ImageStack image, Strel3D strel)
    Performs morphological opening on the input 3D image.
    static ij.process.ImageProcessor opening​(ij.process.ImageProcessor image, Strel strel)
    Performs morphological opening on the input image.
    static ij.ImagePlus whiteTopHat​(ij.ImagePlus imagePlus, Strel3D strel)
    Computes white top hat of the original image.
    static ij.ImageStack whiteTopHat​(ij.ImageStack image, Strel3D strel)
    Computes 3D white top hat of the original image.
    static ij.process.ImageProcessor whiteTopHat​(ij.process.ImageProcessor image, Strel strel)
    Computes white top hat of the original image.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • dilation

      public static ij.ImagePlus dilation​(ij.ImagePlus imagePlus, Strel3D strel)
      Performs morphological dilation on the input image. Dilation is obtained by extracting the maximum value among pixels/voxels in the neighborhood given by the structuring element. This methods is called the equivalent static method for ImageProcessor or ImageStack, and creates a new ImagePlus instance with the result.
      Parameters:
      imagePlus - the input image to process
      strel - the structuring element used for dilation
      Returns:
      the result of the dilation
      See Also:
      dilation(ImageProcessor, Strel), dilation(ImageStack, Strel3D), erosion(ImagePlus, Strel3D)
    • dilation

      public static ij.process.ImageProcessor dilation​(ij.process.ImageProcessor image, Strel strel)
      Performs morphological dilation on the input image. Dilation is obtained by extracting the maximum value among pixels in the neighborhood given by the structuring element. This methods is mainly a wrapper to the dilation method of the strel object.
      Parameters:
      image - the input image to process (grayscale or RGB)
      strel - the structuring element used for dilation
      Returns:
      the result of the dilation
      See Also:
      erosion(ImageProcessor, Strel), Strel.dilation(ImageProcessor)
    • dilation

      public static ij.ImageStack dilation​(ij.ImageStack image, Strel3D strel)
      Performs morphological dilation on the input 3D image. Dilation is obtained by extracting the maximum value among voxels in the neighborhood given by the 3D structuring element.
      Parameters:
      image - the input 3D image to process (grayscale or RGB)
      strel - the structuring element used for dilation
      Returns:
      the result of the dilation
    • erosion

      public static ij.ImagePlus erosion​(ij.ImagePlus imagePlus, Strel3D strel)
      Performs morphological erosion on the input image. Erosion is obtained by extracting the minimum value among pixels/voxels in the neighborhood given by the structuring element. This methods is called the equivalent static method for ImageProcessor or ImageStack, and creates a new ImagePlus instance with the result.
      Parameters:
      imagePlus - the input image to process
      strel - the structuring element used for erosion
      Returns:
      the result of the erosion
      See Also:
      erosion(ImageProcessor, Strel), erosion(ImageStack, Strel3D), dilation(ImagePlus, Strel3D)
    • erosion

      public static ij.process.ImageProcessor erosion​(ij.process.ImageProcessor image, Strel strel)
      Performs morphological erosion on the input image. Erosion is obtained by extracting the minimum value among pixels in the neighborhood given by the structuring element. This methods is mainly a wrapper to the erosion method of the strel object.
      Parameters:
      image - the input image to process (grayscale or RGB)
      strel - the structuring element used for erosion
      Returns:
      the result of the erosion
      See Also:
      dilation(ImageProcessor, Strel), Strel.erosion(ImageProcessor)
    • erosion

      public static ij.ImageStack erosion​(ij.ImageStack image, Strel3D strel)
      Performs morphological erosion on the input 3D image. Erosion is obtained by extracting the minimum value among voxels in the neighborhood given by the 3D structuring element.
      Parameters:
      image - the input image to process (grayscale or RGB)
      strel - the structuring element used for erosion
      Returns:
      the result of the erosion
    • opening

      public static ij.ImagePlus opening​(ij.ImagePlus imagePlus, Strel3D strel)
      Performs morphological opening on the input image. The opening is obtained by performing an erosion followed by a dilation with the reversed structuring element. This methods is called the equivalent static method for ImageProcessor or ImageStack, and creates a new ImagePlus instance with the result.
      Parameters:
      imagePlus - the input image to process
      strel - the structuring element used for erosion
      Returns:
      the result of the erosion
      See Also:
      opening(ImageProcessor, Strel), opening(ImageStack, Strel3D), closing(ImagePlus, Strel3D)
    • opening

      public static ij.process.ImageProcessor opening​(ij.process.ImageProcessor image, Strel strel)
      Performs morphological opening on the input image. The opening is obtained by performing an erosion followed by a dilation with the reversed structuring element. This methods is mainly a wrapper to the opening method of the strel object.
      Parameters:
      image - the input image to process (grayscale or RGB)
      strel - the structuring element used for opening
      Returns:
      the result of the morphological opening
      See Also:
      closing(ImageProcessor, Strel), Strel.opening(ImageProcessor)
    • opening

      public static ij.ImageStack opening​(ij.ImageStack image, Strel3D strel)
      Performs morphological opening on the input 3D image. The 3D opening is obtained by performing a 3D erosion followed by a 3D dilation with the reversed structuring element.
      Parameters:
      image - the input 3D image to process
      strel - the structuring element used for opening
      Returns:
      the result of the 3D morphological opening
      See Also:
      closing(ImageStack, Strel3D), Strel3D.opening(ImageStack)
    • closing

      public static ij.ImagePlus closing​(ij.ImagePlus imagePlus, Strel3D strel)
      Performs morphological closing on the input image. The opening is obtained by performing a dilation followed by an erosion with the reversed structuring element. This methods is called the equivalent static method for ImageProcessor or ImageStack, and creates a new ImagePlus instance with the result.
      Parameters:
      imagePlus - the input image to process
      strel - the structuring element used for closing
      Returns:
      the result of the closing
      See Also:
      closing(ImageProcessor, Strel), closing(ImageStack, Strel3D), opening(ImagePlus, Strel3D)
    • closing

      public static ij.process.ImageProcessor closing​(ij.process.ImageProcessor image, Strel strel)
      Performs closing on the input image. The closing is obtained by performing a dilation followed by an erosion with the reversed structuring element. This methods is mainly a wrapper to the opening method of the strel object.
      Parameters:
      image - the input image to process (grayscale or RGB)
      strel - the structuring element used for closing
      Returns:
      the result of the morphological closing
      See Also:
      opening(ImageProcessor, Strel), Strel.closing(ImageProcessor)
    • closing

      public static ij.ImageStack closing​(ij.ImageStack image, Strel3D strel)
      Performs morphological closing on the input 3D image. The 3D closing is obtained by performing a 3D dilation followed by a 3D erosion with the reversed structuring element.
      Parameters:
      image - the input 3D image to process
      strel - the structuring element used for closing
      Returns:
      the result of the 3D morphological closing
      See Also:
      opening(ImageStack, Strel3D), Strel3D.opening(ImageStack)
    • whiteTopHat

      public static ij.ImagePlus whiteTopHat​(ij.ImagePlus imagePlus, Strel3D strel)
      Computes white top hat of the original image. The white top hat is obtained by subtracting the result of an opening from the original image. The white top hat enhances light structures smaller than the structuring element. This methods is called the equivalent static method for ImageProcessor or ImageStack, and creates a new ImagePlus instance with the result.
      Parameters:
      imagePlus - the input image to process
      strel - the structuring element used for closing
      Returns:
      the result of the closing
      See Also:
      whiteTopHat(ImageProcessor, Strel), whiteTopHat(ImageStack, Strel3D), blackTopHat(ImagePlus, Strel3D)
    • whiteTopHat

      public static ij.process.ImageProcessor whiteTopHat​(ij.process.ImageProcessor image, Strel strel)
      Computes white top hat of the original image. The white top hat is obtained by subtracting the result of an opening from the original image. The white top hat enhances light structures smaller than the structuring element.
      Parameters:
      image - the input image to process (grayscale or RGB)
      strel - the structuring element used for white top-hat
      Returns:
      the result of the white top-hat
      See Also:
      blackTopHat(ImageProcessor, Strel), opening(ImageProcessor, Strel)
    • whiteTopHat

      public static ij.ImageStack whiteTopHat​(ij.ImageStack image, Strel3D strel)
      Computes 3D white top hat of the original image. The white top hat is obtained by subtracting the result of an opening from the original image. The white top hat enhances light structures smaller than the structuring element.
      Parameters:
      image - the input 3D image to process
      strel - the structuring element used for white top-hat
      Returns:
      the result of the 3D white top-hat
      See Also:
      blackTopHat(ImageStack, Strel3D), opening(ImageStack, Strel3D)
    • blackTopHat

      public static ij.ImagePlus blackTopHat​(ij.ImagePlus imagePlus, Strel3D strel)
      Computes black top hat (or "bottom hat") of the original image. The black top hat is obtained by subtracting the original image from the result of a closing. The black top hat enhances dark structures smaller than the structuring element. This methods is called the equivalent static method for ImageProcessor or ImageStack, and creates a new ImagePlus instance with the result.
      Parameters:
      imagePlus - the input image to process
      strel - the structuring element used for closing
      Returns:
      the result of the closing
      See Also:
      blackTopHat(ImageProcessor, Strel), blackTopHat(ImageStack, Strel3D), whiteTopHat(ImagePlus, Strel3D)
    • blackTopHat

      public static ij.process.ImageProcessor blackTopHat​(ij.process.ImageProcessor image, Strel strel)
      Computes black top hat (or "bottom hat") of the original image. The black top hat is obtained by subtracting the original image from the result of a closing. The black top hat enhances dark structures smaller than the structuring element.
      Parameters:
      image - the input image to process (grayscale or RGB)
      strel - the structuring element used for black top-hat
      Returns:
      the result of the black top-hat
      See Also:
      whiteTopHat(ImageProcessor, Strel), closing(ImageProcessor, Strel)
    • blackTopHat

      public static ij.ImageStack blackTopHat​(ij.ImageStack image, Strel3D strel)
      Computes black top hat (or "bottom hat") of the original image. The black top hat is obtained by subtracting the original image from the result of a closing. The black top hat enhances dark structures smaller than the structuring element.
      Parameters:
      image - the input 3D image to process
      strel - the structuring element used for black top-hat
      Returns:
      the result of the 3D black top-hat
      See Also:
      whiteTopHat(ImageStack, Strel3D), closing(ImageStack, Strel3D)
    • gradient

      public static ij.ImagePlus gradient​(ij.ImagePlus imagePlus, Strel3D strel)
      Computes the morphological gradient of the input image. The morphological gradient is obtained by from the difference of image dilation and image erosion computed with the same structuring element. This methods is called the equivalent static method for ImageProcessor or ImageStack, and creates a new ImagePlus instance with the result.
      Parameters:
      imagePlus - the input image to process
      strel - the structuring element used for closing
      Returns:
      the result of the closing
      See Also:
      gradient(ImageProcessor, Strel), gradient(ImageStack, Strel3D), internalGradient(ImagePlus, Strel3D), externalGradient(ImagePlus, Strel3D)
    • gradient

      public static ij.process.ImageProcessor gradient​(ij.process.ImageProcessor image, Strel strel)
      Computes the morphological gradient of the input image. The morphological gradient is obtained by from the difference of image dilation and image erosion computed with the same structuring element.
      Parameters:
      image - the input image to process (grayscale or RGB)
      strel - the structuring element used for morphological gradient
      Returns:
      the result of the morphological gradient
      See Also:
      erosion(ImageProcessor, Strel), dilation(ImageProcessor, Strel)
    • gradient

      public static ij.ImageStack gradient​(ij.ImageStack image, Strel3D strel)
      Computes the morphological gradient of the input 3D image. The morphological gradient is obtained by from the difference of image dilation and image erosion computed with the same structuring element.
      Parameters:
      image - the input 3D image to process
      strel - the structuring element used for morphological gradient
      Returns:
      the result of the 3D morphological gradient
      See Also:
      erosion(ImageStack, Strel3D), dilation(ImageStack, Strel3D)
    • laplacian

      public static ij.ImagePlus laplacian​(ij.ImagePlus imagePlus, Strel3D strel)
      Computes the morphological Laplacian of the 3D input image. The morphological gradient is obtained from the difference of the external gradient with the internal gradient, both computed with the same structuring element. Homogeneous regions appear as gray. This methods is called the equivalent static method for ImageProcessor or ImageStack, and creates a new ImagePlus instance with the result.
      Parameters:
      imagePlus - the input image to process
      strel - the structuring element used for closing
      Returns:
      the result of the closing
      See Also:
      laplacian(ImageProcessor, Strel), laplacian(ImageStack, Strel3D), internalGradient(ImagePlus, Strel3D), externalGradient(ImagePlus, Strel3D)
    • laplacian

      public static ij.process.ImageProcessor laplacian​(ij.process.ImageProcessor image, Strel strel)
      Computes the morphological Laplacian of the input image. The morphological Laplacian is obtained from the difference of the external gradient with the internal gradient, both computed with the same structuring element. Homogeneous regions appear as gray.
      Parameters:
      image - the input image to process (grayscale or RGB)
      strel - the structuring element used for morphological laplacian
      Returns:
      the result of the morphological laplacian
      See Also:
      erosion(ImageProcessor, Strel), dilation(ImageProcessor, Strel)
    • laplacian

      public static ij.ImageStack laplacian​(ij.ImageStack image, Strel3D strel)
      Computes the morphological Laplacian of the 3D input image. The morphological gradient is obtained from the difference of the external gradient with the internal gradient, both computed with the same structuring element. Homogeneous regions appear as gray.
      Parameters:
      image - the input 3D image to process
      strel - the structuring element used for morphological laplacian
      Returns:
      the result of the 3D morphological laplacian
      See Also:
      externalGradient(ImageStack, Strel3D), internalGradient(ImageStack, Strel3D)
    • internalGradient

      public static ij.ImagePlus internalGradient​(ij.ImagePlus imagePlus, Strel3D strel)
      Computes the morphological internal gradient of the input image. The morphological internal gradient is obtained by from the difference of original image with the result of an erosion. This methods is called the equivalent static method for ImageProcessor or ImageStack, and creates a new ImagePlus instance with the result.
      Parameters:
      imagePlus - the input image to process
      strel - the structuring element used for closing
      Returns:
      the result of the closing
      See Also:
      internalGradient(ImageProcessor, Strel), internalGradient(ImageStack, Strel3D), gradient(ImagePlus, Strel3D), externalGradient(ImagePlus, Strel3D)
    • internalGradient

      public static ij.process.ImageProcessor internalGradient​(ij.process.ImageProcessor image, Strel strel)
      Computes the morphological internal gradient of the input image. The morphological internal gradient is obtained by from the difference of original image with the result of an erosion.
      Parameters:
      image - the input image to process (grayscale or RGB)
      strel - the structuring element used for morphological internal gradient
      Returns:
      the result of the morphological internal gradient
      See Also:
      erosion(ImageProcessor, Strel), gradient(ImageProcessor, Strel), externalGradient(ImageProcessor, Strel)
    • internalGradient

      public static ij.ImageStack internalGradient​(ij.ImageStack image, Strel3D strel)
      Computes the morphological internal gradient of the 3D input image. The morphological internal gradient is obtained by from the difference of original image with the result of an erosion.
      Parameters:
      image - the input image to process
      strel - the structuring element used for morphological internal gradient
      Returns:
      the result of the 3D morphological internal gradient
      See Also:
      erosion(ImageStack, Strel3D), gradient(ImageStack, Strel3D), externalGradient(ImageStack, Strel3D)
    • externalGradient

      public static ij.ImagePlus externalGradient​(ij.ImagePlus imagePlus, Strel3D strel)
      Computes the morphological external gradient of the input image. The morphological external gradient is obtained by from the difference of the result of a dilation and of the original image . This methods is called the equivalent static method for ImageProcessor or ImageStack, and creates a new ImagePlus instance with the result.
      Parameters:
      imagePlus - the input image to process
      strel - the structuring element used for closing
      Returns:
      the result of the closing
      See Also:
      externalGradient(ImageProcessor, Strel), externalGradient(ImageStack, Strel3D), gradient(ImagePlus, Strel3D), internalGradient(ImagePlus, Strel3D)
    • externalGradient

      public static ij.process.ImageProcessor externalGradient​(ij.process.ImageProcessor image, Strel strel)
      Computes the morphological external gradient of the input image. The morphological external gradient is obtained by from the difference of the result of a dilation and of the original image .
      Parameters:
      image - the input image to process (grayscale or RGB)
      strel - the structuring element used for morphological external gradient
      Returns:
      the result of the morphological external gradient
      See Also:
      dilation(ImageProcessor, Strel)
    • externalGradient

      public static ij.ImageStack externalGradient​(ij.ImageStack image, Strel3D strel)
      Computes the morphological external gradient of the input 3D image. The morphological external gradient is obtained by from the difference of the result of a dilation and of the original image .
      Parameters:
      image - the input image to process
      strel - the structuring element used for morphological external gradient
      Returns:
      the result of the 3D morphological external gradient
      See Also:
      dilation(ImageStack, Strel3D), internalGradient(ImageStack, Strel3D)