Interface Image


public interface Image
Image is a container of an image in DJL. The storage type of the image depends on the platform you are running on.
  • Method Details

    • getWidth

      int getWidth()
      Gets the width of the image.
      Returns:
      pixels representing width
    • getHeight

      int getHeight()
      Gets the height of the image.
      Returns:
      pixels representing height
    • getWrappedImage

      Object getWrappedImage()
      Gets the wrapped image.
      Returns:
      the wrapped image object
    • resize

      Image resize(int width, int height, boolean copy)
      Creates a new resized image.
      Parameters:
      width - the new image's desired width
      height - the new image's desired height
      copy - false to return original image if size is the same
      Returns:
      the new resized image.
    • getMask

      Image getMask(int[][] mask)
      Returns a new Image of masked area.
      Parameters:
      mask - the mask for each pixel in the image
      Returns:
      the mask image.
    • getSubImage

      Image getSubImage(int x, int y, int w, int h)
      Gets the subimage defined by a specified rectangular region.
      Parameters:
      x - the X coordinate of the upper-left corner of the specified rectangular region
      y - the Y coordinate of the upper-left corner of the specified rectangular region
      w - the width of the specified rectangular region
      h - the height of the specified rectangular region
      Returns:
      subimage of this image
    • duplicate

      Image duplicate()
      Gets a deep copy of the original image.
      Returns:
      the copy of the original image.
    • toNDArray

      default NDArray toNDArray(NDManager manager)
      Converts image to a RGB NDArray.
      Parameters:
      manager - a NDManager to create the new NDArray with
      Returns:
      NDArray
    • toNDArray

      NDArray toNDArray(NDManager manager, Image.Flag flag)
      Converts image to a NDArray.
      Parameters:
      manager - a NDManager to create the new NDArray with
      flag - the color mode
      Returns:
      NDArray
    • save

      void save(OutputStream os, String type) throws IOException
      Save the image to file.
      Parameters:
      os - OutputStream to save the image.
      type - type of the image, such as "png", "jpeg"
      Throws:
      IOException - image cannot be saved through output stream
    • findBoundingBoxes

      List<BoundingBox> findBoundingBoxes()
      Find bounding boxes from a masked image with 0/1 or 0/255.
      Returns:
      the List of bounding boxes of the images
    • drawBoundingBoxes

      void drawBoundingBoxes(DetectedObjects detections)
      Draws the bounding boxes on the image.
      Parameters:
      detections - the object detection results
    • drawJoints

      void drawJoints(Joints joints)
      Draws all joints of a body on an image.
      Parameters:
      joints - the joints of the body
    • drawImage

      void drawImage(Image overlay, boolean resize)
      Draws the overlay on the image.
      Parameters:
      overlay - the overlay image
      resize - true to resize the overlay image to match the image