Args: img: data to be transformed, assuming `img` is channel first.
(self, img: NdarrayOrTensor)
| 1517 | self.spatial_dims = spatial_dims |
| 1518 | |
| 1519 | def __call__(self, img: NdarrayOrTensor) -> NdarrayOrTensor: |
| 1520 | """ |
| 1521 | Args: |
| 1522 | img: data to be transformed, assuming `img` is channel first. |
| 1523 | """ |
| 1524 | if max(self.spatial_dims) > img.ndim - 2 or min(self.spatial_dims) < 0: |
| 1525 | raise ValueError(f"`spatial_dims` values must be within [0, {img.ndim - 2}]") |
| 1526 | |
| 1527 | spatial_size = img.shape[1:] |
| 1528 | coord_channels = np.array(np.meshgrid(*tuple(np.linspace(-0.5, 0.5, s) for s in spatial_size), indexing="ij")) |
| 1529 | coord_channels, *_ = convert_to_dst_type(coord_channels, img) # type: ignore |
| 1530 | coord_channels = coord_channels[list(self.spatial_dims)] |
| 1531 | return concatenate((img, coord_channels), axis=0) |
| 1532 | |
| 1533 | |
| 1534 | class ImageFilter(Transform): |
nothing calls this directly
no test coverage detected