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

Index Error #8

Closed
rahulmoorthy19 opened this issue Mar 4, 2021 · 8 comments
Closed

Index Error #8

rahulmoorthy19 opened this issue Mar 4, 2021 · 8 comments

Comments

@rahulmoorthy19
Copy link

Hello Moritz,

Thanks for such a great implementation of Polygon based on SNIC...i am facing one small issue...so In some cases..I am observing that the polygonize code is giving index error with queue[-1]...I was hoping you could help out in finding a way to solve it.

Preview of the Error is below-

Traceback (most recent call last):
File "trial.py", line 33, in
graphs = polygonize(segmentation, seeds, rdp)
File "/home/sirzech/anaconda3/lib/python3.8/site-packages/pysnic/algorithms/polygonize.py", line 522, in polygonize
graphs = trace_isles(vertices, seeds, segmentation)
File "/home/sirzech/anaconda3/lib/python3.8/site-packages/pysnic/algorithms/polygonize.py", line 304, in trace_isles
vertices, edges = trace_edges_unsafe(px, py, direction, segmentation)
File "/home/sirzech/anaconda3/lib/python3.8/site-packages/pysnic/algorithms/polygonize.py", line 348, in trace_edges_unsafe
idx = queue[-1]
IndexError: list index out of range

Thanks,
Rahul Moorthy

@MoritzWillig
Copy link
Owner

Hi Rahul,
thanks for your feedback! I just had a look at the code and checked in a new commit, that hopefully resolves your error. If the change fixes your problem I will release a new version on pip later today.

Best,
Moritz

@rahulmoorthy19
Copy link
Author

Yes, I tried it out now, it seems to be working...Thanks a lot...

@rahulmoorthy19
Copy link
Author

I also wanted to know one more thing, instead of the vertices and edges...can the algo directly give the polygon? or do we need to write custom logic for that?

@MoritzWillig
Copy link
Owner

I currently have no plans for adding such functionality to the code, as there already exist more advanced libraries to handle polygons and/or meshes (e.g. OpenMesh). The extracted data structure is also likely to depend on the specific use case (- point list, half-edge structure, ...).

Just a remark about extracting polygons: Depending on the parameters, the SNIC algorithm can produce superpixels that are fully enclosed into others. Simply converting to polygons by tracing the edges may violate this topology, as the enclosing super-pixels may also cover the area of the enclosed ones. This may be problematic if you plan to do some calculations/statistics on them. If you simply want to visualize the superpixels, make sure to draw the graphs in the provided order. Graphs containing the enclosed superpixels are provided last in the returned graph list.

If you got some suggestions for adding such functionality in a proper way, I can try to free some time and add it to the repo.

@rahulmoorthy19
Copy link
Author

rahulmoorthy19 commented Mar 4, 2021

I just want to visualize...and send the polygon coordinates...will keep in mind the point which you mentioned..will implement and let you know if at all a way exists which will be useful for the community

@MoritzWillig
Copy link
Owner

MoritzWillig commented Mar 7, 2021

Just in case you are again encountering index out of bound errors in the polygonization method - I just revised the code to cover some more edge cases. (Fixed the same error in another sub-method and prevented some edges from being mistakenly discarded).

@rahulmoorthy19
Copy link
Author

Thanks a lot Moritz....just wanted to know...whether you have updated the same in the pip version of pysnic

@MoritzWillig
Copy link
Owner

Just updated the pip package. 👍

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

2 participants