Facemorph.psm
Class PSM

java.lang.Object
  extended by Facemorph.psm.PSM

public class PSM
extends java.lang.Object

PSM implementation using steerable pyramids (doesn't work very well, the PSMNode class is preferred)

See Also:
PSMNode

Constructor Summary
PSM()
          PSM constructor
PSM(int start, BigMat mst, DiagonalGMM[] appGauss, DiagonalGaussian[] gauss, boolean[] visited, java.util.ArrayList<Filter> filters, Filter lowpass, int w, int h, int levs)
          PSM constructor
 
Method Summary
 void batchTest(java.lang.String outfold, java.util.ArrayList<java.lang.String> imageNames, java.util.ArrayList<java.lang.String> templateNames, int w)
           
 double calculateFeatureProbability(SteerablePyramid pyr, float x, float y)
          Calculate the probability of this feature
 FloatImage evaluateProbability(FloatImage source)
          Evaluate the probability using Steerable pyramid
 FloatImage evaluateProbability(SteerablePyramid pyr)
          Evaluate the probability by recursing down and up the tree
static int findBestRoot(BigMat tree, BigMat graph)
          Find the best root of the tree
 java.util.ArrayList<java.awt.geom.Point2D.Float> getFeatures()
          Get the feature points
 java.util.ArrayList<java.awt.geom.Point2D.Float> getFeatures(FloatImage source)
          Get the feature points in the image
 void getFeatures(int x, int y, java.util.ArrayList<java.awt.geom.Point2D.Float> points)
          Get the features
static double[] getFeatureVector(SteerablePyramid pyr, float x, float y)
          Get the feature vector from a steerable pyramid
static void main(java.lang.String[] args)
           
static BigMat minimumSpanningTree(BigMat graph)
          Calculate the MST
static double ncc(double[] v1, double[] v2)
          The normalised cross correlation
 void read(java.io.InputStream in)
          Read from an input stream
 void read(java.io.StreamTokenizer st)
          Read from a StreamTokenizer
 void read(java.lang.String fileName)
          Read from a file
static PSM train(java.util.ArrayList<java.lang.String> imageNames, java.util.ArrayList<java.lang.String> templateNames, int[] pointList, int w, java.util.ArrayList<Filter> filters, Filter lowpass, int maxLev)
          PSM training method
 void write(java.io.PrintStream ps)
          Write to a PrintStream
 void write(java.lang.String fileName)
          Write PSM to a file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PSM

public PSM()
PSM constructor


PSM

public PSM(int start,
           BigMat mst,
           DiagonalGMM[] appGauss,
           DiagonalGaussian[] gauss,
           boolean[] visited,
           java.util.ArrayList<Filter> filters,
           Filter lowpass,
           int w,
           int h,
           int levs)
PSM constructor

Parameters:
start - the start node
mst - the minimum spanning tree
appGauss - the appearance models for the features
gauss - the point distributions
visited - indicates which nodes have been visited
filters - the filters to use to build the pyramids
lowpass - the lowpass filters to use to build the pyramids
w - the width
h - the height
levs - the levels
Method Detail

write

public void write(java.lang.String fileName)
Write PSM to a file

Parameters:
fileName - the file to write to

write

public void write(java.io.PrintStream ps)
Write to a PrintStream

Parameters:
ps - the PrintStream to write to

read

public void read(java.lang.String fileName)
Read from a file

Parameters:
fileName - the file to read from

read

public void read(java.io.InputStream in)
          throws java.io.IOException
Read from an input stream

Parameters:
in - the stream to read from
Throws:
java.io.IOException

read

public void read(java.io.StreamTokenizer st)
          throws java.io.IOException
Read from a StreamTokenizer

Parameters:
st - the StreamTokenizer to read from
Throws:
java.io.IOException

train

public static PSM train(java.util.ArrayList<java.lang.String> imageNames,
                        java.util.ArrayList<java.lang.String> templateNames,
                        int[] pointList,
                        int w,
                        java.util.ArrayList<Filter> filters,
                        Filter lowpass,
                        int maxLev)
PSM training method

Parameters:
imageNames - the names of the training images
templateNames - the names of the training templates
pointList - the list of points to use from each template
w - the training width
filters - the filters to use to build the pyramid
lowpass - the low pass filter to use to build the pyramid
maxLev - the maximum level to build the pyramid to
Returns:
return the trained PSM

findBestRoot

public static int findBestRoot(BigMat tree,
                               BigMat graph)
Find the best root of the tree

Parameters:
tree - the mst
graph - the original completed weighted edge graph
Returns:
returns the best root (in some sense)

minimumSpanningTree

public static BigMat minimumSpanningTree(BigMat graph)
Calculate the MST

Parameters:
graph - the Graph to find the MST for
Returns:
returns the MST

evaluateProbability

public FloatImage evaluateProbability(FloatImage source)
Evaluate the probability using Steerable pyramid

Parameters:
source - the source image
Returns:
returns the probability image

getFeatureVector

public static double[] getFeatureVector(SteerablePyramid pyr,
                                        float x,
                                        float y)
Get the feature vector from a steerable pyramid

Parameters:
pyr - the pyramid
x - the x-coors
y - the y-coord
Returns:
return the feature vector from the pyramid

calculateFeatureProbability

public double calculateFeatureProbability(SteerablePyramid pyr,
                                          float x,
                                          float y)
Calculate the probability of this feature

Parameters:
pyr - the steerable pyramid
x - x-coord
y - y-coord
Returns:
the probability of the feature at (x,y)

evaluateProbability

public FloatImage evaluateProbability(SteerablePyramid pyr)
Evaluate the probability by recursing down and up the tree

Parameters:
pyr - the pyramid to use
Returns:
returns the probabilities as an image

getFeatures

public void getFeatures(int x,
                        int y,
                        java.util.ArrayList<java.awt.geom.Point2D.Float> points)
Get the features

Parameters:
x - the x-coord
y - the y-coord
points - the point list to add the features to

getFeatures

public java.util.ArrayList<java.awt.geom.Point2D.Float> getFeatures(FloatImage source)
Get the feature points in the image

Parameters:
source - the input image
Returns:
the estimated feature locations

getFeatures

public java.util.ArrayList<java.awt.geom.Point2D.Float> getFeatures()
Get the feature points

Returns:
return the most likely feature points

ncc

public static double ncc(double[] v1,
                         double[] v2)
The normalised cross correlation

Parameters:
v1 - the first vector
v2 - the second vector
Returns:
returns the ncc between the two vectors

batchTest

public void batchTest(java.lang.String outfold,
                      java.util.ArrayList<java.lang.String> imageNames,
                      java.util.ArrayList<java.lang.String> templateNames,
                      int w)
Parameters:
outfold -
imageNames -
templateNames -
w -

main

public static void main(java.lang.String[] args)
Parameters:
args -