# アノテーション

## Annotation

画像はピクセルの配列から構成されています。ピクセルに対してアノテーションする方法として、 `segmentation` ツール（RLE - run-length encodingとして出力） または `vector` ツール（形状を構成する点を出力）の二つの方法をサポートしています。

### セグメンテーション (RLE)

RLE (run-length encoding) オブジェクトは、ラベルタイプが `segmentation`の場合 に使用され、各ラベルは一つのRLEオブジェクトを持てます。セグメンテーションを用いてアノテーションをすると、画像内のピクセルをアノテーションすることになります。

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

RLEオブジェクトは以下のように記述します：

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

* **type**: セグメンテーションの種類。`rle` のみサポートされています。
* **segmentation**: RLEの2次元配列。
  * segmentationの最小単位は整数の1x1のピクセルエリアになります。
  * 例えば、4x4ピクセルの画像に対するアノテーションがあった場合、配列は以下のような値をとりえます：

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

&#x20;

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

### ベクター

ベクターオブジェクトは、ラベルタイプが`vector` の場合のみ使用され、各ラベルは複数のベクターオブジェクトを持てます。ベクターを用いてアノテーションすると、画像内のアノテーションの形状の座標を記述することになります：

![](/files/-MFssAMnbdv3fbUGJ8aU)

ベクターオブジェクトは以下のように記述します：

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

* **type**: ベクターオブジェクトの種類。以下の種類をサポートしています： `polygon`, `boundingBox`, `path` , `point`。
* **attributes**: ベクターオブジェクトに付与されたカスタム属性。
  * **name**: 属性の名前。
  * **values**: 属性の値の配列。
* **segmentation**: ベクターオブジェクトを記述する座標の配列。
  * segmentationの最小単位は float (浮動小数点型)の座標になります。
  * segmentationの種類が `polygon`の場合、以下のような値をとります `[x1, y1, x2, y2, ..., xn, yn]`。
  * segmentationの種類が`boundingBox`の場合、以下のような値をとります

    &#x20;`[x1, y1, x2, y2, x3, y3, x4, y4]`。
  * segmentationの種類が`path`の場合、以下のような値をとります `[x1, y1, x2, y2, ..., xn, yn]`。
  * segmentationの種類が`point`の場合、以下のような値をとります`[x1, y1]`。
  * 座標は時計回りでも反時計回り一貫した順序に沿っていればどちらでも構いません。
  * 例えば、4x4ピクセルの画像に対するアノテーションがあった場合、配列は以下のように記述できます：

![](/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/jpn/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.
