edu.stanford.rsl.konrad.utils
Class BilinearInterpolatingDoubleArray

java.lang.Object
  extended by edu.stanford.rsl.konrad.utils.BilinearInterpolatingDoubleArray
All Implemented Interfaces:
java.io.Serializable

public class BilinearInterpolatingDoubleArray
extends java.lang.Object
implements java.io.Serializable

Class for interpolation on an arbitrary regular 2-D grid. (Inplementation follows formula as displayed in Wikipedia.)

Author:
akmaier
See Also:
http://en.wikipedia.org/wiki/Bilinear_interpolation, Serialized Form

Constructor Summary
BilinearInterpolatingDoubleArray(double[] meshx, double[] meshy, double[][] values)
          Constructor with requires an x-mesh, a y-mesh, and a two-dimensional array of values at the mesh points
 
Method Summary
 double getValue(double meshPointX, double meshPointY)
          Interpolate an arbitrary point between the meshes.
static void main(java.lang.String[] args)
          Code for testing using KONRAD Software package.
 ij.process.FloatProcessor toFloatProcessor(int binsX, int binsY)
          Renders a float processor of the 2-D array given the number of bins in x and y direction
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BilinearInterpolatingDoubleArray

public BilinearInterpolatingDoubleArray(double[] meshx,
                                        double[] meshy,
                                        double[][] values)
Constructor with requires an x-mesh, a y-mesh, and a two-dimensional array of values at the mesh points

Parameters:
meshx - the mesh spacing in x direction
meshy - the mesh spacing in y direction
values - the values at the mesh points.
Method Detail

getValue

public double getValue(double meshPointX,
                       double meshPointY)
                throws java.lang.Exception
Interpolate an arbitrary point between the meshes.

Parameters:
meshPointX - the x-coordinate
meshPointY - the y-coordinate
Returns:
the interpolated value
Throws:
java.lang.Exception - may happen if the point is not within the grid.

main

public static void main(java.lang.String[] args)
Code for testing using KONRAD Software package. Will create the example image as displayed in Wikipedia.
(http://en.wikipedia.org/wiki/File:Bilininterp.png)

Parameters:
args -

toFloatProcessor

public ij.process.FloatProcessor toFloatProcessor(int binsX,
                                                  int binsY)
Renders a float processor of the 2-D array given the number of bins in x and y direction

Parameters:
binsX - the number of bins in x direction
binsY - the number of bins in y direction
Returns:
the rendered FloatProcessor.