algorithm.psgm
Class CostGetter

java.lang.Object
  extended by algorithm.psgm.CostGetter

public class CostGetter
extends java.lang.Object

Given two skeletons, get the costs to match two specified end nodes by first creating a path distance matrix and then applying OSBv5 to this matrix.


Field Summary
private  Config config
          holding configuration parameters
private  org.apache.log4j.Logger logger
          logger instance
(package private)  double normalizationFactor
          factor to multiply all path lengths with to make the algorithm invariant to scale.
private  SkeletonObject so1
          first skeleton object to be matched
private  SkeletonObject so2
          second skeleton object to be matched
 
Constructor Summary
CostGetter(SkeletonObject so1, SkeletonObject so2, Config config)
          Constructor.
 
Method Summary
 double getCost(SkeletonNode sn1, SkeletonNode sn2)
          Get the matching costs for the two specified end nodes.
private  double getMaximalPathLength(SkeletonObject so)
          get the length of the longest path in the specified skeleton object.
private  void getNormalizationFactor()
          Get the normalization factor.
 double getPathDistanceByPath(SkeletonPath p1, SkeletonPath p2)
          Get the path distance between the two specified skeleton paths.
 double getPathDistanceByPathLength(SkeletonPath p1, SkeletonPath p2)
          Get the path distance between a pair of skeleton paths, based on their path length.
 double[][] getPathDistanceMatrix(SkeletonNode sn1, SkeletonNode sn2)
          Get the path distance matrix for a pair of end nodes to be matched.
private  java.util.List<SkeletonPath> wrapList(java.util.List<SkeletonPath> toBeWrapped, int index)
          Rotate a list of skeleton paths by the given distance by using Collections.rotate(List, int).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private final org.apache.log4j.Logger logger
logger instance


so1

private final SkeletonObject so1
first skeleton object to be matched


so2

private final SkeletonObject so2
second skeleton object to be matched


config

private final Config config
holding configuration parameters


normalizationFactor

double normalizationFactor
factor to multiply all path lengths with to make the algorithm invariant to scale. Path lengths are between 0 and 1 afterwards

Constructor Detail

CostGetter

public CostGetter(SkeletonObject so1,
                  SkeletonObject so2,
                  Config config)
Constructor. Create a new CostGetter instance with the specified skeleton objects and weight factor for path length.

Parameters:
so1 - - the first skeleton object to be matched. Make sure this is the one with lesser end nodes.
so2 - - the second skeleton object to be matched. Make sure this the one with more end nodes.
config - - holding all configuration parameters
Method Detail

getCost

public double getCost(SkeletonNode sn1,
                      SkeletonNode sn2)
               throws InvalidSkeletonException,
                      InvalidWeightFunctionGivenException
Get the matching costs for the two specified end nodes.

Parameters:
sn1 - - a skeleton node from so1 to be matched
sn2 - - a skeleton node from so2 to be matched
Returns:
the costs to match the two specified skeleton nodes.
Throws:
InvalidSkeletonException - if one of the skeletons seems broken
InvalidWeightFunctionGivenException - if no valid weight function could be constructed from the path distances

getPathDistanceMatrix

public double[][] getPathDistanceMatrix(SkeletonNode sn1,
                                        SkeletonNode sn2)
                                 throws InvalidSkeletonException
Get the path distance matrix for a pair of end nodes to be matched.

Parameters:
sn1 - the end node from the first skeleton
sn2 - the end node from the second skeleton
Returns:
the path distance matrix for the skeleton end nodes
Throws:
InvalidSkeletonException - if the skeleton seems to be broken

getPathDistanceByPathLength

public double getPathDistanceByPathLength(SkeletonPath p1,
                                          SkeletonPath p2)
Get the path distance between a pair of skeleton paths, based on their path length. The path length is normalized and then compared to each other.

Parameters:
p1 - the first skeleton path
p2 - the second skeleton path
Returns:
a similarity value for the two skeleton paths, based on their path length. The smaller the number, the more similar are the two paths.

getPathDistanceByPath

public double getPathDistanceByPath(SkeletonPath p1,
                                    SkeletonPath p2)
Get the path distance between the two specified skeleton paths. The path distance is based on the skeleton paths' vectors. See SkeletonPath.getVectorRepresentation() for more information.

Parameters:
p1 - - a skeleton path from skeleton so1
p2 - - a skeleton path from skeleton so2
Returns:
the distance between the two paths

getNormalizationFactor

private void getNormalizationFactor()
Get the normalization factor. All skeleton path lengths will be multiplied by this factor to achieve values between 0 and 1. This way, the approach gets invariant to scale.


wrapList

private java.util.List<SkeletonPath> wrapList(java.util.List<SkeletonPath> toBeWrapped,
                                              int index)
Rotate a list of skeleton paths by the given distance by using Collections.rotate(List, int). The original list is copied before, so the original list is not changed by this function.

Parameters:
toBeWrapped - - the list of skeleton paths to be rotated.
index - - the value by that the list will be rotated.
Returns:
the rotated list, where the element that previously was at index (i) will be at index (i+index), including wrap-arounds.

getMaximalPathLength

private double getMaximalPathLength(SkeletonObject so)
get the length of the longest path in the specified skeleton object.

Parameters:
so - the skeleton object where the longest path is searched
Returns:
length of the shortest skeleton path in so