json2contours

tomni.transformers.json2contours(json: dict) numpy.ndarray[source]

Convert a JSON object in a default AxionBio format to a contour represented as a NumPy array.

Parameters

json (dict) – A JSON object containing ‘points’ in the form of a list of dictionaries with keys ‘x’ and ‘y’, and ‘type’ set to ‘polygon’.

Returns

A contour represented as a NumPy array.

Return type

np.ndarray

Raises

ValueError – If the ‘type’ in the JSON object is not ‘polygon’ or missing.