Class ImageOps

java.lang.Object
qupath.opencv.ops.ImageOps

public class ImageOps extends Object
Create and use ImageOp and ImageDataOp objects.

The Gson types in v0.2.0 are subject to change in later version. Specifically, each category will likely have an additional part to the subtype. This is currently the case with "core", but not other subtypes.

Author:
Pete Bankhead
  • Constructor Details

    • ImageOps

      public ImageOps()
  • Method Details

    • registerOp

      public static void registerOp(Class<? extends ImageOp> cls, String label)
      Register an ImageOp class for JSON serialization/deserialization.

      Labels should typically be all lowercase and begin with "op." and include "ext" if the op is added via an extension.

      For example, an "op.threshold.ext.triangle" would be a suitable label for an op added via an extension to apply a threshold using the triangle method.

      Parameters:
      cls - the op to register; this must be compatible with JSON serialization.
      label - an identifying label; that this must be unique. If it does not start with "op." a warning will be logged.
    • registerDataOp

      public static void registerDataOp(Class<? extends ImageDataOp> cls, String label)
      Register an ImageDataOp class for JSON serialization/deserialization.

      Labels should typically be all lowercase and begin with "data.op." and include "ext" if the op is added via an extension.

      Parameters:
      cls - the op to register; this must be compatible with JSON serialization.
      label - an identifying label; that this must be unique. If it does not start with "data.op." a warning will be logged.
    • buildServer

      public static ImageDataServer<BufferedImage> buildServer(ImageData<BufferedImage> imageData, ImageDataOp dataOp, PixelCalibration resolution)
      Build an ImageServer that generates pixels on demand from an ImageData by applying an ImageDataOp.

      Warning! Because ImageData are mutable, this can potentially result in inconsistencies if a change is made that impacts the behavior of the op while tiles are still being requested.

      Parameters:
      imageData - the ImageData to wrap
      dataOp - the op performing pixel transformations
      resolution - the resolution at which the op should be applied
      Returns:
      the ImageDataServer
    • buildServer

      public static ImageDataServer<BufferedImage> buildServer(ImageData<BufferedImage> imageData, ImageDataOp dataOp, PixelCalibration resolution, int tileWidth, int tileHeight)
      Build an ImageServer that generates pixels on demand from an ImageData by applying an ImageDataOp.

      Warning! Because ImageData are mutable, this can potentially result in inconsistencies if a change is made that impacts the behavior of the op while tiles are still being requested.

      Parameters:
      imageData - the ImageData to wrap
      dataOp - the op performing pixel transformations
      resolution - the resolution at which the op should be applied
      tileWidth - the tile width for the server
      tileHeight - the tile height of the server
      Returns:
      the ImageDataServer
    • buildImageDataOp

      public static ImageDataOp buildImageDataOp(ColorTransforms.ColorTransform... inputChannels)
      Create an ImageDataOp, optionally using a specified array of input channels.
      Parameters:
      inputChannels - array of ColorTransforms.ColorTransform objects used to extract the pixels that will form the channels of the output Mat. If empty, the original image channels will be used.
      Returns:
      the ImageDataOp
    • buildImageDataOp

      public static ImageDataOp buildImageDataOp(Collection<? extends ColorTransforms.ColorTransform> inputChannels)
      Create an ImageDataOp, optionally using a specified collection of input channels.
      Parameters:
      inputChannels - array of ColorTransforms.ColorTransform objects used to extract the pixels that will form the channels of the output Mat. If empty, the original image channels will be used.
      Returns:
      the ImageDataOp
    • padAndApply

      public static Mat padAndApply(ImageOp op, Mat mat, int padType)
      Apply an op after adding specified padding.

      This is useful when applying padded ops to Mats directly, rather than via an ImageDataOp. Because the op will strip off any padding, calling op.apply(mat) directly often results in a smaller output than the input image. Using this method instead gives an output image that is the same size as the input.

      Parameters:
      op - the op to apply
      mat - the image to process
      padType - the OpenCV boundary padding type
      Returns:
      the result of applying the op to the input image; note that this is often a modified version of the input image itself, since many ops work in-place.
      See Also:
    • padAndApply

      public static Mat padAndApply(ImageOp op, Mat mat)
      Apply an op after adding symmetric (reflection) padding.

      This is useful when applying padded ops to Mats directly, rather than via an ImageDataOp. Because the op will strip off any padding, calling op.apply(mat) directly often results in a smaller output than the input image. Using this method instead gives an output image that is the same size as the input.

      Parameters:
      op - the op to apply
      mat - the image to process
      Returns:
      the result of applying the op to the input image; note that this is often a modified version of the input image itself, since many ops work in-place.