Sources with the BigML Dashboard

5.7 Regions

Regions fields are used to represent areas of interest in an image. They are typically used as the objective field in object detection models. Figure 5.15 shows the icon BigML uses to refer to them.

\includegraphics[width=2cm]{images/sources/source-datatype-icon-regions}
Figure 5.15 Regions field icon

The values of a regions field can be specified either by a list of 5-tuples, or a list of JSON maps, also know as JSON objects.

The canonical form of a region is a 5-tuple, or a list of 5 elements. The first element is the class label, the rest are the coordinates of the bounding box. Specifically, this is a region:

      [label xmin ymin xmax ymax]

so is this (commas are optional):

      [label, xmin, ymin, xmax, ymax]

where label is the class to which the object belongs, (xmin ymin) are the coordinates of the top left vertex of the bounding box, (xmax ymax) the coordinates of the bottom right vertex.

For example, the following two represent the same region:

      ["abc" 10 15 36 29]
      ["abc", 10, 15, 36, 29]

Equivalently, a JSON map can be used to represent a region:

      {"label": label, "xmin": xmin, "ymin": ymin, "xmax": xmax, "ymax": ymax}

A JSON map representing a region may use any of these key collections:

  1. (label, xmin, ymin, xmax, ymax) where (xmin, ymin) is the top left vertex of the region, while (xmax, ymax) the bottom right vertex. This is the canonical tuple representation. If no keys are used in a JSON map, the coordinates are assumed to be in this format.

  2. (label, xmin, ymin, width, height) where (xmin, ymin) is the top left vertex of region, while (width, height) the width and height of the region, respectively.

  3. (label, xmax, ymax, width, height) where (xmax, ymax) is the bottom right vertex of region, while (width, height) the width and height of the region, respectively.

  4. (label, x, y, width, height) where (x, y) is the center of the region, while (width, height) the width and height of the region, respectively.

  5. (label, xcenter, ycenter, width, height) which is a synonym of 4, with xcenter for x and ycenter for y.

As one image may contain more than one object, the value of its regions field is a list of 5-tuples, or a list of JSON maps. For instance, the following two JSON maps are equivalent for the annotation of one image (the backslash \ is the line continuation mark, meaning the two lines should be read as a single line):

{"file":"a.png","box":[["cat",20,150,250,300]]}
{"file":"a.png","box":[{"label":"cat", "xmin": 20, "ymin": 150, \
                       "xmax": 250, "ymax": 300}]}

The same region can also be specified as:

{"file": "a.png", "box": [{"label": "cat", "x": 135, "y": 225, \
                           "width": 230, "height": 150}]}