MCPcopy Create free account
hub / github.com/Project-MONAI/MONAI / _get_point

Function _get_point

monai/transforms/utils.py:1610–1628  ·  view source on GitHub ↗

Select one of the indices within slice containing val. Args: val : value for comparison dim : dimension in which to look for value

(val, dim)

Source from the content-addressed store, hash-verified

1608 raise ValueError("get_extreme_points: no foreground object in mask!")
1609
1610 def _get_point(val, dim):
1611 """
1612 Select one of the indices within slice containing val.
1613
1614 Args:
1615 val : value for comparison
1616 dim : dimension in which to look for value
1617 """
1618 idx = where(indices[dim] == val)[0]
1619 idx = idx.cpu() if isinstance(idx, torch.Tensor) else idx
1620 idx = rand_state.choice(idx) if rand_state is not None else idx
1621 pt = []
1622 for j in range(img.ndim):
1623 # add +- pert to each dimension
1624 val = int(indices[j][idx] + 2.0 * pert * (rand_state.rand() if rand_state is not None else 0.5 - 0.5))
1625 val = max(val, 0)
1626 val = min(val, img.shape[j] - 1)
1627 pt.append(val)
1628 return pt
1629
1630 points = []
1631 for i in range(img.ndim):

Callers 1

get_extreme_pointsFunction · 0.85

Calls 4

whereFunction · 0.90
maxFunction · 0.85
minFunction · 0.85
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…