alan-turing-institute / pixelflow

BSD 3-Clause "New" or "Revised" License
5 stars 4 forks source link

Add an example builtin shape analysis function #19

Closed quantumjot closed 1 year ago

quantumjot commented 1 year ago

See #5 and #20

This demonstrates how we can add custom analysis functions, complete with parameterisation (see the PixelflowLambda function, with the keyword argument n_terms).

In this case, I've added the Elliptic Fourier descriptor from the pyefd package.

Usage is like this:


from pixelflow.builtins.shape import efd
from pixelflow.core import pixelflow, PixelflowLambda

lambda_efd = PixelflowLambda(efd, n_terms=10)

features = pixelflow(
    mask,
    img,
    features=("area", "perimeter", "major_axis_length", "centroid"),
    custom=(lambda_efd,)
)
quantumjot commented 1 year ago

Note that there is some extraneous code here. I'm not sure how useful the decorator is yet, but I imagine it could be useful going forward.