Select one of the indices within slice containing val. Args: val : value for comparison dim : dimension in which to look for value
(val, dim)
| 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): |
no test coverage detected
searching dependent graphs…