Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transformation matrix (affine_matrix_from_points) #57

Open
Cestovatels opened this issue May 31, 2023 · 3 comments
Open

Transformation matrix (affine_matrix_from_points) #57

Cestovatels opened this issue May 31, 2023 · 3 comments

Comments

@Cestovatels
Copy link

Cestovatels commented May 31, 2023

Hello. I have been working on STL and DICOM images for a while. I select points on STL and DICOM with the 3Dslicer program. Then I create a set of v0 and v1 points for myself. Thanks to these points, I am trying to move the STL on DICOM using the function you wrote. I apply the affine_matrix_from_points function to the STL I have, but it does not create an STL where I want. Am I doing something wrong or do I need to change the method?

import numpy as np
from transforms3d import _gohlketransforms
from stl import mesh

v0 = [[-8.7,-13.8,-17.8,-18.5,-18.7,-16.3,-12.6,-7.4],
         [6.2,4.5,2.9,2.4,2.4,3.1,3.5,5.3],
         [17.4,11.9,6.8,1.1,-4.0,-8.8,-14.7,-19.6]]
      
v1 = [[-88.9,-93.7,-99.0,-104.6,-109.8,-115.9,-121.3,-126.4],
          [-46.2,-40.8,-37.3,-35.5,-35.4,-38.4,-40.8,-45.6],
          [64.3,62.8,62.5,62.5,62.4,63.0,63.7,65.0]]

stl_data = mesh.Mesh.from_file('test.stl')      
R = _gohlketransforms.affine_matrix_from_points(v0, v1,shear=False, scale=False, usesvd=True)
stl_data.transform(R)
stl_data.save('affine_matrix_from_points.stl')
@matthew-brett
Copy link
Owner

I'm really sorry to say - that I don't know that function at all - it's from the code that became : https://github.com/cgohlke/transformations/blob/master/transformations/transformations.py#L936 - try there for support?

@Cestovatels
Copy link
Author

Cestovatels commented May 31, 2023

image
I have examined this part of the code in detail, but there may be something I missed. In this image, the bottom left part is STL and the skull is DICOM. If I align the two, everything will be solved. Thanks for your help.

@matthew-brett
Copy link
Owner

Sorry - just to clarify - I can't help - as I don't know the code. Try the repository I linked to above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants