Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pyBPL for stroke extraction #1158

Open
spigo900 opened this issue Jun 28, 2022 · 3 comments
Open

Use pyBPL for stroke extraction #1158

spigo900 opened this issue Jun 28, 2022 · 3 comments

Comments

@spigo900
Copy link
Collaborator

We'd like to convert the stroke extraction code (#1151) to use PyBPL once we have things working. Our current GNN processing code in #1151 uses Matlab BPL with some modifications by @shengcheng. It would make documenting setup easier if we could use Python for this component instead. There is a partial Python implementation of BPL. It would be nice if we could use a modified version of pyBPL instead of calling out to Matlab.

The first step here is determining if this is possible. It looks like this might not be, because pyBPL uses the Matlab API for some parts that aren't yet implemented. Stroke extraction might be one.

(In theory we could reimplement the stroke extraction logic ourselves, maybe calling out using say opencv-python (or similar tools) but I expect that's probably more work than is worthwhile at this point.)

@spigo900
Copy link
Collaborator Author

Since I just looked through the code, it might be some help to point out that AFAICT anyway the stroke extraction code uses only three exports from BPL:

  • extract_junctions() (function)
  • trace_graph() (function)
  • UGraph (class)

Unfortunately, it doesn't look like PyBPL covers these at the moment. So if we want to replace them we would have to re-implement those parts ourselves.

I think rewriting this ourselves is doable but there are bound to be some difficulties. It's doable because there are only ~600 or 700 lines of code total, with no randomness and nothing that looks obviously irreplaceable to me. As for difficulties, I think potentially the most annoying here is finding equivalents for Matlab's image processing functions, specifically edge(), imdilate(), imbothat(), bwmorph(), and bwconncomp(). (These are the functions I noticed were used in ske.m and its dependencies.) Pillow or OpenCV might be useful if we decided to go down that route.

@lichtefeld
Copy link
Collaborator

For now let’s have this rewrite as a lower priority given we have the matlab version functioning. It be nice to only need to invoke Python scripts for processing but this may be a larger project time wise than we want to tackle before the demo.

@spigo900
Copy link
Collaborator Author

@lichtefeld I agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants