Skip to content

Commit 2b160b3

Browse files
authored
Add ValueError in GenerateSuccinctContour (#5719)
Signed-off-by: KumoLiu <yunl@nvidia.com> Fixes #5714. ### Description Add ValueError when an invalid contour is generated. ### 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. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] 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: KumoLiu <yunl@nvidia.com>
1 parent 75e02ba commit 2b160b3

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • monai/apps/pathology/transforms/post

monai/apps/pathology/transforms/post/array.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,10 @@ def __call__(self, contours: List[np.ndarray]) -> np.ndarray:
458458
elif coord[1] == self.width - 1:
459459
corner = 2
460460
pixel = (int(coord[0] - 0.5), int(coord[1]))
461+
else:
462+
raise ValueError(
463+
f"Invalid coutour coord {coord} is generated, areas may contain boundaries or small holes"
464+
)
461465
sequence.append(pixel)
462466
last_added = pixel
463467
elif i == len(group) - 1:

0 commit comments

Comments
 (0)