source
JacobianDRR
JacobianDRR (drr, rotation, translation, parameterization,
convention=None)
Computes the Jacobian of a DRR wrt pose parameters.
source
gradient_matching
gradient_matching (J0, J1)
source
plot_img_jacobian
plot_img_jacobian (I, J, **kwargs)
from diffdrr.drr import DRR
from diffdrr.utils import convert
from diffpose.deepfluoro import DeepFluoroDataset
device = torch.device("cuda")
specimen = DeepFluoroDataset(id_number=1)
height = 256
subsample = (1536 - 100) / height
delx = 0.194 * subsample
drr = DRR(
specimen.volume,
specimen.spacing,
sdr=specimen.focal_len / 2,
height=height,
delx=delx,
x0=specimen.x0,
y0=specimen.y0,
reverse_x_axis=True,
).to(device)
_, pose = specimen[52]
R = convert(pose.get_rotation(), "matrix", "euler_angles", output_convention="ZYX")
R = R.to(device)
t = pose.get_translation().to(device)
jacdrr = JacobianDRR(drr, R, t, "euler_angles", "ZYX")
I0, J0 = jacdrr()
kwargs = dict(cmap="turbo", norm="symlog")
plot_img_jacobian(I0, J0, **kwargs)