Class IJFilters

java.lang.Object
qupath.imagej.processing.IJFilters

public class IJFilters extends Object
Helper class for filtering ImageJ images.

Many of these methods call built-in ImageJ filters, but adding them as static methods in a single class here may make them easier to find and use... and there are some extras that aren't part of ImageJ.

Important notes:

  • In general, the input image is unchanged and a new output image is created.
  • These methods do not pay attention to any Roi that has been set on the image!
This lack of Roi-attention may result in images being cropped when duplicates are created internally. It is therefore strongly recommended to reset the Roi for any images provided as input.
Since:
v0.6.0
  • Constructor Details

    • IJFilters

      public IJFilters()
  • Method Details

    • mean

      public static ImageProcessor mean(ImageProcessor ip, double radius)
      Apply a mean (average) filter.
      Parameters:
      ip - the input image
      radius - the filter radius
      Returns:
      the filtered image
    • median

      public static ImageProcessor median(ImageProcessor ip, double radius)
      Apply a median filter.
      Parameters:
      ip - the input image
      radius - the filter radius
      Returns:
      the filtered image
    • maximum

      public static ImageProcessor maximum(ImageProcessor ip, double radius)
      Apply a maximum filter.
      Parameters:
      ip - the input image
      radius - the filter radius
      Returns:
      the filtered image
    • minimum

      public static ImageProcessor minimum(ImageProcessor ip, double radius)
      Apply a minimum filter.
      Parameters:
      ip - the input image
      radius - the filter radius
      Returns:
      the filtered image
    • dilate

      public static ImageProcessor dilate(ImageProcessor ip, double radius)
      Apply a dilation; this is equivalent to applying a maximum filter.
      Parameters:
      ip - the input image
      radius - the filter radius
      Returns:
      the filtered image
    • erode

      public static ImageProcessor erode(ImageProcessor ip, double radius)
      Apply an erosion; this is equivalent to applying a minimum filter.
      Parameters:
      ip - the input image
      radius - the filter radius
      Returns:
      the filtered image
    • open

      public static ImageProcessor open(ImageProcessor ip, double radius)
      Apply a morphological opening; this is equivalent to applying a minimum followed by a maximum filter.
      Parameters:
      ip - the input image
      radius - the filter radius
      Returns:
      the filtered image
    • close

      public static ImageProcessor close(ImageProcessor ip, double radius)
      Apply a morphological closing; this is equivalent to applying a maximum followed by a minimum filter.
      Parameters:
      ip - the input image
      radius - the filter radius
      Returns:
      the filtered image
    • blackTopHat

      public static ImageProcessor blackTopHat(ImageProcessor ip, double radius)
      Apply a black tophat filter; this is equivalent to subtracting an 'opened' image from the original.
      Parameters:
      ip - the input image
      radius - the filter radius
      Returns:
      the filtered image
      See Also:
    • whiteTopHat

      public static ImageProcessor whiteTopHat(ImageProcessor ip, double radius)
      Apply a white tophat filter; this is equivalent to subtracting the original image from the a 'closed' image.
      Parameters:
      ip - the input image
      radius - the filter radius
      Returns:
      the filtered image
      See Also:
    • openingByReconstruction

      public static ImageProcessor openingByReconstruction(ImageProcessor ip, double radius)
      Apply an opening by (morphological) reconstruction.
      Parameters:
      ip - the input image
      radius - the radius of the initial opening filter
      Returns:
      the filtered image
    • closingByReconstruction

      public static ImageProcessor closingByReconstruction(ImageProcessor ip, double radius)
      Apply a closing by (morphological) reconstruction.
      Parameters:
      ip - the input image
      radius - the radius of the initial closing filter
      Returns:
      the filtered image
    • regionalMaxima

      public static ByteProcessor regionalMaxima(ImageProcessor ip)
      Find regional maxima in an image.

      Note: Use with caution! This method is experimental and may change.

      Parameters:
      ip - the input image
      Returns:
      a binary image with 255 at the location of regional maxima and 0 elsewhere
    • regionalMinima

      public static ByteProcessor regionalMinima(ImageProcessor ip)
      Find regional minima in an image.

      Note: Use with caution! This method is experimental and may change.

      Parameters:
      ip - the input image
      Returns:
      a binary image with 255 at the location of regional minima and 0 elsewhere
    • hMaxima

      public static FloatProcessor hMaxima(ImageProcessor ip, double h)
      Suppress small local maxima in an image using a H-maxima transform.

      Note: Use with caution! This method is experimental and may change.

      Parameters:
      ip - the input image
      h - the height of maxima to suppress
      Returns:
      the input with maxima suppressed
    • hMinima

      public static FloatProcessor hMinima(ImageProcessor ip, double h)
      Suppress small local minima in an image using a H-minima transform.

      Note: Use with caution! This method is experimental and may change.

      Parameters:
      ip - the input image
      h - the height of minima to suppress
      Returns:
      the input with minima suppressed
    • extendedMaxima

      public static ByteProcessor extendedMaxima(ImageProcessor ip, double h)
      Find regional maxima in an image above a defined height.

      Note: Use with caution! This method is experimental and may change.

      Parameters:
      ip - the input image
      h - the height of the maxima
      Returns:
      a binary image with 255 at the location of regional maxima and 0 elsewhere
    • extendedMinima

      public static ByteProcessor extendedMinima(ImageProcessor ip, double h)
      Find regional minima in an image above a defined height.

      Note: Use with caution! This method is experimental and may change.

      Parameters:
      ip - the input image
      h - the height of the minima
      Returns:
      a binary image with 255 at the location of regional minima and 0 elsewhere
    • gaussian

      public static ImageProcessor gaussian(ImageProcessor ip, double sigma)
      Apply a Gaussian filter to an input image.
      Parameters:
      ip - the input image
      sigma - the sigma value of the Gaussian filter
      Returns:
      the filtered image
    • differenceOfGaussians

      public static FloatProcessor differenceOfGaussians(ImageProcessor ip, double sigma1, double sigma2)
      Apply a Difference of Gaussians filter to an input image.
      Parameters:
      ip - the input image
      sigma1 - the sigma value of the first Gaussian filter
      sigma2 - the sigma value of the second Gaussian filter (to be subtracted)
      Returns:
      the filtered image