animate(
inpath: str | Path,
outpath: str | Path,
skip: int = 1,
dpi: int = 192,
fps: int = 30,
)
Animate the trajectory of iterative optimization.
Source code in src/xvr/visualization/animate.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 | def animate(
inpath: str | Path, # Saved registration result from <xvr register>
outpath: str | Path, # Savepath for iterative optimization animation
skip: int = 1, # Animate every <skip> frames of the optimization
dpi: int = 192, # DPI of each frame of the animation
fps: int = 30, # FPS of the animation
):
"""Animate the trajectory of iterative optimization."""
# Initialize the renderer
run = torch.load(inpath, weights_only=False)
drr = initialize_drr(**run["drr"])
gt, *_ = read_xray(**run["xray"])
scales = _parse_scales(
run["optimization"]["scales"], run["xray"]["crop"], run["drr"]["height"]
)
# Render all DRRs
drrs = render(drr, gt, scales, run, skip)
# Generate the animation
frames = plot(drrs, dpi)
imwrite(outpath, frames, fps=fps)
|