GithubHelp home page GithubHelp logo

Comments (3)

eigenvivek avatar eigenvivek commented on June 3, 2024 1

Hi @charlesalec, thanks for bringing this to my attention. This is due to an issue with diffdrr.pose.RigidTransform.convert.

diffdrr.drr.DRR and diffdrr.registration.Registration assume that, given a rotation R and a translation t, the camera pose is pose = t.compose(R). Written as a matrix, this looks like [R | Rt]. If you look at a CV textbook like Hartley and Zisserman, they explain that this represents a camera center Rt and a camera orientation R.

In contrast, diffdrr.pose.RigidTransform.convert assumes that the camera pose is pose = [R | t]. Therefore, when it converts a pose into its underlying parameters, it turns your R into Euler angles and returns your t without modification.

[R | t] is the old convention in DiffDRR and I am pretty sure I will make [R | Rt] the new convention going forward (since it directly models how C-arms behave). Thanks for catching this piece of legacy code - will add it to the list of fixes for v0.4.0.

For now, here's a hack that should get you what you need:

# pose : diffdrr.pose.RigidTransform that we want to convert into `R` and `t`
rot, rotxyz = pose.convert("euler_angles", "ZXY")
R = convert(rot, torch.zeros_like(rot), parameterization="euler_angles", convention="ZXY")
xyz = R.inverse()(rotxyz.unsqueeze(0))[0]

reg = Registration(
    drr,
    rot,
    xyz,
    parameterization="euler_angles",
    convention="ZXY", 
)

from diffdrr.

charlesalec avatar charlesalec commented on June 3, 2024

Aha yes, I see it now. You're right, that did indeed fix it. Thanks for the explanation, that wasn't obvious to me at all that they behaved differently.

Much appreciated!

from diffdrr.

eigenvivek avatar eigenvivek commented on June 3, 2024

No problem! I'll keep this open until a fix is merged.

from diffdrr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.