Facemorph
Class MultiscaleWarp

java.lang.Object
  extended by Facemorph.Warp
      extended by Facemorph.MultiscaleWarp
All Implemented Interfaces:
java.io.Serializable

public class MultiscaleWarp
extends Warp
implements java.io.Serializable

Implements a multi-scale interpolation algorithm

See Also:
Serialized Form

Field Summary
static int WARP_AFFINE_ONLY
          Static constant for affine only
static int WARP_FULL_AFFINE
          Static constant for full warp with affine component
static int WARP_FULL_RIGID
          Static constant for full warp with rigid component
static int WARP_RIGID_ONLY
          Static constant for rigid only
 
Fields inherited from class Facemorph.Warp
height, LINEAR, MULTISCALE, MULTISCALERB, TPS, width, xshift, yshift
 
Constructor Summary
MultiscaleWarp(int w, int h)
          Creates a multi-scale warping object of the specified (equal input and output) dimensions
MultiscaleWarp(int w, int h, int tw, int th)
          Creates a multi-scale warping object of the specified input and output dimensions
 
Method Summary
 void calculateAffine(java.util.List<java.awt.geom.Point2D.Float> source, java.util.List<java.awt.geom.Point2D.Float> dest)
          Calculate the affine components of the warp
 void calculateRigid(java.util.List<java.awt.geom.Point2D.Float> source, java.util.List<java.awt.geom.Point2D.Float> dest)
          Calculate the rigid components of the warp
 void concatenate(MultiscaleWarp warp1, MultiscaleWarp warp2)
          Concatenates 2 MultiscaleWarps
 void concatenate(Warp warp)
          Concatenates warp with this
 void copy(BSplineQuadTree bwarp)
          Copy a warp defined as a BSplineQuadTree
 void copy(MultiscaleWarp warp)
          Copy the given warp
 float[] get(int x, int y)
          return the value of the warping function at the specified position
 float[] getScaled(int x, int y, float scale)
          return the value of the warping function at the specified position,scaled by the specified amount
 boolean interpolate(int n, java.util.List<java.awt.geom.Point2D.Float> source, java.util.List<java.awt.geom.Point2D.Float> dest, boolean borders)
          Interpolates the given 2D values across the 2D space, by performing setup then calling interpolate()
 boolean interpolate(int n, java.awt.geom.Point2D.Float[] source, java.awt.geom.Point2D.Float[] dest, boolean borders)
          Method to interpolate the warping function
 boolean interpolate(java.util.List<javax.vecmath.TexCoord2f> source, java.util.List<javax.vecmath.TexCoord2f> dest, boolean borders)
          Interpolates using points in an ArrayList
 boolean interpolate(javax.vecmath.TexCoord2f[] source, javax.vecmath.TexCoord2f[] dest, boolean borders)
          Interpolates using the texture coords (values between 0 and 1)
 void scaleWarp(float scaleFactor)
          Scales a warp by the amount specified
 void set(int x, int y, float X, float Y)
          Sets the value of this warp at the specified point
 void setScaled(MultiscaleWarp small)
          Up-scale the small warp into this
 void setWarpType(int type)
          Sets the type of warp
 int upsample(MultiscaleWarp small, float[] filter, int m)
          Upsample (expand) the small warp into this
 
Methods inherited from class Facemorph.Warp
concatenate, convert, createWarp, getHeight, getWidth, interpolate, interpolate, interpolate, iterate, overlap, reconvert, sample, sample, stripPoints, warpFloatImage, warpImage, warpImage, warpImage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WARP_FULL_AFFINE

public static final int WARP_FULL_AFFINE
Static constant for full warp with affine component

See Also:
Constant Field Values

WARP_FULL_RIGID

public static final int WARP_FULL_RIGID
Static constant for full warp with rigid component

See Also:
Constant Field Values

WARP_AFFINE_ONLY

public static final int WARP_AFFINE_ONLY
Static constant for affine only

See Also:
Constant Field Values

WARP_RIGID_ONLY

public static final int WARP_RIGID_ONLY
Static constant for rigid only

See Also:
Constant Field Values
Constructor Detail

MultiscaleWarp

public MultiscaleWarp(int w,
                      int h)
Creates a multi-scale warping object of the specified (equal input and output) dimensions

Parameters:
w - The desired width
h - The desired height

MultiscaleWarp

public MultiscaleWarp(int w,
                      int h,
                      int tw,
                      int th)
Creates a multi-scale warping object of the specified input and output dimensions

