I’m super new to Julia, and am porting over a python program of mine to Julia to get a feel for the language. I’ve constructed a region adjacency graph (RAG) for an image using ImageSegmentation.region_adjacency_graph.
I’d like to merge adjacent regions in the graph if they are similarly colored (Colors.colordiff of the regions’ mean color under some threshold). In Python’s scikit-image, there’s a handy merge_hierarchical function – is there something similar in Julia, or should I reimplement/port that function to my project?
I’m looking to accomplish something similar to what is posted about here.
My code so far:
using Colors, Images, TestImages, ImageView, ImageSegmentation
lena = testimage("lena_color_512.tif")
seg = ImageSegmentation.felzenszwalb(lena, 10, 1000)
# imshow(map(i-> ImageSegmentation.segment_mean(segs, i), ImageSegmentation.labels_map(segs)))
weight(i, j) = Colors.colordiff(segment_mean(seg, i), segment_mean(seg, j))
G, vert_map = region_adjacency_graph(seg, weight)
# now, can I do a hierarchical merge of G with some color difference threshold?
Thanks! I think submitting it as a PR to ImageSegmentation would be fine (and it would be easier to review that way since PRs have line-by-line comments). It would need tests and more documentation. (You’re aware that docstrings go before the function you want to document, right?) A good example of the kind of documentation we strive for is
The # Examples section is quite useful for newbies, and the # Citation section is great for those who want to learn more.