Commit 01711cf
Fixes #8656
Distance_transform_edt indices preallocation to use channel-first (C,
spatial_dims, ...) layout for both torch/cuCIM and NumPy/SciPy paths,
resolving “indices array has wrong shape” errors when
return_indices=True.
### Description
```
import torch
from monai.transforms.utils import distance_transform_edt
img = torch.tensor([[[0, 0, 1],
[0, 1, 1],
[1, 1, 1]]], dtype=torch.float32) # shape (1, 3, 3)
# Previously raised: RuntimeError: indices array has wrong shape
indices = distance_transform_edt(img, return_distances=False, return_indices=True)
print(indices.shape) # now: (1, 2, 3, 3)
```
### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [x] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [x] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.
---------
Signed-off-by: alexanderjaus <[email protected]>
Co-authored-by: Eric Kerfoot <[email protected]>
1 parent 4014c84 commit 01711cf
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2498 | 2498 | | |
2499 | 2499 | | |
2500 | 2500 | | |
2501 | | - | |
| 2501 | + | |
2502 | 2502 | | |
2503 | 2503 | | |
2504 | 2504 | | |
| |||
2532 | 2532 | | |
2533 | 2533 | | |
2534 | 2534 | | |
2535 | | - | |
| 2535 | + | |
2536 | 2536 | | |
2537 | 2537 | | |
2538 | 2538 | | |
| |||
0 commit comments