Parameters:
w - The desired width
h - The desired height
tw - The width of the source image
th - The height of the source image
Method Detail

setWarpType

public void setWarpType(int type)
Sets the type of warp

Parameters:
type - type should be one of WARP_FULL_AFFINE, WARP_FULL_RIGID, WARP_AFFINE_ONLY, WARP_RIGID_ONLY

copy

public void copy(MultiscaleWarp warp)
Copy the given warp

Parameters:
warp - the warp to copy

calculateAffine

public void calculateAffine(java.util.List<java.awt.geom.Point2D.Float> source,
                            java.util.List<java.awt.geom.Point2D.Float> dest)
Calculate the affine components of the warp

Parameters:
source - set of source points
dest - set of target points

calculateRigid

public void calculateRigid(java.util.List<java.awt.geom.Point2D.Float> source,
                           java.util.List<java.awt.geom.Point2D.Float> dest)
Calculate the rigid components of the warp

Parameters:
source - set of source points
dest - set of target points

interpolate

public boolean interpolate(int n,
                           java.util.List<java.awt.geom.Point2D.Float> source,
                           java.util.List<java.awt.geom.Point2D.Float> dest,
                           boolean borders)
Interpolates the given 2D values across the 2D space, by performing setup then calling interpolate()

Parameters:
n - The number of constraints to interpolate
source - The array of start points
dest - The array of end points
borders - Specifies whether to fix the points on the borders
Returns:
true of the interpolation was successful, false otherwise

interpolate

public boolean interpolate(javax.vecmath.TexCoord2f[] source,
                           javax.vecmath.TexCoord2f[] dest,
                           boolean borders)
Interpolates using the texture coords (values between 0 and 1)

Parameters:
source - The source coordinates
dest - The destination coordinates
borders - Specifices if the borders should be fixed
Returns:
Returns true if interpolation was successful

interpolate

public boolean interpolate(java.util.List<javax.vecmath.TexCoord2f> source,
                           java.util.List<javax.vecmath.TexCoord2f> dest,
                           boolean borders)
Interpolates using points in an ArrayList

Parameters:
source - The list of source points
dest - The list of target points
borders - Specifies if the borders should be fixed
Returns:
Return true if interpolation was successful

upsample

public int upsample(MultiscaleWarp small,
                    float[] filter,
                    int m)
Upsample (expand) the small warp into this

Parameters:
small - the small warp
filter - the upsampling filter
m - the mid-point of the filter
Returns:
returns 1

copy

public void copy(BSplineQuadTree bwarp)
Copy a warp defined as a BSplineQuadTree

Parameters:
bwarp - the warp to copy

get

public float[] get(int x,
                   int y)
return the value of the warping function at the specified position

Overrides:
get in class Warp
Parameters:
x - The x-coordinate
y - The y-coordinate
Returns:
A float array of 2 containing the x and y value of the warp.

set

public void set(int x,
                int y,
                float X,
                float Y)
Sets the value of this warp at the specified point

Overrides:
set in class Warp
Parameters:
x - The x-coord
y - The y-coord
X - The X value
Y - The Y value

concatenate

public void concatenate(Warp warp)
Description copied from class: Warp
Concatenates warp with this

Overrides:
concatenate in class Warp
Parameters:
warp - the warp to concatenate

concatenate

public void concatenate(MultiscaleWarp warp1,
                        MultiscaleWarp warp2)
Concatenates 2 MultiscaleWarps

Parameters:
warp1 - the first warp
warp2 - the second warp

getScaled

public float[] getScaled(int x,
                         int y,
                         float scale)
return the value of the warping function at the specified position,scaled by the specified amount

Parameters:
scale - The amount to scale this warp by
x - The x-coordinate
y - The y-coordinate
Returns:
A float array of 2 containing the x and y value of the warp.

setScaled

public void setScaled(MultiscaleWarp small)
Up-scale the small warp into this

Parameters:
small - the small warp to upscale

scaleWarp

public void scaleWarp(float scaleFactor)
Description copied from class: Warp
Scales a warp by the amount specified

Overrides:
scaleWarp in class Warp
Parameters:
scaleFactor - the scale factor to apply to this warp

interpolate

public boolean interpolate(int n,
                           java.awt.geom.Point2D.Float[] source,
                           java.awt.geom.Point2D.Float[] dest,
                           boolean borders)
Description copied from class: Warp
Method to interpolate the warping function

Specified by:
interpolate in class Warp
Parameters:
n - The number of constraints
source - The start points
dest - The target points
borders - if true fix the borders
Returns:
true if the interpolation was successful