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

How to convert an obj file to .m file the algorithm needed? #1

Open
MurielCuiCui opened this issue Feb 24, 2021 · 8 comments
Open

How to convert an obj file to .m file the algorithm needed? #1

MurielCuiCui opened this issue Feb 24, 2021 · 8 comments

Comments

@MurielCuiCui
Copy link

Thanks for your sharing ! I have a .nrrd medical file of hippocampus segmentation and I want to use your code to map the hippocampus to sphere, then I convert .nrrd file to obj file using slicer. I want to convert the .obj file to .m file the algorithm needed.The .m file is consisted of three variable: vertex ,face and mean_curv. What is mean_curv ? And could it converted from .obj file?
Or is there any easy way to create a mat for hippocampus surface which is a .nrrd file or .obj file as input ? I really appreciate if you could reply to me

@garyptchoi
Copy link
Owner

Hi, you may read the vertices and faces from the .obj file using some of the following functions:
https://www.mathworks.com/matlabcentral/fileexchange/18957-readobj
https://www.mathworks.com/matlabcentral/fileexchange/20307-display_obj
https://www.mathworks.com/matlabcentral/fileexchange/27982-wavefront-obj-toolbox

The spherical mapping code (spherical_conformal_map.m) only requires the vertex (nv x 3 matrix) and face (nf x 3 matrix) as the input.

The variable mean_curv is not required for computing the mapping. It is just an optional vertex-based quantity (which can either be the mean curvature, Gaussian curvature, or any other quantity you want to visualize) for the mesh plotting code plot_mesh.m.
You may use some of the following functions to compute the mean curvature and the Gaussian curvature:
https://www.mathworks.com/matlabcentral/fileexchange/32573-patch-curvature
https://www.mathworks.com/matlabcentral/fileexchange/61136-gaussian-and-mean-curvatures-calculation-on-a-triangulated-3d-surface

@MurielCuiCui
Copy link
Author

Thanks so much !!!

@MurielCuiCui
Copy link
Author

I find out the result spherical map is much smaller than the input, how to change the size of sphere as large as the input ?
Picture below is a hippocampus and the spherical map
图像2021-2-24 下午8 00

@garyptchoi
Copy link
Owner

Hi, The spherical map always results in a sphere centered at the origin and with radius 1. You can rescale it based on the surface area of the input surface as follows:
map = spherical_conformal_map(v,f);
fa1 = face_area(f,v);
fa2 = face_area(f,map);
map_rescaled = map*sqrt(sum(fa1)/sum(fa2));

@MurielCuiCui
Copy link
Author

You help me a lot,thanks! I try to use the result generated from your code, as input of optimal transport program which is from Spherical Optimal Transportation Map,and it output the Legendre dual mesh and the optimal transportation map mesh which is .m file, show below;Honestly, I don’t know how to understand this output , what software can be used to load this kind of file. What do c and u stand for and Is normal the vertex normal? Have you dealt with the similarity problem?
I really appreciate your help!!!

image

@garyptchoi
Copy link
Owner

I am not very familiar with that program and the data format. It seems to me that "normal" is the vertex normal, and "u" may be the spherical parameterization result. I suggest that you contact the authors for more details.

@MurielCuiCui
Copy link
Author

It's very nice of you !Thanks for your suggestion , I try to contact the authors .

@lcdoan
Copy link

lcdoan commented Mar 9, 2021

Thanks for your code.
The code is very fast and useful for me.

Assume that I have two surfaces with their landmarks.
Could you please tell me how can I use the code to map between two genus zero surfaces with landmarks constraint ?

Thank you in advance.

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

3 participants