I would like to convert a JSON file back into a png image or a NumPy array. The file JSON file consists of a list of coordinates and other metadata. As an example. it would look like this :
"firstEditDate": "2019-12-02T19:05:45.393Z",
"lastEditDate": "2020-06-30T13:21:33.371Z",
"folder": "/Pictures/poly",
"objects": [
{
"classIndex": 5,
"layer": 0,
"polygon": [
{
"x": 0,
"y": 0
},
{
"x": 1699.7291626931146,
"y": 0
},
{
"x": 1699.7291626931146,
"y": 1066.87392714095
},
{
"x": 0,
"y": 1066.87392714095
}
],
},
{
"classIndex": 2,
"layer": 0,
"polygon": [
{
"x": 844.2300556586271,
"y": 711.8243676199173
},
{
"x": 851.156462585034,
"y": 740.5194820293175
},
{
"x": 854.1249226963513,
"y": 744.477428844407
},
{
"x": 854.1249226963513,
"y": 747.4458889557243
},
(coordinates should be rounded to the nearest ones prior to creating the array or image)
The dimension of the array/ picture should be 1727 x 971
Is there any function in python that can convert the file either into an array with the value inside the array of the ClassIndex
? Or into a picture where each ClassIndex
is assigned to a specific color?