> ## Documentation Index
> Fetch the complete documentation index at: https://docs.runanywhere.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Segmentation

> Find and label regions in an image

Segmentation outlines objects in an image and labels them. Where a
[vision model](/react-native/vlm) describes a picture in words, segmentation gives you the
regions themselves: a mask per object, with a class and a confidence.

```ts theme={null}
import { ImageInputs } from '@runanywhere/core'

const result = await RunAnywhere.segmentation.segment(ImageInputs.file(path), {
  includeDiagnosticImage: true,
})
```

## Building the input

```ts theme={null}
ImageInputs.file(path)
ImageInputs.bytes(data)
ImageInputs.base64(value)
ImageInputs.rawRgb(data, width, height)
ImageInputs.rawRgba(data, width, height)
```

Note the plural name. Every other SDK calls this `ImageInput`.

## Options

| Field                    | Default | Meaning                                         |
| ------------------------ | ------- | ----------------------------------------------- |
| `includeDiagnosticImage` | `false` | Return a rendered overlay alongside the regions |

Turn the diagnostic image on while you are building the feature: it shows you what the model
actually found, which is much faster than reasoning about mask arrays. Turn it off in
production, since rendering it costs time and memory you do not have on a phone.

## What comes back

A `SegmentationResult` holds the regions found. Each carries its class label, a confidence, and
the mask itself, so you can draw an outline, crop to the object, or count instances.

## Segmentation or a vision model

| You want                            | Use                      |
| ----------------------------------- | ------------------------ |
| A sentence about the picture        | [VLM](/react-native/vlm) |
| "Is there a dog in this"            | VLM                      |
| The exact pixels of the dog         | Segmentation             |
| Object counts, or a crop            | Segmentation             |
| Anything you will draw on the image | Segmentation             |

## Availability

Segmentation needs a registered segmentation model and a backend that serves it. The namespace
existing does not mean the catalog has an entry.
