# Annotation

## Annotation

An image is composed of array of pixels, and we have two ways to annotate on the pixels, by using the `segmentation` tool (as RLE - run-length encoding) and `vector` tool.

### Segmentation (RLE)

RLE (run-length encoding) object is used only when the label type is `segmentation`, and each label contains only one RLE object. When annotating with RLE, we basically annotate the pixel in the image:

<div align="center"><img src="/files/-MFsr9461RvMil0h3916" alt=""></div>

An RLE object is represented as:

```
{
  "type": STRING,
  "segmentation": [
    [x, y, length from x to right],
    ...
  ]
}
```

* **type**: Type of the segmentation, which currently supports `rle` only.
* **segmentation**: Two-dimensional array for RLE.
  * The minimal unit of segmentation is a 1x1 pixel area, which is an integer.
  * For example, given by the 4x4 pixel image below with annotation, the array will be:

```
{
  "segmentation": [
    [2, 0, 2],
    [0, 1, 3],
    [2, 2, 1]
  ]
}
```

&#x20;

![](/files/-MFss-VXeB89_z9uMQZ8)

### vector

A vector object is used only when the label type is `vector`, and each label can contain multiple vector objects. When annotating with vector, we basically describe the coordinates of the annotation in the image:

![](/files/-MFssAMnbdv3fbUGJ8aU)

A vector object is represented as:

```
{
  "type": STRING,
  "attributes": [
    {
      "name": STRING,
      "values": [STRING]
    }
  ],
  "segmentation": [x1, y1, x2, y2, ..., xn, yn]
}
```

* **type**: Type of the vector object, currently supports `polygon`, `boundingBox`, `path` and `point`.
* **attributes**: Custom attributes to describe the vector object.
  * **name**: Name of the attribute.
  * **values**: Array of value to the attribute.
* **segmentation**: Array of coordinate which represents the vector object.

  * The minimal unit of segmentation is a coordinate, which is float.
  * if the segmentation type is `polygon`, the value will be `[x1, y1, x2, y2, ..., xn, yn]`.
  * if the segmentation type is `boundingBox`, the value will be `[x1, y1, x2, y2, x3, y3, x4, y4]`.
  * if the segmentation type is `path`, the value will be `[x1, y1, x2, y2, ..., xn, yn]`.
  * if the segmentation type is `point`, the value will be `[x1, y1]`.
  * The coordinates can be either clockwise or counterclockwise as long as it follows the order.
  * For example, given by the 4x4 pixel images below with annotation, the array will be:

  &#x20;

![](/files/-MGDBUPUkflLwNWZ1I8s)

![](/files/-MGDBbMWY4SxSnuhK_YC)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.annostation.orni.co.jp/resources/json/json-annotation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
