Skip to content
Snippets Groups Projects
Commit 12421b53 authored by Daniel Schramm's avatar Daniel Schramm
Browse files

Computation of feature point weights corrected (weighted average used)

parent 0d5d262c
No related branches found
No related tags found
No related merge requests found
......@@ -29,8 +29,8 @@ import javax.vecmath.Point3d;
* points separately</li>
* <li>Priorities of the faces' vertices with respect to all the given types
* of feature points merged together</li>
* <li>Average weighted Hausdorff distance with respect to the given types of feature
* points for each of the faces' mesh facets</li>
* <li>Weighted average of Hausdorff distance of all vertices within the priority sphere
* of feature points of the given types for each of the faces' mesh facets</li>
* </ul>
* This visitor is instantiated with a single k-d tree (either given as the input
* parameter, or automatically created from the triangular mesh).
......@@ -238,24 +238,24 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor {
}
/**
* For all visited faces' mesh facets, the method returns the average weighted Hausdorff distance
* with respect to the given types of feature points (i.e. the sum of weighted distances
* of the mesh facet's vertices to the source facets divided by the number of vertices
* located within the feature point's priority sphere).
* The average weighted distances are calculated for each type of feature point separately.
* For all visited faces' mesh facets, the method returns the weighted average of Hausdorff distance
* of all vertices within the priority sphere of feature points of the given types
* (i.e. the sum of weighted distances of the mesh facet's vertices to the source facets
* divided by the sum of their priorities).
* The weighted average is calculated for each type of feature point separately.
*
* Keys in the map contain human faces whose mesh facets were measured with the
* source facets.
* For each human face, there is a map of examined types of feature points.
* Each feature point type then stores a map of the face's mesh facets together with
* the average weighted distances of their vertices to the source facets.
* The average weighted distances are calculated with respect to the face's feature point
* the weighted average of distance of their vertices to the source facets.
* The weighted average of distance is calculated with respect to the face's feature point
* of the corresponding type.
* <i>If there is no vertex within the priority sphere of a feature point,
* the value of the average weighted Hausdorff distance is {@link Double#NaN}</i>
*
* @return Average weighted Hausdorff distances with respect to the given types
* of feature points
* @return Weighted average of Hausdorff distance of all vertices within the priority sphere
* of feature points of the given types
*/
public Map<HumanFace, Map<FeaturePointType, Map<MeshFacet, Double>>> getFeaturePointWeights() {
return Collections.unmodifiableMap(featurePointWeights);
......@@ -370,19 +370,24 @@ public class HausdorffDistancePrioritized extends HumanFaceVisitor {
synchronized (this) {
/*
* Calculate the average weighted Hausdorff distance for the feature point.
* Calculate the weighted average of Hausdorff distance
* of all vertices within the feature point's priority sphere.
*/
final List<Double> facetDistances = hausdorffDistances.get(facet);
featurePointWeights.computeIfAbsent(humanFace, face -> new HashMap<>())
.computeIfAbsent(featurePointType, fPointType -> new HashMap<>())
.put(facet, IntStream.range(0, facetDistances.size())
.filter(i -> facetPriorities.get(i) > 0) // Filter out vertices that are outside of the priority sphere
.mapToDouble(i -> facetDistances.get(i) * facetPriorities.get(i))
.average()
.orElse(Double.NaN)); // If there is no vertex in the priority sphere
.boxed()
.collect(WeightedAverageCollector.toWeightedAverage(
facetDistances::get,
facetPriorities::get
))
);
/*
* Merge priorities computed for the current feature point type with the priorities of already computed feature point types.
* Merge priorities computed for the current feature point type
* with the priorities of already computed feature point types.
*/
final List<Double> storedFacetPriorities = mergedPriorities
.computeIfAbsent(humanFace, face -> new HashMap<>())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment