# Class SelfieSegmenter

java.lang.Object
com.codename1.ai.vision.SelfieSegmenter

All Implemented Interfaces:
  `VisionAnalyzer<SegmentationMask>, AutoCloseable`

public final class SelfieSegmenter extends Object

Separates a person from the background, for background replacement or blur.

    SelfieSegmenter segmenter = new SelfieSegmenter();
    EncodedImage photo = EncodedImage.create(jpegBytes);

    segmenter.process(VisionImage.encoded(jpegBytes)).ready(mask -> {
        // Everything below 60% foreground confidence becomes transparent, so
        // whatever is painted behind this image shows through.
        Image person = mask.cutOut(photo, 0.6f);
        preview.setIcon(person);
        segmenter.close();
    }).except(error -> {
        Log.e(error);
        segmenter.close();
    });

The mask has the model's own resolution rather than the frame's; `SegmentationMask.cutOut(com.codename1.ui.Image, float)` and `SegmentationMask.toMaskImage(int)` rescale it for you.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SelfieSegmenter()`
  Creates an analyzer using the platform default backend and options.
  `SelfieSegmenter(VisionOptions options)`
  Creates a reusable analyzer with explicit backend and result options.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `final void`
  `close()`
  Idempotently releases the retained native backend.
  `final boolean`
  `isSupported()`
  Tests the exact feature/backend pair configured for this analyzer.
  `final AsyncResource<SegmentationMask>`
  `process(VisionImage image)`
  Starts one analysis using the retained native backend.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### SelfieSegmenter

    public SelfieSegmenter()
    Creates an analyzer using the platform default backend and options.
    See Also:
      - `VisionOptions`

  - ### SelfieSegmenter

    public SelfieSegmenter(VisionOptions options)
    Creates a reusable analyzer with explicit backend and result options.
    Parameters:
      `options` - configuration captured by this analyzer; `null` uses defaults

- ## Method Details

  - ### isSupported

    public final boolean isSupported()
    Description copied from interface: `VisionAnalyzer`
    Tests the exact feature/backend pair configured for this analyzer.
    Specified by:
      `isSupported` in interface `VisionAnalyzer<T>`
    Returns:
      whether this analyzer's feature/backend is available and open

  - ### process

    public final AsyncResource<SegmentationMask> process(VisionImage image)
    Starts one analysis using the retained native backend.
    Specified by:
      `process` in interface `VisionAnalyzer<T>`
    Parameters:
      `image` - immutable encoded or raw input
    Returns:
      asynchronous typed result

  - ### close

    public final void close()
    Idempotently releases the retained native backend.
    Specified by:
      `close` in interface `AutoCloseable`
    Specified by:
      `close` in interface `VisionAnalyzer<T>`