Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable getting segmentations at any threshold #46

Merged
merged 1 commit into from
Apr 10, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 16 additions & 3 deletions gala/agglo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ def update_merge_queue(self, u, v):
self.merge_queue.push(new_qitem)


def get_segmentation(self):
def get_segmentation(self, threshold=None):
"""Return the unpadded segmentation represented by the graph.

Remember that the segmentation volume is padded with an
Expand All @@ -1752,7 +1752,10 @@ def get_segmentation(self):

Parameters
----------
None
threshold : float, optional
Get the segmentation at the given threshold. If no
threshold is given, return the segmentation at the current
level of agglomeration.

Returns
-------
Expand All @@ -1764,7 +1767,17 @@ def get_segmentation(self):
--------
get_ucm
"""
m = self.tree.get_map()
if threshold is None:
# a threshold of np.inf is the same as no threshold on the
# tree when getting the map (see below). Thus, using a
# threshold of `None` (the default), we get the segmentation
# implied by the current merge tree.
threshold = np.inf
elif threshold > self.max_merge_score:
# If a higher threshold is required than has been merged, we
# continue the agglomeration until that threshold is hit.
self.agglomerate(threshold)
m = self.tree.get_map(threshold)
seg = m[self.watershed]
if self.pad_thickness > 1: # volume has zero-boundaries
seg = morpho.remove_merged_boundaries(seg, self.connectivity)
Expand Down