Class Mask

All Implemented Interfaces:
BoundingBox, BytesSupplier, ai.djl.util.JsonSerializable, Serializable

public class Mask extends Rectangle
A mask with a probability for each pixel within a bounding rectangle.

This class is usually used to record the results of an Image Segmentation task.

See Also:
  • Nested Class Summary

    Nested classes/interfaces inherited from interface ai.djl.util.JsonSerializable

    ai.djl.util.JsonSerializable.Serializer
  • Constructor Summary

    Constructors
    Constructor
    Description
    Mask(double x, double y, double width, double height, float[][] dist)
    Constructs a Mask with the given data.
    Mask(double x, double y, double width, double height, float[][] dist, boolean fullImageMask)
    Constructs a Mask with the given data.
  • Method Summary

    Modifier and Type
    Method
    Description
    float[][]
    Returns the probability for each pixel.
    boolean
    Returns if the mask is for full image.
    com.google.gson.JsonObject
    static float[][]
    toMask(NDArray array)
    Converts the mask tensor to a mask array.

    Methods inherited from class ai.djl.modality.cv.output.Rectangle

    getBounds, getCoordinates, getHeight, getIoU, getPath, getPoint, getWidth, getX, getY, nms, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface ai.djl.ndarray.BytesSupplier

    getAsBytes, getAsObject

    Methods inherited from interface ai.djl.util.JsonSerializable

    getAsString, toByteBuffer, toJson
  • Constructor Details

    • Mask

      public Mask(double x, double y, double width, double height, float[][] dist)
      Constructs a Mask with the given data.
      Parameters:
      x - the left coordinate of the bounding rectangle
      y - the top coordinate of the bounding rectangle
      width - the width of the bounding rectangle
      height - the height of the bounding rectangle
      dist - the probability distribution for each pixel in the rectangle
    • Mask

      public Mask(double x, double y, double width, double height, float[][] dist, boolean fullImageMask)
      Constructs a Mask with the given data.
      Parameters:
      x - the left coordinate of the bounding rectangle
      y - the top coordinate of the bounding rectangle
      width - the width of the bounding rectangle
      height - the height of the bounding rectangle
      dist - the probability distribution for each pixel in the rectangle
      fullImageMask - if the mask if for full image
  • Method Details

    • getProbDist

      public float[][] getProbDist()
      Returns the probability for each pixel.
      Returns:
      the probability for each pixel
    • isFullImageMask

      public boolean isFullImageMask()
      Returns if the mask is for full image.
      Returns:
      if the mask is for full image
    • serialize

      public com.google.gson.JsonObject serialize()
      Specified by:
      serialize in interface ai.djl.util.JsonSerializable
      Overrides:
      serialize in class Rectangle
    • toMask

      public static float[][] toMask(NDArray array)
      Converts the mask tensor to a mask array.
      Parameters:
      array - the mask NDArray
      Returns:
      the mask array