garyptchoi / spherical-conformal-map

Spherical conformal map for genus-0 closed surfaces
Apache License 2.0
37 stars 6 forks source link

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

Open MurielCuiCui opened 3 years ago

MurielCuiCui commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Thanks so much !!!

MurielCuiCui commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

lcdoan commented 3 years ago

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.