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

Add epsilon parameter to find_contours() for smoother border paths #9

Open
ShangAlex opened this issue May 5, 2022 · 0 comments
Open

Comments

@ShangAlex
Copy link

Proposing changes to find_contours.pyx line 73, 114

https://github.com/v7labs/upolygon/blob/master/upolygon/find_contours.pyx

It looks like the default implementation of find_contours() determines the integer point boundary and then calls simplify_polygon() with a default epsilon of 0, allowing for no interpolation outside of consecutive linearly interpolatable points (for example, (0,1) (0,2) (0,3) could be simplified to (0,1) (0,3)). In the case of ellipsoid contours, this could result in horribly complex borders with more roughness along the border than in reality.

Without diving into cublic spline fitting options, let me propose adding an epsilon parameter to find_contours() which can be passed into the final call of simplify_polygon(), changing

return labels, simplify_polygon(outer_paths, 0), simplify_polygon(inner_paths, 0)
to
return labels, simplify_polygon(outer_paths, epsilon), simplify_polygon(inner_paths, epsilon)

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

No branches or pull requests

1 participant