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

Centering and scaling ruins the results? #9

Open
DavidBoja opened this issue Apr 6, 2023 · 2 comments
Open

Centering and scaling ruins the results? #9

DavidBoja opened this issue Apr 6, 2023 · 2 comments

Comments

@DavidBoja
Copy link

Hi,
first of all, thank you for the python implementation.

I tried registering the bunnies you provided with the test.py function and the results were good.
However, when centering and scaling the model and data bunnies (as suggested by the instructions) the results are completely wrong. This is the code i use for centering and scaling, after which i run the test.py again with the new bunnies.

Nm, a_points, np_a_points = loadPointCloud('../data/model_bunny.txt');
Nd, b_points, np_b_points = loadPointCloud('../data/data_bunny.txt');

# center pcs
np_a_points_cent = np_a_points - np.mean(np_a_points,axis=0)
np_b_points_cent = np_b_points - np.mean(np_b_points,axis=0)

# scale to unit sphere
np_a_points_cent_sc, np_b_points_cent_sc, scale = scale_to_unit_sphere(np_a_points_cent,
                                                                       np_b_points_cent)

# save to 
np.savetxt("../data/model_bunny_centered_scaled.txt",np_a_points_cent_sc)
np.savetxt("../data/data_bunny_centered_scaled.txt",np_b_points_cent_sc)

where I add the number of points as the first line in the .txt files and the scaling function I use is:

def scale_to_unit_sphere(pci,pcj):

    max_pci_point_norm = np.max(np.sqrt(np.sum((pci ** 2),axis=1)))
    max_pcj_point_norm = np.max(np.sqrt(np.sum((pcj ** 2),axis=1)))

    largest_norm = max(max_pci_point_norm,max_pcj_point_norm)

    pci_scaled = pci / largest_norm
    pcj_scaled = pcj / largest_norm

    return pci_scaled, pcj_scaled, largest_norm

Thank you in advance for any tips.

@aalavandhaann
Copy link
Owner

Hello @DavidBoja,

I never had this issue when centering and scaling. My initial guess is in your code at lines

# center pcs
np_a_points_cent = np_a_points - np.mean(np_a_points,axis=0)
np_b_points_cent = np_b_points - np.mean(np_b_points,axis=0)

Should they not be along axis 1? You want the mean along x, y, z. Are you loading it as a N x 3 or 3 x N?

Regards,
#0K

@DavidBoja
Copy link
Author

Hi, thanks for the response!

I am using your function loadPointCloud from the test.py script. It loads a Nx3 numpy array.
Therefore np.mean(np_a_points,axis=0) is of dimension (3,) which is correct.

I am still not sure why are the results bad when centering and scaling.
Could you possibly run GO-ICP for yourself with the model_bunny_centered_scaled.txt and data_bunny_centered_scaled .txt as I processed them 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