orlitany / DeepFunctionalMaps

91 stars 23 forks source link

How to get egenvectors #5

Closed hellohawaii closed 3 years ago

hellohawaii commented 5 years ago

Hi! I am trying to reproduce your work and need your help!

I want to use my own dataset, so I am trying to write codes to compute eigenvectors, distance map and so on. In order to ensure that there is no bug in my code, I compared the results of my own preprocess codes with those you provided, but I got very different results!

I downloaded the data you provided in issue#3(https://drive.google.com/drive/folders/1Sm76v3znqQvWw3OUIa-kvzbqnMk1a7fF?usp=sharing), and the data you provided in readme(https://drive.google.com/drive/folders/1nHUGaKcn2INwXln6Ig354y6o9WI-_Kzj?usp=sharing). I preprocessed the tr_reg_080.off using my own code. I managed to compute the distance map and SHOT decriptor. However,when trying to compute the eigenvectors, I got totally different results. So I checked the eigenvalues(In the dataset mentioned in issue#3, I found a file named eigvals_500_shape.mat, I think the column 81 is the eigenvals of tr_reg_080.off) and found that we got different eigenvalues.

I used the codes by Huang Hui to compute the eigenvalues( https://github.com/wanghuiSTDU/Group-Representation-of-Global-Intrinsic-Symmetry/blob/master/demo_C2Shape.m from line17 to line 21 ). I also used the codes by myself. These two vesions got the same results while both were different from your data.

I am really struggling to preprocess these data. May I ask you to upload the codes of computing the eigenvectors and transposed eigenvectors? It will help me a lot to reproduce your work!

hellohawaii commented 5 years ago

I think perhaps the key point how to compute the Laplace matrixes. I got the same matrixes using my codes as those produced by Huang Hui's codes.

hellohawaii commented 5 years ago

I managed to calculate the the eigenvalues using the Laplacian matrixes provided in your paper. However, the eigenvectors are different even after applying normalization. Could you please provide the Laplacian matrixes of part of the data for reference?

dvirginz commented 5 years ago

@hellohawaii Hi! Can you please provide your SHOT descriptor and distance map code? That would be super helpful. Thanks:)

meihanchen666 commented 3 years ago

@hellohawaii Hi! Can you please provide your SHOT descriptor and distance map code? That would be super helpful. Thanks you very much!

hellohawaii commented 3 years ago

@hellohawaii Hi! Can you please provide your SHOT descriptor and distance map code? That would be super helpful. Thanks you very much!

It is a long time ago and I can not remember the certain file clearly. I examined the codes before, it seems that SHOT is computed by the codes provided by this repo DeepFunctionalMaps/Utils/. The distance map is computed by https://github.com/wanghuiSTDU/Group-Representation-of-Global-Intrinsic-Symmetry/blob/28202db1e585f266fa08775994982256959b3633/Toolbox/geodesic%20distance/geodesicDistance_fastmarch_multiple.m

The following is how I used these code:

function preprocess_one_64(obj_filename, mat_filename)
%%preprocess obj_filename and store the data to the mat_filename, run on
%%64 bit matlab. Comput eivectors, SHOT, 

% addpath('D:\工作文件\对称性\PreprocessOfDeepFeatureMap\')
% input_coff = 'D:\工作文件\对称性\PreprocessOfDeepFeatureMap\tr_reg_081.off';
% output_mat = 'D:\工作文件\对称性\PreprocessOfDeepFeatureMap\my_tr_reg_081.mat';
% output_obj =  'D:\工作文件\对称性\PreprocessOfDeepFeatureMap\tr_reg_081.obj';

%read .obj
obj = readObj(obj_filename);
V = obj.v;
F = obj.f.v;  %indices start from 1
V = V*100;  %scaled by 100, both des_map and shot need to do so, TODO:how about egenvalues?
fprintf('Finish loading triangular mesh with %d vertices and %d triangles.\n', size(V,1), size(F,1));

num_eigen_vectors = 50;
num_wks = 20;
num_hks = 20;

%read .coff
%[V, F] = read_coff(input_coff);

%Compute eigenvalues and eigenvectors of the Laplace-Beltrami operator
fprintf('Start computing igen-decomposition of the Laplace-Beltrami operator.\n');
[L, mass_matrix] = laplacian_matrix_cotan(V, F);
[eigvector, eigvalue] = eigs(L, num_eigen_vectors, 'sm');
eigvalue = diag(eigvalue);
[eigvalue, index] = sort(eigvalue);
eigvector = eigvector(:, index);

%another way to compute the eigenvectors
%convert .off to .obj
%obj_write(output_obj, V, F);
%[eigvectors1, eigen_vectors_before, eigvalues1, laplacepoint] = get_eigen_from_obj(output_obj, 500);
transposed_evecs = eigvector' * mass_matrix;

%compute distance_map
%fprintf('Start computing distance map...\n');
%every_point = 1:size(V,1);  %the indice should start from 1
%D = geodesicDistance_fastmarch_multiple(V,F,every_point);

%compute SHOT_descriptor
fprintf('computing SHOT descriptors...\n');
%shotdescr = calc_shot(V, F, every_point, 10, 9, 3); 
%TODO:Does the indice start from 0?
%TODO:Our F/everypoint start from indices 1
%the shot descriptor provided by the author uses 1-based indices
every_point = 1:size(V,1);  %the indice should start from 1
shotdescr = calc_shot(V', F', every_point, 10, 9, 3); 
shotdescr = shotdescr';  %by compared to the ground truth, I should take a transpose to get the same result as DeepFuncionalMap, but I do not know why

%compute HKS and WKS, referring to Huanghui's codes
[hks] = HKS(eigvector, eigvalue);
wks = compute_WKS(eigvector, eigvalue, num_wks);

%save the output
fprintf('saving....\n');
save(mat_filename, 'shotdescr', 'eigvector','transposed_evecs','mass_matrix','-append'); %use 64bit to get the shot
%save(mat_filename, 'D', 'eigvector');  %use 32bit to get distance map
end

and another version...

function preprocess_one_32(obj_filename, mat_filename)
%%preprocess obj_filename and store the data to the mat_filename

% addpath('D:\工作文件\对称性\PreprocessOfDeepFeatureMap\')
% input_coff = 'D:\工作文件\对称性\PreprocessOfDeepFeatureMap\tr_reg_081.off';
% output_mat = 'D:\工作文件\对称性\PreprocessOfDeepFeatureMap\my_tr_reg_081.mat';
% output_obj =  'D:\工作文件\对称性\PreprocessOfDeepFeatureMap\tr_reg_081.obj';

%read .obj
obj = readObj(obj_filename);
V = obj.v;
F = obj.f.v;  %indices start from 1
V = V*100;  %scaled by 100, both des_map and shot need to do so, TODO:how about egenvalues?
fprintf('Finish loading triangular mesh with %d vertices and %d triangles.\n', size(V,1), size(F,1));

%read .coff
%[V, F] = read_coff(input_coff);

%compute distance_map
fprintf('Start computing distance map...\n');
every_point = 1:size(V,1);  %the indice should start from 1
D = geodesicDistance_fastmarch_multiple(V,F,every_point);

%save the output
fprintf('saving....\n');
%save(mat_filename, 'shotdescr', 'eigvector'); %use 64bit to get the shot
save(mat_filename, 'D','-append');  %use 32bit to get distance map
end

It seems that I write two version of codes to run on 32bit Matlab and 64bit Matlab seprately. Note that I am quite not sure. However, I hope this can help you.