zarquon42b / Rvcg

R-package providing mesh manipulation routines from VCGLIB
Other
25 stars 10 forks source link

Wish: 95% Hausdorff distance in vcgMetro() #37

Open dwoll opened 2 years ago

dwoll commented 2 years ago

Again, thanks for developing Rvcg! While vcgMetro() provides relevant distance-based similarity metrics, I think that the 95% Hausdorff distance is currently not returned. As this metric is increasingly used, would it be possible to return it as well in the ForwardSampling and BackwardSampling components of vcgMetro()?

Thanks in advance for considering!

zarquon42b commented 1 year ago

Hi, I am not sure what seems to be the issue. You can obtain the max/mean/RMS Haussdorfdistance both ways like (just switch ForwardSampling to BackwardSampling to get the reverse values):

samp$ForwardSampling$maxdist
samp$ForwardSampling$meandist
samp$ForwardSampling$RMSdist
dwoll commented 1 year ago

Right, these are the classical HD metrics. Some people argue that the 95% HD is also relevant. It is basically the HD for the best-matching part of the structures ("Partial HD" called by Huttenlocher 1993: https://people.eecs.berkeley.edu/~malik/cs294/Huttenlocher93.pdf), ignoring 5% of the vertices with the longest distance. My C++ is weak, but calculating it in Rvcg should be doable. If the SamplingFlags::HIST is set, alls dists are stored:

https://github.com/zarquon42b/Rvcg/blob/b0d5bb6ad269bbc49a84777bc74588d716cfebcd/src/vcglib/apps/metro/sampling.h#L254

The 95% HD would be the 0.95 quantile of the stored dists, and could be returned by a public interface like mean_dist. Many thanks in advance!

zarquon42b commented 1 year ago

Hi, the dists are included and you can compute the 95%-Quantile as quantile(samp$distances1,probs=.95)

zarquon42b commented 1 year ago

This only applies for cases without sampling. When doing edge/face sampling, the function does not store the dists but only tracks cumulatively. E.g. for computing mean_dist, all values are summed up and it divided by the number of samples afterwards (same for RMS). See here: https://github.com/zarquon42b/Rvcg/blob/24682559bf0ee192def5fab08d2420922354643c/src/metroSampling.h#L251-L255