Segmentation
Stay organized with collections
Save and categorize content based on your preferences.
Entry point for identifying pixels in a supplied image as being part of the foreground or
the background.
Segmenter segmenter = Segmentation.getClient(segmenterOptions);
To perform segmentation of an image, you first need to create an instance of
InputImage
from a Bitmap
,
ByteBuffer
, etc. See
InputImage
documentation for more details. For example, the code below creates an InputImage
from a Bitmap
.
InputImage image = InputImage.fromBitmap(bitmap, rotationDegrees);
Then the code
below can segment the supplied
InputImage
and
asynchronously return a
SegmentationMask
.
Task<SegmentationMask> task = segmenter.process(image);
task.addOnSuccessListener(...).addOnFailureListener(...);
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
void |
finalize()
|
final Class<?>
|
getClass()
|
int |
hashCode()
|
final void |
notify()
|
final void |
notifyAll()
|
String
|
toString()
|
final void |
wait(long arg0, int arg1)
|
final void |
wait(long arg0)
|
final void |
wait()
|
Public Methods
Gets an instance of Segmenter
that can segment the foreground and the background of an image.
To release the resources associated with a Segmenter
,
you need to ensure that Segmenter.close()
is called on the resulting Segmenter
instance once it will no longer be used.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["The `Segmentation` class is used to identify foreground and background pixels in an image."],["To use it, you first create an `InputImage` from your image source (e.g., Bitmap)."],["You then obtain a `Segmenter` instance using `Segmentation.getClient()` with desired options."],["Finally, you call `segmenter.process()` on the `InputImage` to get a `SegmentationMask` representing the segmentation result."],["Remember to close the `Segmenter` instance using `Segmenter.close()` when you are finished with it."]]],["To segment an image, obtain a `Segmenter` instance via `Segmentation.getClient(segmenterOptions)`. Create an `InputImage` from a `Bitmap` or `ByteBuffer`. Use `segmenter.process(image)` to segment the image, which returns a `Task\u003cSegmentationMask\u003e` asynchronously. Attach success and failure listeners to this task. Once finished with the `Segmenter`, call `Segmenter.close()` to release resources. `Segmenter` identifies pixels as either foreground or background.\n"]]