Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tiatoolbox/utils/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ def process_contours(

"""
annotations_list: list[Annotation] = []
outer_contours: list[np.ndarray] = []
outer_contours: dict[int, np.ndarray] = {}
holes_dict: dict[int, list[np.ndarray]] = {}

for i, layer_ in enumerate(contours):
Expand All @@ -1235,7 +1235,7 @@ def process_contours(
# save one points as a line, otherwise save the Polygon
if len(layer_) > 2: # noqa: PLR2004
if int(hierarchy[0][i][3]) == -1: # Outer contour
outer_contours.append(scaled_coords[0])
outer_contours[i] = scaled_coords[0]
else: # Hole
parent_idx: int = int(hierarchy[0][i][3])
if parent_idx not in holes_dict:
Expand Down Expand Up @@ -1274,7 +1274,7 @@ def process_contours(
]
)

for idx, outer in enumerate(outer_contours):
for idx, outer in outer_contours.items():
holes: list[np.ndarray] = holes_dict.get(idx, [])
if len(holes) != 0:
feature_geom = feature2geometry(
Expand Down