algorithm
Class Matching2D

java.lang.Object
  extended by algorithm.Matching2D

public class Matching2D
extends java.lang.Object

Wrapper class to use PSGM for the matching of 2D data. Takes care of loading the data and reordering the skeletons, if needed.

PSGM is then applied to the two skeletons, where the end nodes of the two skeletons are matched.


Field Summary
private  Config config
          holding configuration parameters
private  org.apache.log4j.Logger logger
          logger instance
private  boolean reordered
          hold the information if the two skeletons were reordered for the algorithm, that is, PathSimilaritySkeletonGraphMatching.so1 originally was the second skeleton, and the other way around.
private  SkeletonObject so1
          the first skeleton object (the one with lesser end nodes
private  SkeletonObject so1_flipped
          the first skeleton object, read from an image flipped horizontally
private  SkeletonObject so2
          the second skeleton object (the one with more end nodes
 
Constructor Summary
Matching2D(SkeletonObject so1, SkeletonObject so1_flipped, SkeletonObject so2, Config config)
          Constructor that should only be used if you know what you are doing.
Matching2D(java.lang.String skeletonfilename1, java.lang.String objectfilename1, java.lang.String skeletonfilename2, java.lang.String objectfilename2)
          Constructor.
Matching2D(java.lang.String skeletonfilename1, java.lang.String objectfilename1, java.lang.String skeletonfilename2, java.lang.String objectfilename2, Config config)
          Constructor.
Matching2D(java.lang.String skeletonfilename1, java.lang.String objectfilename1, java.lang.String skeletonfilename2, java.lang.String objectfilename2, java.lang.String[] args)
          Constructor.
 
Method Summary
 SkeletonObject getSo1_flipped()
          Get the first skeleton (the one with lesser end nodes), but flipped horizontally)
 SkeletonObject getSo1()
          Get the "first skeleton", the one with lesser end nodes.
 SkeletonObject getSo2()
          Get the "second skeleton", the one with more end nodes
 CleanMatchingResult go()
          execute the PSGM algorithm.
 boolean isReordered()
          Test if the two skeletons were reordered in order to execute the algorithm.
private  void loadSkeletons(java.lang.String skeletonfilename1, java.lang.String objectfilename1, java.lang.String skeletonfilename2, java.lang.String objectfilename2)
          load both skeletons, specified by the filename.
 void setSo1_flipped(SkeletonObject so1_flipped)
          Set the first skeleton (the one with lesser end nodes), but flipped horizontally)
 void setSo1(SkeletonObject so1)
          Set the "first skeleton", the one with lesser end nodes.
 void setSo2(SkeletonObject so2)
          Set the "second skeleton", the one with lesser end nodes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

so1

