Package ai.djl.modality.cv
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.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumFlag indicates the color channel options for images.static enumInterpolation indicates the Interpolation options for resizinig an image. -
Method Summary
Modifier and TypeMethodDescriptiondefault int[][]createStar(Point point, int radius) Creates a star shape.default voiddrawBoundingBoxes(DetectedObjects detections) Draws the bounding boxes on the image.voiddrawBoundingBoxes(DetectedObjects detections, float opacity) Draws the bounding boxes on the image.voidDraws the overlay on the image.voiddrawJoints(Joints joints) Draws all joints of a body on an image.default voidDraws a mark on the image.voidDraws a mark on the image.voiddrawRectangle(Rectangle rect, int rgb, int thickness) Draws a rectangle on the image.Gets a deep copy of the original image.Find bounding boxes from a masked image with 0/1 or 0/255.intGets the height of the image.getMask(int[][] mask) Returns a newImageof masked area.getSubImage(int x, int y, int w, int h) Gets the subimage defined by a specified rectangular region.intgetWidth()Gets the width of the image.Gets the wrapped image.resize(int width, int height, boolean copy) Creates a new resized image.voidsave(OutputStream os, String type) Save the image to file.default NDArrayConverts image to a RGBNDArray.toNDArray(NDManager manager, Image.Flag flag) Converts image to aNDArray.
-
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
Creates a new resized image.- Parameters:
width- the new image's desired widthheight- the new image's desired heightcopy- false to return original image if size is the same- Returns:
- the new resized image.
-
getMask
Returns a newImageof masked area.- Parameters:
mask- the mask for each pixel in the image- Returns:
- the mask image.
-
getSubImage
Gets the subimage defined by a specified rectangular region.- Parameters:
x- the X coordinate of the upper-left corner of the specified rectangular regiony- the Y coordinate of the upper-left corner of the specified rectangular regionw- the width of the specified rectangular regionh- 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
Converts image to a RGBNDArray. -
toNDArray
Converts image to aNDArray. -
save
Save the image to file.- Parameters:
os-OutputStreamto 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
Draws the bounding boxes on the image.- Parameters:
detections- the object detection results
-
drawBoundingBoxes
Draws the bounding boxes on the image.- Parameters:
detections- the object detection results
-
drawRectangle
Draws a rectangle on the image.- Parameters:
rect- the rectangle to drawrgb- the colorthickness- the thickness
-
drawMarks
Draws a mark on the image.- Parameters:
points- as list ofPoint
-
drawMarks
Draws a mark on the image.- Parameters:
points- as list ofPointsize- the radius of the star mark
-
drawJoints
Draws all joints of a body on an image.- Parameters:
joints- the joints of the body
-
drawImage
Draws the overlay on the image.- Parameters:
overlay- the overlay imageresize- true to resize the overlay image to match the image
-
createStar
Creates a star shape.- Parameters:
point- the coordinateradius- the radius- Returns:
- the polygon points
-