Skip to content

Remove need for openCV in write_evr by implementing C++/Cython/Numba accelerated contour finding #226

Description

@ctuguinay

In #225 I added write_evr capability. Currently, openCV is used to do the contour finding in write_evr. I spent some time trying to write different contour finding algorithms in numpy, but these were rather slow compared to openCV (and scikit-image) implementations since they were C++/Cython accelerated. ~12seconds vs ~0.1seconds for a 3955 x 1681 matrix ended up being the time comparison. The problem with installing openCV is that it drastically inflates the size of the Echoregions package, which is supposed to be lightweight, so we'll need to implement some form of contour finding in the future.

The algorithm which openCV uses is Suzuki-Abe and this algorithm works well with holes. It's rather involved to implement, so I'll need to heavily reference openCV's implementation (https://github.com/opencv/opencv/blob/master/modules/imgproc/src/contours.cpp) to do this. Another option to try is an accelerated version of Moore-neighborhood tracing algorithm, which doesn't work well with holes, but with path simplification, can be robust as Suzuki-Abe in contour tracing of regions containing no holes.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions