Package ai.djl.modality.cv.output
Class CategoryMask
java.lang.Object
ai.djl.modality.cv.output.CategoryMask
- All Implemented Interfaces:
BytesSupplier
,ai.djl.util.JsonSerializable
,Serializable
A class representing the segmentation result of an image in an
Application.CV.SEMANTIC_SEGMENTATION
case.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
A customized Gson serializer to serialize theSegmentation
object. -
Constructor Summary
ConstructorsConstructorDescriptionCategoryMask
(List<String> classes, int[][] mask) Constructs a Mask with the given data. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Highlights the detected object on the image with random colors.void
Highlights the detected object on the image with random colors.void
Highlights the specified object with specific color.getBackgroundImage
(Image image) Extracts the background from the image.Returns the list of classes.int[][]
getMask()
Returns the class for each pixel.getMaskImage
(Image image) Extracts the detected objects from the image.getMaskImage
(Image image, int classId) Extracts the specified object from the image.Returns theByteBuffer
presentation of the object.toJson()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ai.djl.ndarray.BytesSupplier
getAsBytes, getAsObject, getAsString
-
Constructor Details
-
CategoryMask
Constructs a Mask with the given data.- Parameters:
classes
- the list of classesmask
- the category mask for each pixel in the image
-
-
Method Details
-
getClasses
Returns the list of classes.- Returns:
- list of classes
-
getMask
public int[][] getMask()Returns the class for each pixel.- Returns:
- the class for each pixel
-
toByteBuffer
Returns theByteBuffer
presentation of the object.- Specified by:
toByteBuffer
in interfaceBytesSupplier
- Returns:
- the
ByteBuffer
presentation of the object
-
toJson
- Specified by:
toJson
in interfaceai.djl.util.JsonSerializable
-
getMaskImage
Extracts the detected objects from the image.- Parameters:
image
- the original image- Returns:
- the detected objects from the image
-
getMaskImage
Extracts the specified object from the image.- Parameters:
image
- the original imageclassId
- the class to extract from the image- Returns:
- the specific object on the image
-
getBackgroundImage
Extracts the background from the image.- Parameters:
image
- the original image- Returns:
- the background of the image
-
drawMask
Highlights the detected object on the image with random colors.- Parameters:
image
- the original imageopacity
- the opacity of the overlay. Value is between 0 and 255 inclusive, where 0 means the overlay is completely transparent and 255 means the overlay is completely opaque.
-
drawMask
Highlights the detected object on the image with random colors.- Parameters:
image
- the original imageopacity
- the opacity of the overlay. Value is between 0 and 255 inclusive, where 0 means the overlay is completely transparent and 255 means the overlay is completely opaque.background
- replace the background with specified background color, use transparent color to remove background
-
drawMask
Highlights the specified object with specific color.- Parameters:
image
- the original imageclassId
- the class to draw on the imagecolor
- the rgb color with opacityopacity
- the opacity of the overlay. Value is between 0 and 255 inclusive, where 0 means the overlay is completely transparent and 255 means the overlay is completely opaque.
-