-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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 scanline algorithm for drawing polygons #931
base: main
Are you sure you want to change the base?
Conversation
Suggestions for API and placement within skimage welcome. Code may have to be turned to Cython code to compete with existing polygon drawing, even though the algorithm should be much faster for large polygons. |
@@ -154,3 +224,24 @@ def set_color(img, coords, color): | |||
rr, cc = coords | |||
rr, cc = _coords_inside_image(rr, cc, img.shape) | |||
img[rr, cc] = color | |||
|
|||
|
|||
if __name__ == "__main__": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this was for testing purposes.
Is there a reason why we not replace the existing function altogether? Does it produce the same result? |
@ahojnnes 👍 agreed, if possible the ideal change would be a drop-in replacement. That function gets used directly or indirectly quite a bit, so existing test coverage should be very good. |
It depends on which one you want to replace, I guess. It gives identical results to the existing |
Hmm, perhaps both should be replaced? I haven't delved into this deeply to see if a single backend is reasonable/possible; if not (or if the overhead would be undesirable) perhaps |
I just realised that it may very well be that the difference in these
|
@stefanv thanks for resurrecting this! Looks great! Care to change it to rows/cols and Cythonize the loop? ;) I would also think that using lists is unnecessary. Pairs is simple enough to implement with looping, and you can pre-allocate an array of the same size as the number of segments for intersections. |
Implementation of a scanline algorithm for rendering polygons in response to #928