Skip to content
Open
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
10 changes: 10 additions & 0 deletions exporters/spline_segmentation_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,16 @@ def draw_segmentation(image_size, control_points, label: int = 1, canvas: np.nda

@staticmethod
def compute_scaling(image_size, spacing):
if len(spacing) > len(image_size):
warnings.warn(f'Image is {len(image_size)}D and spacing is {len(spacing)}D.'
f'Dropping the extra axes in the spacing vector.')
for n in range(len(spacing) - len(image_size)):
spacing.pop(-1)
elif len(spacing) < len(image_size):
raise ValueError(f'Something wrong with the data:'
f'image is {len(image_size)}D and spacing is {len(spacing)}D.')

assert len(image_size) == len(spacing), 'Image size and spacing are expected to have the same dimensions.'
if len(spacing) == 2:
aspect_ratio = image_size[0] / image_size[1]
new_aspect_ratio = image_size[0] * spacing[0] / (image_size[1] * spacing[1])
Expand Down