|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Facemorph.PCI
public class PCI
An object to contain the PCA of a set of images
Field Summary | |
---|---|
float[] |
maxWeights
List of the maximum or mean weights that keep the components within a specified range |
Constructor Summary | |
---|---|
PCI()
Creates a new instance of PCI |
Method Summary | |
---|---|
float[] |
analyse(FloatImage[] fimg)
Analyses the given image to gives the weights of the principal components |
float[] |
analyse(FloatImage[] fimg,
FloatImage mask)
Analyses the given image to gives the weights of the principal components |
static float[] |
analyseFile(FloatImage[] fimg,
FloatImage mask,
int pcaCount)
Analyses the given image to gives the weights of the principal components |
double[] |
analyseLS(FloatImage[] fimg,
FloatImage mask)
Analyses the given image to gives the weights of the principal components |
float[] |
analyseMaxWeights(FloatImage[] fimg)
Analyses the given image to gives the weights of the principal components |
void |
build(java.util.ArrayList<java.awt.image.BufferedImage> images,
double varianceToExplain)
Method to create a PCI from a set of delineated images. |
void |
build(java.util.ArrayList<java.awt.image.BufferedImage> images,
double varianceToExplain,
FloatImage mask)
Method to create a PCI from a set of delineated images. |
void |
build(Template avTem,
FloatImage[] avImg,
java.awt.Image[] images,
Template[] templates,
FloatImage mask,
double varianceToExplain)
Method to create a PCI from a set of delineated images. |
void |
build(Template avTem,
java.awt.Image avImg,
java.awt.Image[] images,
Template[] templates,
Mask mask,
double varianceToExplain)
Builds a PCI from the data given |
void |
buildFloatImage(java.util.ArrayList<FloatImage[]> images,
FloatImage mask,
double varianceToExplain)
Method to create a PCI from a set of delineated images. |
static double[] |
buildWarpedFiles(int number,
double varianceToExplain,
FloatImage[] average,
FloatImage mask)
Method to create a PCI from a set of pre-warped images, which are read from files with names of the form "warped"+i+"_"+k+".fimg" where k is 0, 1 or 2 for r, g and b. |
void |
calculateMaxWeights(int min,
int max)
Calculates the max weights required to keep the component within the (min, max) range |
void |
calculateMeanWeights(int min,
int max)
Calculates the mean weights required to keep the component within the (min, max) range |
BigMat |
combine(PCI[] pci,
Template targetShape,
int targetWidth,
int targetHeight,
Mask mask)
Builds a PCI by combining a set of PCIs |
FloatImage[] |
getAverage()
Retrieves the average image as an array of FloatImage |
FloatImage[] |
getComponent(int i)
Retrieve a specific component |
float[] |
getComponentMaxShiftScale(int comp,
float min,
float max)
Find scale and shift of component comp of this PCI such that alpha*smallest <= min and alpha*biggest<=max |
int |
getCount()
Return the number of components in this model |
FloatImage[][] |
getIntersection(PCI pci,
Mask mask)
Gets the intersection or closest point between two PCIs |
FloatImage[][] |
getIntersectionIterative(PCI pci,
Mask mask)
Gets the intersection or closest point between two PCIs |
float[][] |
getMaxShiftScale(float min,
float max)
Get the scale and shift for each component so that the values remain the min-max range |
float[] |
getMaxWeights(int min,
int max)
Get the mean weights required to keep the component within the (min, max) range |
BigMat |
getReduced(PCI pci,
float[] filter,
int m,
Mask mask)
Shrinks by a factor of 2 using filter to downsample |
Template |
getTemplate()
Retrieve the average template that defines the shape of this PCI |
double |
getTotalVariance()
Return the total variance |
double |
getVariance(int i)
Get the variance of component i |
static void |
main(java.lang.String[] args)
Main method used for testing |
void |
read(java.lang.String file,
int maxComp)
Reads PCI data from a directory |
void |
readJpgs(java.lang.String file,
int maxComp,
java.applet.Applet applet)
Reads PCI data as a list of image filesspecified in a text file |
FloatImage[] |
reconstruct(float[] params)
reconstructs an image given the component weightings |
FloatImage[] |
reconstruct(float[] params,
FloatImage[] avrg)
reconstructs an image given the component weightings, using avrg instead of the built in average |
java.awt.image.BufferedImage |
reconstructBufferedImage(float[] params)
Build an image from PCA components using the weights given |
static FloatImage[] |
reconstructFile(float[] params,
FloatImage[] avrg,
int pcaCount)
reconstructs an image given the component weightings, using avrg instead of the built in average |
java.awt.Image |
reconstructImage(float[] params)
Build an image from PCA components using the weights given |
FloatImage[] |
reconstructMaxWeights(float[] params)
Build an image from PCA components using the weights given after rescaling them by the maxWeights array |
FloatImage[] |
reconstructMaxWeights(float[] params,
FloatImage[] avrg)
Build an image from PCA components using the weights given after rescaling them by the maxWeights array. |
void |
replaceMean(java.awt.Image newMean,
Template temp,
boolean project)
Replace the mean image with that specified |
void |
setAverage(FloatImage red,
FloatImage green,
FloatImage blue)
Sets the values of the mean image |
void |
setComponent(int i,
FloatImage[] fimg)
Set one component |
void |
setComponents(FloatImage[][] comps,
double[] variances)
Sets the components and their variances |
void |
setMaxCount(int c)
Sets the maximum number of components to use |
BigMat |
warp(Template targetShape,
int targetWidth,
int targetHeight,
Mask mask)
Warps this PCI into targetShape |
void |
write(java.lang.String file)
Writes PCI data to a directory |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public float[] maxWeights
Constructor Detail |
---|
public PCI()
Method Detail |
---|
public BigMat getReduced(PCI pci, float[] filter, int m, Mask mask)
pci
- The PCI to copy and shrinkfilter
- The downsampling filterm
- The midpoint of the downsampling filtermask
- The mask to use
public BigMat warp(Template targetShape, int targetWidth, int targetHeight, Mask mask)
targetShape
- The desired new shape of the PCItargetWidth
- the desired new width of the PCItargetHeight
- the desired new height of the PCImask
- The mask to use
public void build(Template avTem, java.awt.Image avImg, java.awt.Image[] images, Template[] templates, Mask mask, double varianceToExplain) throws Facemorph.PCI.AverageException
avTem
- The average Template to useavImg
- The average imaage to useimages
- The set of images to usetemplates
- The set of Templates to usemask
- The mask to usevarianceToExplain
- The fraction of variance to explain in this model
Facemorph.PCI.AverageException
public void build(Template avTem, FloatImage[] avImg, java.awt.Image[] images, Template[] templates, FloatImage mask, double varianceToExplain) throws Facemorph.PCI.AverageException
avTem
- The average TemplateavImg
- The average image as an array of 3 FloatImageimages
- The array of images to be averaged.templates
- The array of templates outlining the features of the corresponding templates.mask
- The FLoatImage to use as a mask, values should be between 0 and 1varianceToExplain
- This controls the number of components output.
AverageException
- Thrown if a problem arises in building this PCI
Facemorph.PCI.AverageException
public void build(java.util.ArrayList<java.awt.image.BufferedImage> images, double varianceToExplain) throws Facemorph.PCI.AverageException
images
- The array of images to be averaged.varianceToExplain
- This controls the number of components output.
AverageException
- Thrown if a problem arises in building this PCI
Facemorph.PCI.AverageException
public void build(java.util.ArrayList<java.awt.image.BufferedImage> images, double varianceToExplain, FloatImage mask) throws Facemorph.PCI.AverageException
images
- The array of images to be averaged.varianceToExplain
- This controls the number of components output.mask
- mask image to use when building the PCI
AverageException
- Thrown if a problem arises in building this PCI
Facemorph.PCI.AverageException
public static double[] buildWarpedFiles(int number, double varianceToExplain, FloatImage[] average, FloatImage mask) throws Facemorph.PCI.AverageException
number
- the number of images to be usedvarianceToExplain
- This controls the number of components output.average
- average image, seems to be only used for its sizemask
- a mask to use or null if no masking needed
AverageException
- Thrown if a problem arises in building this PCI
Facemorph.PCI.AverageException
public void buildFloatImage(java.util.ArrayList<FloatImage[]> images, FloatImage mask, double varianceToExplain) throws Facemorph.PCI.AverageException
images
- The array of images to be averaged.mask
- selection function for points to usevarianceToExplain
- This controls the number of components output.
AverageException
- Thrown if a problem arises in building this PCI
Facemorph.PCI.AverageException
public BigMat combine(PCI[] pci, Template targetShape, int targetWidth, int targetHeight, Mask mask)
pci
- An array of PCIs to combinetargetShape
- the desired output shapetargetWidth
- the desired output widthtargetHeight
- the desired output heightmask
- the mask to use
public FloatImage[][] getIntersection(PCI pci, Mask mask) throws BigMatException
pci
- the PCI to find the intersection withmask
- the mask to use
BigMatException
public FloatImage[][] getIntersectionIterative(PCI pci, Mask mask)
pci
- the PCI to find the intersection withmask
- the mask to use
public void setAverage(FloatImage red, FloatImage green, FloatImage blue)
red
- The red component of the averagegreen
- The green component of the averageblue
- The blue component of the averagepublic void replaceMean(java.awt.Image newMean, Template temp, boolean project)
newMean
- the new mean to usetemp
- the shape of the new meanproject
- boolean indicating if the mean should be projected back
into the new PCI and used as the meanpublic void readJpgs(java.lang.String file, int maxComp, java.applet.Applet applet)
file
- The text file containing the names of the image component files and their variancemaxComp
- The maximum number of components to readapplet
- The applet that is reading the PCI from Jpgspublic void read(java.lang.String file, int maxComp) throws java.io.IOException
file
- The text file containing the names of the image component files and their variancemaxComp
- The maximum number of components to read
java.io.IOException
- if the file can't be readpublic void write(java.lang.String file) throws java.io.IOException
file
- The text file containing the names of the image component files and their variance
java.io.IOException
- throws IOException if problem writing filepublic FloatImage[] getComponent(int i)
i
- The index of the component
public void setComponents(FloatImage[][] comps, double[] variances)
comps
- The new components to usevariances
- the new variances to usepublic void setComponent(int i, FloatImage[] fimg)
i
- The index of the componentfimg
- the red, green and blue components in an array of 3 FloatImagepublic void setMaxCount(int c)
c
- the new maximum countpublic FloatImage[] reconstruct(float[] params)
params
- the component weightings
public java.awt.Image reconstructImage(float[] params)
params
- The weights of each component
public java.awt.image.BufferedImage reconstructBufferedImage(float[] params)
params
- The weights of each component
public FloatImage[] reconstruct(float[] params, FloatImage[] avrg)
params
- the component weightingsavrg
- the average image to use as an {R,G,B} array of FloatImage
public static FloatImage[] reconstructFile(float[] params, FloatImage[] avrg, int pcaCount)
params
- the component weightingsavrg
- the average image to use as an {R,G,B} array of FloatImagepcaCount
- the number of components to use in the reconstruction
public FloatImage[] reconstructMaxWeights(float[] params)
params
- The scaled PCA weights
public FloatImage[] reconstructMaxWeights(float[] params, FloatImage[] avrg)
params
- The parameters weightsavrg
- The average image to use as the base
public double getVariance(int i)
i
- The component whose variance you want to know
public double getTotalVariance()
public float[] analyse(FloatImage[] fimg)
fimg
- The FloatImage to analyse
public float[] analyse(FloatImage[] fimg, FloatImage mask)
fimg
- The FloatImage to analysemask
- the mask to use
public static float[] analyseFile(FloatImage[] fimg, FloatImage mask, int pcaCount)
fimg
- The FloatImage to analysemask
- the mask to usepcaCount
- the number of pca components to use
public double[] analyseLS(FloatImage[] fimg, FloatImage mask)
fimg
- The FloatImage to analysemask
- the mask to use
public float[] analyseMaxWeights(FloatImage[] fimg)
fimg
- The FloatImage to analyse
public int getCount()
public FloatImage[] getAverage()
public Template getTemplate()
public void calculateMaxWeights(int min, int max)
min
- The minimum value you want it to attainmax
- The maximum value you want it to attainpublic void calculateMeanWeights(int min, int max)
min
- The minimum value you want it to attainmax
- The maximum value you want it to attainpublic float[] getMaxWeights(int min, int max)
min
- The minimum value you want it to attainmax
- The maximum value you want it to attain
public float[] getComponentMaxShiftScale(int comp, float min, float max)
comp
- the component to testmin
- the minimum valuemax
- the maximum value
public float[][] getMaxShiftScale(float min, float max)
min
- the minimum value neededmax
- the maximum value needed
public static void main(java.lang.String[] args)
args
- the arguments to use
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |