目录

class info
com.huawei.hms.mlsdk.imgseg.MLImageSegmentation

Represents the category of each pixel after image segmentation by an image segmentation analyzer (MLImageSegmentationAnalyzer). The object attributes include: 

1. Label of each pixel after image segmentation.

2. Human body image with a transparent background.

3. Gray-scale image with a white human body and black background



Constant Summary
TypeNameDesc
BitmapforegroundHuman body image with a transparent background.
BitmapgrayscaleGray-scale image with a white human body and black background.
bytemasksSize of the semantic segmentation result of pixel detection in the current image category. The segmentation effect can be viewed only after secondary processing. The size is calculated by multiplying the image length by image width.
BitmaporiginalOriginal image for segmentation.

Public Constructor Summary

Constructor name
MLImageSegmentation(byte[] masks, android.graphics.Bitmap foreground, Bitmap grayscale)Constructor.
MLImageSegmentation(byte[] masks, android.graphics.Bitmap foreground, android.graphics.Bitmap grayscale, android.graphics.Bitmap original)Constructor.

Public Method Summary

Return typeMethod name
android.graphics.BitmapgetForeground()
android.graphics.BitmapgetGrayscale()
byte[]getMasks()
android.graphics.BitmapgetOriginal()

Constants

Constant
public Bitmap foreground
Human body image with a transparent background.
Constant
public Bitmap grayscale
Gray-scale image with a white human body and black background.
Constant
public byte masks
Size of the semantic segmentation result of pixel detection in the current image category. The segmentation effect can be viewed only after secondary processing. The size is calculated by multiplying the image length by image width.
Constant
public Bitmap original
Original image for segmentation.

Public Constructors

Method
public MLImageSegmentation(byte[] masks, android.graphics.Bitmap foreground, Bitmap grayscale)
Constructor.

Parameters

Parameter nameParameter desc
masksOne-dimensional array, which stores the category label of each pixel of an image.
foregroundHuman body image with a transparent background.
grayscaleGray-scale image with a white human body and black background.
grayscaleGray-scale image with a white human body and black background.
Method
public MLImageSegmentation(byte[] masks, android.graphics.Bitmap foreground, android.graphics.Bitmap grayscale, android.graphics.Bitmap original)
Constructor.

Parameters

Parameter nameParameter desc
masksOne-dimensional array, which stores the category label of each pixel of an image.
foregroundHuman body image with a transparent background.
grayscaleGray-scale image with a white human body and black background.
originalOriginal image for segmentation.

Public Methods

Method
public android.graphics.Bitmap getForeground()
Obtains the human body image with a transparent background. The segmentation effect can be directly viewed. (The edge burrs of static human body are optimized, and the display effect is better than that of secondary processing of pixel classification.)

Return

Typedesc
android.graphics.BitmapReturns the human body image with a transparent background.Detection success: Returns bitmap with the same size of the original image.Detection failure: Returns null.
Method
public android.graphics.Bitmap getGrayscale()
Obtains the gray-scale image with a white human body and black background. The segmentation effect can be directly viewed.

Return

Typedesc
android.graphics.BitmapReturns the gray-scale image with a white human body and black background.Detection success: Returns bitmap with the same size of the original image.Detection failure: Returns null.
Method
public byte[] getMasks()
Image segmentation result. The segmentation effect can be viewed only after secondary processing.

Return

Typedesc
byte[]Category label of each pixel after current image segmentation (for details, please refer to the definition of MLImageSegmentationClassification).Detection success: Returns a one-dimensional byte array with the length of the original image multiplied by its width.Detection failure: Returns null.
Method
public android.graphics.Bitmap getOriginal()
Returns the original image for segmentation.

Return

Typedesc
android.graphics.BitmapOriginal image for segmentation.