Skip to content

How to get the images corresponding to each shape of the tree ? #217

Answered by PerretB
nboutry asked this question in Q&A
Discussion options

You must be logged in to vote

Hello,

the following example demonstrates how to get a binary mask giving all the vertices of the base graph (pixels) that do (not) belong to a node of a hierarchy:

import higra as hg
import numpy as np
import matplotlib.pyplot as plt
from skimage import data

im = data.coins()
plt.imshow(im)

# construct the tree of shapes of im
tree, altitudes = hg.component_tree_tree_of_shapes_image2d(im)

# perform an area filter to remove small components of the tree
area = hg.attribute_area(tree)
tree, _ = hg.simplify_tree(tree, area < 100)

# construct a vector that will be true for any node expect the one we want
deleted = np.ones(tree.num_vertices(), dtype=np.bool)
# arbitrarily select the 50th n…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by PerretB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #217 on December 10, 2020 11:18.