private SkeletonObject so1
the first skeleton object (the one with lesser end nodes


so2

private SkeletonObject so2
the second skeleton object (the one with more end nodes


so1_flipped

private SkeletonObject so1_flipped
the first skeleton object, read from an image flipped horizontally


config

private final Config config
holding configuration parameters


reordered

private boolean reordered
hold the information if the two skeletons were reordered for the algorithm, that is, PathSimilaritySkeletonGraphMatching.so1 originally was the second skeleton, and the other way around.


logger

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

Constructor Detail

Matching2D

public Matching2D(java.lang.String skeletonfilename1,
                  java.lang.String objectfilename1,
                  java.lang.String skeletonfilename2,
                  java.lang.String objectfilename2)
           throws InvalidConfigParameterException,
                  java.io.IOException,
                  InvalidSkeletonException
Constructor. Creating a new Matching2D instance, loading all skeletons automatically according to the specified input files.

Input of the algorithm are at minimum four input files. For each object to be matched, two input images are needed: One binary image showing the skeleton, one binary image showing the shape. Both binary images should have black background and white foreground.

Parameters:
skeletonfilename1 - the path to the first skeleton image
objectfilename1 - the path to the first shape image
skeletonfilename2 - the path to the second skeleton image
objectfilename2 - the path to the second shape image
Throws:
InvalidConfigParameterException - if an error occured, creating the new config instance
java.io.IOException - if one of the input files could not be found
InvalidSkeletonException - if one of the skeletons was broken.

Matching2D

public Matching2D(java.lang.String skeletonfilename1,
                  java.lang.String objectfilename1,
                  java.lang.String skeletonfilename2,
                  java.lang.String objectfilename2,
                  java.lang.String[] args)
           throws InvalidConfigParameterException,
                  java.io.IOException,
                  InvalidSkeletonException
Constructor. Creating a new Matching2D instance, loading all skeletons automatically according to the specified input files.

Input of the algorithm are at minimum four input files. For each object to be matched, two input images are needed: One binary image showing the skeleton, one binary image showing the shape. Both binary images should have black background and white foreground.

When using this constructor, als a string array of config parameters can be passed - see Config for more information.

Parameters:
skeletonfilename1 - the path to the first skeleton image
objectfilename1 - the path to the first shape image
skeletonfilename2 - the path to the second skeleton image
objectfilename2 - the path to the second shape image
args - an array of configuration strings
Throws:
InvalidConfigParameterException - if an error occured, creating the new config instance
java.io.IOException - if one of the input files could not be found
InvalidSkeletonException - if one of the skeletons was broken.

Matching2D

public Matching2D(java.lang.String skeletonfilename1,
                  java.lang.String objectfilename1,
                  java.lang.String skeletonfilename2,
                  java.lang.String objectfilename2,
                  Config config)
           throws java.io.IOException,
                  InvalidSkeletonException,
                  InvalidConfigParameterException
Constructor. Creating a new Matching2D instance, loading all skeletons automatically according to the specified input files.

Input of the algorithm are at minimum four input files. For each object to be matched, two input images are needed: One binary image showing the skeleton, one binary image showing the shape. Both binary images should have black background and white foreground.

If this constructor is used, also a configuration instance can be passed.

Parameters:
skeletonfilename1 - the path to the first skeleton image
objectfilename1 - the path to the first shape image
skeletonfilename2 - the path to the second skeleton image
objectfilename2 - the path to the second shape image
config - holding configration parameters
Throws:
InvalidConfigParameterException - if an error occured with the config instance
java.io.IOException - if one of the input files could not be found
InvalidSkeletonException - if one of the skeletons was broken.

Matching2D

public Matching2D(SkeletonObject so1,
                  SkeletonObject so1_flipped,
                  SkeletonObject so2,
                  Config config)
           throws InvalidSkeletonException,
                  WrongUsageOfAlgorithmException
Constructor that should only be used if you know what you are doing. You can pass the ready-to-use skeleton objects, but have to keep track of if the skeletons were reordered or not.

Parameters:
so1 - the skeleton object with lesser end nodes
so1_flipped - the first skeleton object, flipped horizontally
so2 - the skeleton object with more end nodes
config - holding the configuration parameters
Throws:
InvalidSkeletonException - if one of the skeleton seems to be broken
WrongUsageOfAlgorithmException - if the algorithm is applied in a wrong way
Method Detail

loadSkeletons

private void loadSkeletons(java.lang.String skeletonfilename1,
                           java.lang.String objectfilename1,
                           java.lang.String skeletonfilename2,
                           java.lang.String objectfilename2)
                    throws java.io.IOException,
                           InvalidSkeletonException,
                           InvalidConfigParameterException
load both skeletons, specified by the filename. The skeletons might get reordered in this function. Also, a flipped version of the "smaller" skeleton is parsed automatically.

Parameters:
skeletonfilename1 - - path to the first skeleton image
objectfilename1 - - path to the first shape image (belonging to skeletonfilename1)
skeletonfilename2 - - path to the second skeleton image
objectfilename2 - - path to the second skeleton image (belonging to skeletonfilename2)
Throws:
java.io.IOException - - if one of the image was not found
InvalidSkeletonException - - if one of the skeletons seems broken
InvalidConfigParameterException

go

public CleanMatchingResult go()
                       throws InvalidSkeletonException,
                              InvalidWeightFunctionGivenException,
                              WrongUsageOfAlgorithmException,
                              InvalidConfigParameterException
execute the PSGM algorithm. The matching result will be cleared, that is, if the input skeleton were reordered in order to execute the algorithm, they are ordered back, and if one of the shapes has been flipped, the match list is "translated back" to the original image.

Returns:
a cleaned up match list.
Throws:
InvalidSkeletonException - if one of the skeleton seems to be broken
InvalidWeightFunctionGivenException - if no valid weight function could be extracted for the final matching
WrongUsageOfAlgorithmException - if one of the steps in the algorithm has been applied wrong
InvalidConfigParameterException - if one of the configuration parameters is no valid value

getSo1

public SkeletonObject getSo1()
Get the "first skeleton", the one with lesser end nodes.

Returns:
the first skeleton object

setSo1

public void setSo1(SkeletonObject so1)
Set the "first skeleton", the one with lesser end nodes.

Parameters:
so1 - the first skeleton object

getSo2

public SkeletonObject getSo2()
Get the "second skeleton", the one with more end nodes

Returns:
the second skeleton object

setSo2

public void setSo2(SkeletonObject so2)
Set the "second skeleton", the one with lesser end nodes.

Parameters:
so2 - the second skeleton to set

getSo1_flipped

public SkeletonObject getSo1_flipped()
Get the first skeleton (the one with lesser end nodes), but flipped horizontally)

Returns:
the so1_flipped

setSo1_flipped

public void setSo1_flipped(SkeletonObject so1_flipped)
Set the first skeleton (the one with lesser end nodes), but flipped horizontally)

Parameters:
so1_flipped - the so1_flipped to set

isReordered

public boolean isReordered()
Test if the two skeletons were reordered in order to execute the algorithm.

Returns:
true if the two input skeletons had to be reordered, false if not.