ukoethe/vigra — pull request #111 by markus-nullmeier (2012-03-16 23:38:59+00:00)
Title: Python bindings for accumulators a.k.a. object features

Sample session:

In [2]: image = vigra.impex.readImage('image.png')

In [3]: labels = vigra.impex.readImage('labels.png', dtype="UINT32")

In [4]: acc = vigra.analysis.extractFeatures(image, labels, 'center of mass')

In [5]: acc['center of mass']
Out[5]:
VigraArray(shape=(7, 2), axistags=x c, dtype=float32, data=
[[ 254.57258606 242.90429688 234.39247131 NaN NaN
250.78726196 249.44869995]
[ 175.4069519 234.64147949 244.92553711 NaN NaN
180.56497192 208.06402588]])

In [6]: acc['center of mass'][0]
Out[6]:
VigraArray(shape=(2,), axistags=c, dtype=float32, data=
[ 254.57258606 175.4069519 ])

In [7]: acc.selected()
Out[7]: ['center of mass', 'sum', 'weighted sum']