Skip to content

Potential Error in Chamfer Distance Calculation #89

Open
@samuelss1996

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions