2026-05-03-22-02-15 调整预览分界线绘制

This commit is contained in:
2026-05-03 22:09:19 +08:00
parent e431830d15
commit 525c2c1dda
6 changed files with 299 additions and 18 deletions

View File

@@ -28,6 +28,7 @@ from head_extension_app import (
draw_cutoff_line,
fit_image,
load_dicom_volume,
preview_deform_with_cutoff_line,
preview_deform_2d,
run_deformation,
sagittal_mip,
@@ -650,13 +651,24 @@ def make_preview(
volume = load_dicom_volume(input_dir)
before = crop_head_neck(sagittal_mip(volume))
before_display = draw_cutoff_line(before, volume.shape[0]) if show_cutoff_line else before
after = preview_deform_2d(
before_display,
float(angle_degrees),
mode,
transition_width=float(transition_width),
gaussian_sigma=float(gaussian_sigma),
)
if mode in {"hard_boundary", "gaussian_smooth"}:
after = preview_deform_with_cutoff_line(
before,
volume.shape[0],
float(angle_degrees),
mode,
transition_width=float(transition_width),
gaussian_sigma=float(gaussian_sigma),
show_cutoff_line=show_cutoff_line,
)
else:
after = preview_deform_2d(
before_display,
float(angle_degrees),
mode,
transition_width=float(transition_width),
gaussian_sigma=float(gaussian_sigma),
)
canvas_image = Image.new("RGB", (1440, 520), (0, 0, 0))
canvas_image.paste(fit_image(before_display, 700, 520), (0, 0))
@@ -666,15 +678,23 @@ def make_preview(
("Original", before_display),
(
"Hard boundary",
preview_deform_2d(before_display, float(angle_degrees), "hard_boundary"),
preview_deform_with_cutoff_line(
before,
volume.shape[0],
float(angle_degrees),
"hard_boundary",
show_cutoff_line=show_cutoff_line,
),
),
(
"Gaussian smooth",
preview_deform_2d(
before_display,
preview_deform_with_cutoff_line(
before,
volume.shape[0],
float(angle_degrees),
"gaussian_smooth",
gaussian_sigma=float(gaussian_sigma),
show_cutoff_line=show_cutoff_line,
),
),
(