Being a little naive I was hoping to have a simple set of edges to traverse. I found a Peekaboo blog entry: http://peekaboo-vision.blogspot.com.au/2011/08/region-connectivity-graphs-in-python.html
Also, any advice/gotchas on how to join/combine segments?
# connected_components is a list of lists, for example
out = np.zeros_like(image)
for i, c in enumerate(connected_components):
for superpixel in c:
out[image==superpixel] = i+1
return out
On 22/04/13 8:32 PM, Stéfan van der Walt wrote:Thanks for sharing that good advice. Juan. There is also anintermediary storage format, one that I used before with some success.Think of a 2-D example: you store the start and end indices of eachcolumn that comprises the object, paired with an index into the rows(very similar to CSR).
Perhaps it will be a bit painful to extend to N-d, but it is doable.
Another option is to store a graph in an array. This goes along verywell with the implementation of ``graph.label``. At each position inthe array, you store the index of the previous pixel to which it isconnected. For any super-pixel, you can then store only the lastpixel, and traverse indices backward to get the entire super-pixel.Con: 2 x storage.