Open fdecarpentier opened 4 years ago
Thanks for raising the issue. It turns out that I forgot a simple =
. It should be
@unpack id, is_outer, pixels = node.data # See Parameters.jl for "@unpack"
It turns out that the @unpack
macro is now also available in a standalone package UnPack.jl
.
Hence, if you do that package to your environment via
] add UnPack
then the following code snippet will run.
using ImageComponentAnalysis, TestImages, ImageBinarization, ImageCore, AbstractTrees, UnPack
img = Gray.(testimage("blobs"))
img2 = binarize(img, Otsu())
components = label_components(img2, trues(3,3), 1)
tree = establish_contour_hierarchy(components)
# Iterate over all DigitalContour's in the tree.
for node in PostOrderDFS(tree)
@unpack id, is_outer, pixels = node.data # See Parameters.jl or UnPack.jl for "@unpack"
@show id, is_outer, pixels
end
Note that the @unpack
macro is just a convenient short-hand for writing something like:
id = node.data.id
is_outer = node.data.is_outer
pixels = node.data.pixels
I see that you must be using the master branch. Apologies for not tagging a new release in such a long time. I did a bunch of clean-up since the last release. At the moment I am working on an implementation of Fourier Descriptors so that one can reason about the shape of a connected component based on its contour. Once that is finished I was planning to update all the documentation, give lots more examples and tag a new release.
Thank you for your answer! I'm still a bit confused about how this works but I think this package is great and unique!
Thanks for the kind words. Please could you elaborate on what you meant by "how this works". Were you referring to @unpack
, or how to extract knowledge about the topology of a connected component from the tree representation?
I still need to write some documentation for the concept of the contour hierarchy, but a good place to start to get the basic idea is to at the OpenCV example. I haven't implemented any convenience functions for grabbing information about where a component sits in the hierarchy. The OpenCV example talks about different "contour retrieval modes". I'm not sure that any of those constitute the best approach for representing the information, and hence I have just exposed the tree to the end-user so that they can decide what information they want to extract and how.
Actually I'm more interested in drawing the contour than hierarchy.
Hi,
Thanks for this very nice package. I'm trying to reproduce your example of contour drawing:
And I get this error:
I belive that it is due to the fact that @unpack belives that "pixels node.data" are two different Expr. I have no idea how Parameters.jl works...
Thank you for your time, Best regards,
Félix