ukoethe / vigra

a generic C++ library for image analysis
http://ukoethe.github.io/vigra/
Other
407 stars 191 forks source link

connected path from crack edes #493

Closed Baehn closed 3 years ago

Baehn commented 3 years ago

Hello,

given a rag from one of the vigranumpy examples (e.g. created with rag = graphs.regionAdjacencyGraph(gridGraph, labels)) and an edge "e" from the rag, I can fetch all pixel coordinates of the corresponding crack edges with

rag.edgeCoordinates(e.id)

however the resulting coordinates do not form a connected path as the order is not (always) correct.

Is there an easy way to get the crack edges as a connected path?

hmeine commented 3 years ago

I think Ulli (or a look at the code) would have to answer this one. In which way is the order not always correct?

Baehn commented 3 years ago

you can check with "graph_3cycles.py" from the examples: If you plot all edges as connected paths, you will see that for some paths the order is "broken":

execute code from graph_3cycles.py" then

 for e in rag.edgeIter():
    arr = rag.edgeCoordinates(e.id)
    matplotlib.pyplot.plot(arr.T[0], arr.T[1])
 matplotlib.pyplot.show()

I think edgeCoordinates does simply not guarantee an order (so not a bug?). But maybe there is already a nice way to get connected paths.

hmeine commented 3 years ago

I am sorry, even after a quick look at the code (which I never used), I cannot tell how to accomplish that. edgeCoordinates() is implemented in Python and uses the graph's .affiliatedEdges internally, which is created using pyMakeRegionAdjacencyGraph() implemented in C++ in export_graph_rag_visitor.hxx.

While I agree that edges are characterized by having a dimensionality of 1, so that there should be a way of iterating them linearly, I cannot say if and how this API is supposed to support that.

Baehn commented 3 years ago

Ok, I found a solution: discovered your geomap on github, now I can make all queries I need. So thank you for your help (and geomap, it should be part of vigra) :)