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

Potential Error in Chamfer Distance Calculation #89

Open
samuelss1996 opened this issue Jun 5, 2024 · 0 comments
Open

Potential Error in Chamfer Distance Calculation #89

samuelss1996 opened this issue Jun 5, 2024 · 0 comments

Comments

@samuelss1996
Copy link

Description

I noticed a potential issue in the calculation of the Chamfer Distance within the codebase. Specifically, the current implementation sums the mean distances rather than taking the average.

Current Implementation

In the current implementation, the Chamfer Distance is calculated as follows:

cham_dist = np.mean(dists_x_to_y) + np.mean(dists_y_to_x)

Issue

The Chamfer Distance is typically defined as the average of the mean distances, not the sum. This is in fact, what is written in the project's documentation:

$$ \text{chamfer}(P_1, P_2) = \frac{1}{2n} \sum_{x \in P_1} |x - \text{NN}(x, P_2)| + \frac{1}{2m} \sum_{x \in P_2} |x - \text{NN}(x, P_1)| $$

Source: https://github.com/fwilliams/point-cloud-utils/blob/master/docs/docs/sections/shape_metrics.md#chamfer-distance

The current method calculates the sum of the mean distances, thus performing the following computation instead:

$$ \text{chamfer}(P_1, P_2) = \frac{1}{n} \sum_{x \in P_1} |x - \text{NN}(x, P_2)| + \frac{1}{m} \sum_{x \in P_2} |x - \text{NN}(x, P_1)| $$

(notice the change in the denominators with respect to the original equation)

Proposed Fix

The correct calculation should take the average of these distances:

cham_dist = (np.mean(dists_x_to_y) + np.mean(dists_y_to_x)) / 2
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

1 participant