Interface ImageOp

All Superinterfaces:
UriResource
All Known Implementing Classes:
ImageOps.PaddedOp

public interface ImageOp extends UriResource
An operation that may be applied to a Mat.

This is intended to apply simple transforms to an image (e.g. color transforms, channel extraction, filtering, normalization), which may impact the number and type of image channels - but not other aspects of the image, with the exception of removing any padding.

Operations may be chained

  • Method Details

    • apply

      Mat apply(Mat input)
      Apply operation to the image. The input may be modified (and the operation applied in-place), therefore should be duplicated if a copy is required to be kept.

      Note that any non-empty padding will be removed, potentially giving an output image smaller than the input. If this is not desirable use ImageOps.padAndApply(ImageOp, Mat).

      Parameters:
      input - input image
      Returns:
      output image, which may be the same as the input image
      See Also:
    • getPadding

      default Padding getPadding()
      Get the padding requested for this operation. The default is to return Padding.empty().

      Subclasses that perform neighborhood operations should override this. If the padding is non-empty, it will be removed when apply(Mat) is called - and so the Mat that is output will be smaller than the Mat that was input.

      Returns:
      the padding requested by this operation
    • getChannels

      default List<ImageChannel> getChannels(List<ImageChannel> channels)
      Get appropriate channels to reflect the output of this transform. The default is to return the input list unchanged.

      Classes that change the meaning or number of channels should override this. In particular, the number of channels in the output list should match the number of channels output by this transformer, given the input channels.

      Parameters:
      channels -
      Returns:
    • getOutputType

      default PixelType getOutputType(PixelType inputType)
      Get the output pixel type. The default is to return the pixel type unchanged.
      Parameters:
      inputType - the input pixel type
      Returns:
      the output pixel type
    • getURIs

      default Collection<URI> getURIs() throws IOException
      Default implementation returns an empty list; classes should override this if necessary.
      Specified by:
      getURIs in interface UriResource
      Returns:
      the required URIs
      Throws:
      IOException
    • updateURIs

      default boolean updateURIs(Map<URI,URI> replacements) throws IOException
      Default implementation makes no changes; classes should override this if necessary.
      Specified by:
      updateURIs in interface UriResource
      Parameters:
      replacements - replacement map, where the key gives the current URI and the value gives its replacement.
      Returns:
      true if URIs were changed, false otherwise
      Throws:
      IOException