Search code examples
python-3.xopencvimage-processingscikit-learnscikit-image

regarding the code performing region boundary based RAGs using skimage


Regarding the Region Boundary based RAGs, I am not clear about the code on defining edges_rgb, if I perform the RAG analysis over a gray image, why I need to transfer the edges into rgb color?

edges_rgb = color.gray2rgb(edges)
g = graph.rag_boundary(labels, edges)
lc = graph.show_rag(labels, g, edges_rgb, img_cmap=None, edge_cmap='viridis',
                    edge_width=1.2)

Solution

  • It turns out you don't. This code does the same thing:

    g = graph.rag_boundary(labels, edges)
    lc = graph.show_rag(labels, g, edges, img_cmap='gray', edge_cmap='viridis',
                        edge_width=1.2)
    

    I guess the original author preferred using gray2rgb and no colormapping. But it's a matter of preference, not necessity!