Facemorph
Class GridWarp2D

java.lang.Object
  extended by Facemorph.GridWarp2D

public class GridWarp2D
extends java.lang.Object

Warps using a grid of fixed size using B-splines and an affine term


Constructor Summary
GridWarp2D(int gridWidth, int gridHeight, int width, int height)
          Creates a new instance of GridWarp2D
 
Method Summary
 java.awt.geom.Point2D.Double get(double x, double y)
          Gets the interpolated value at the point specified
static void main(java.lang.String[] args)
          Main method for testing
static java.awt.Color sample(java.awt.image.BufferedImage img, float x, float y)
          Sample from a non-integer point in an image (as an int array) using linear interpolated sampling
 void setAffine(Vector3 ax, Vector3 ay)
          Sets the affine terms
 void setGridValue(int x, int y, double xval, double yval)
          Sets a specific grid value
 double spline(double x)
          Calculates the cubic B-spline on interval x=[0.0,4.0]
 java.awt.image.BufferedImage warpImage(java.awt.image.BufferedImage img)
          Warps the given image using this GridWarp2D
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridWarp2D

public GridWarp2D(int gridWidth,
                  int gridHeight,
                  int width,
                  int height)
Creates a new instance of GridWarp2D

Parameters:
gridWidth - the width of the grid
width - the width of the warped image
gridHeight - the height of the grid
height - the height of the grid to warp
Method Detail

setGridValue

public void setGridValue(int x,
                         int y,
                         double xval,
                         double yval)
Sets a specific grid value

Parameters:
x - the x-grid coord
y - the y-grid coord
xval - the new x-value of the warp
yval - the new y-value of the warp

setAffine

public void setAffine(Vector3 ax,
                      Vector3 ay)
Sets the affine terms

Parameters:
ax - the x affine term
ay - the y affine term

get

public java.awt.geom.Point2D.Double get(double x,
                                        double y)
Gets the interpolated value at the point specified

Parameters:
x - the x-coord
y - the y-coord
Returns:
returns the interpolated warped coordinate

spline

public double spline(double x)
Calculates the cubic B-spline on interval x=[0.0,4.0]

Parameters:
x - the position on the interval
Returns:
the value of the B-spline at that point

sample

public static java.awt.Color sample(java.awt.image.BufferedImage img,
                                    float x,
                                    float y)
Sample from a non-integer point in an image (as an int array) using linear interpolated sampling

Parameters:
img - The BufferedImage to sample from
x - The x-coord of the sample point
y - Te y-coord of the sample point
Returns:
The sampled colour

warpImage

public java.awt.image.BufferedImage warpImage(java.awt.image.BufferedImage img)
Warps the given image using this GridWarp2D

Parameters:
img - the image top warp
Returns:
the warped image

main

public static void main(java.lang.String[] args)
Main method for testing

Parameters:
args - command line arguments (not used)