Currently the labels spec supports the declaration of a label-value
and its associated color
.
Commonly, label values have other associated information including the most obvious, the class name. napari also supports display of label properties, so this would be a nice additional feature for the reader plugin.
I think the critical requirements for these properties should be:
- Supporting an easy mapping between a given property and the
label-value
/s it is associated with
- Enforcing as few rules as possible on what kinds of properties can be accepted
- Supporting an arbitrary number of properties
There are three ways I can see the spec supporting these additional properties:
- Arbitrary number of lists of max length n for a label image containing n label values, each corresponding to a property. The index in the list corresponds to the integer
label-value
e.g.
"image-label": {
"version": "0.1",
"colors": [
{
"label-value": 1,
"rgba": [
255,
100,
100,
255
]
},
{
"label-value": 2,
"rgba": [
0,
40,
200,
255
]
},
{
"label-value": 3,
"rgba": [
148,
50,
165,
255
]
}
],
"properties": [
{
"class": [
"Urban",
"Water",
"Agriculture"
],
"area_m2":
[
"400",
"1532",
"590"
]
}
]
}
I think this is least explicit, and less intuitive than the next approaches.
- Declare another group similar to colors, where each
label-value
has its own associated properties:
{
"multiscales": [
{
"datasets": [
{
"path": "0"
},
{
"path": "1"
},
{
"path": "2"
},
{
"path": "3"
}
],
"version": "0.1"
}
],
"image-label": {
"version": "0.1",
"colors": [
...
],
"properties": [
{
"label-value": 1,
"class": "Urban",
"area_m2": "400"
},
{
"label-value": 2,
"class": "Water",
"area_m2": "1532"
},
{
"label-value": 3,
"class": "Agriculture",
"area_m2": "590"
}
]
}
}
This is explicit, but has the disadvantage of duplicating the label-value
definitions.
- Make color another property e.g.
"properties": [
{
"label-value": 1,
"rgba": [
255,
100,
100,
255
],
"class": "Urban",
"area_m2": "400"
},
{
"label-value": 2,
"rgba": [
148,
50,
165,
255
],
"class": "Water",
"area_m2": "1532"
},
{
"label-value": 3,
"rgba": [
148,
50,
165,
255
],
"class": "Agriculture",
"area_m2": "590"
}
]
This doesn't duplicate label-values
, and has the benefit of keeping all properties associated with a particular label-value
in one spot.
On the implementation side, I think the differences in parsing the properties are negligible.
I'd love to hear what other people think are appropriate ways to represent the properties in the label metadata, or what they think the best option is.