Skip to content

pyamiimage: AmiGraph

petermr edited this page Nov 27, 2021 · 3 revisions

AmiGraph, AmiNode, AmiEdge, AmiIsland

sknw outputs nodes and edges in a dictionary with somewhat cryptic keys (e.g. "o" is coordinates). These Ami* classes will wrap the sknw output, probably with deep copying. However there is a close link to NetworkX which gives the subcomponents (we use "Islands" and it's more descriptive than component). A problem is that sknw (or routines it uses) holds coordinates as (y, x) so it is safer to copy (we are unlikely to modify the NetworkX graph).

inputs and outputs

input

Skeletonized image, white on black. Not yet clear whether it's 0.0 -> 1.0 or 0 -> 255 or both. We assume it's correct and AmiGraph does no image processing.

output

### AmiGraph

contains

    AmiNodeDict, AmiEdgeDict
    [AmiIsland [, AmiIsland...]]

We need the dicts to hold the Id's of the nodes and edges and the Objects they refer to. The Islands then consist of pointers to these dicts. If there is only one Island it might be omitted but I'd prefer to keep it anyway.

AmiIsland

contains

    AmiNode [, AmiNode...]
    AmiEdge [, AmiEdge...]

AmiNode

contains node key and 2 sets of coordinates (with sknw keys)

  • CENTROID ("o")

The centroid of the node

  • PTS ("pts")

All the points in the node. Often this is the same as the CENTROID, but some nodes with many connections are stretched out.

AmiEdge

a pair of node keys. We will order them numerically (lo-hi)

  • PTS ("pts") (check this)

All the points in the edge. Note that edges may be curved and so the BBox may extend between corners of the nodes.

bounding boxes

There will be BBox objects for AmiGraph, AmiIsland, AmiEdge and (opt