volume
Class Transformer

java.lang.Object
  |
  +--volume.Transformer

public class Transformer
extends java.lang.Object

This class implements static methods for transforming images and volumes.

See Also:
for transformation matrix operations. Copyright (c) 1999-2003, Michael Abramoff. All rights reserved.

Constructor Summary
Transformer()
           
 
Method Summary
static float bilinear(float[] image, int width, float x, float y)
          Bilinearly interpolate the pixel at x,y.
static float bilinearExtend(float[] image, int width, int height, float x, float y)
          Interpolate the pixel at x,y in image, extend if x,y not in image .
static float[][] convertParametersIntoTransformationMatrix(double[] p)
          Convert a bunch of double transformation parameters into a transformation matrix.
static float[][] convertParametersIntoTransformationMatrix(float[] p)
          Convert a bunch of float transformation parameters into a transformation matrix.
static float[][] convertParametersIntoTransformationMatrix(float[] p, float xcenter, float ycenter)
          Convert a bunch of float transformation parameters into a transformation matrix.
static float[] extract(float[] image, int width, int newx, int newy, int newwidth, int newheight)
          Extract a new float [] image from an image.
static float[] quick(float[] image, int width, int xshift, int yshift)
          Quickly transform an image for whole pixel shifts.
static float[] transform(float[] image, int width, float[] p)
          Transform image using the transformation parameters in p.
static float[] transform(float[] image, int width, float[][] m)
          Bilinearly transform an image using a 2-D transformation matrix m.
static float[] transform(float[] image, int width, float[] p, float xcenter, float ycenter)
          Transform image using the transformation parameters in p.
static ij.process.ImageProcessor transform(ij.process.ImageProcessor ip, float[] p)
          Transform the image in fp by translation parameters p
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Transformer

public Transformer()
Method Detail

transform

public static float[] transform(float[] image,
                                int width,
                                float[] p)
                         throws java.lang.Exception
Transform image using the transformation parameters in p. The transformation parameters do not include centering the image before rotation around the rotation axis. The rotation is around the center of the image.
Parameters:
the - image to be transformed.
width - the width of the image.
p - a float[] with the transformation parameters:
Returns:
the transformation of image.
See Also:
convertParametersIntoTransformationMatrix

transform

public static float[] transform(float[] image,
                                int width,
                                float[] p,
                                float xcenter,
                                float ycenter)
                         throws java.lang.Exception
Transform image using the transformation parameters in p. The transformation parameters do not include centering the image before rotation around the rotation axis.
Parameters:
the - image to be transformed.
width - the width of the image.
p - a float[] with the transformation parameters:
xcenter - the x center for rotation.
ycenter - the ycenter for rotation.
Returns:
the transformation of image.
See Also:
convertParametersIntoTransformationMatrix

transform

public static float[] transform(float[] image,
                                int width,
                                float[][] m)
                         throws java.lang.Exception
Bilinearly transform an image using a 2-D transformation matrix m.
Parameters:
image - a float[] image
width - the width of image
m - the transformation matrix, a homogenuous matrix.

convertParametersIntoTransformationMatrix

public static float[][] convertParametersIntoTransformationMatrix(float[] p,
                                                                  float xcenter,
                                                                  float ycenter)
Convert a bunch of float transformation parameters into a transformation matrix.
Parameters:
p - the parameters (either first 2, first 3 or 5).
 p[0] translation x-dir
 p[1] translation y-dir
 p[2] rotation (degrees)
 p[3] scaling x
 p[4] scaling y
 
xcenter, - ycenter the x and y center for rotation if any.
Returns:
a transformation matrix.

convertParametersIntoTransformationMatrix

public static float[][] convertParametersIntoTransformationMatrix(float[] p)
Convert a bunch of float transformation parameters into a transformation matrix.
Parameters:
p - the parameters (either first 2, first 3 or 5).
 p[0] translation x-dir
 p[1] translation y-dir
 p[2] rotation (degrees)
 p[3] scaling x
 p[4] scaling y
 
Returns:
a transformation matrix.

convertParametersIntoTransformationMatrix

public static float[][] convertParametersIntoTransformationMatrix(double[] p)
Convert a bunch of double transformation parameters into a transformation matrix.
Parameters:
p - the parameters
 p[0] translation x-dir
 p[1] translation y-dir
 p[2] rotation (degrees)
 p[3] scaling x
 p[4] scaling y
 
Returns:
a transformation matrix.

bilinearExtend

public static float bilinearExtend(float[] image,
                                   int width,
                                   int height,
                                   float x,
                                   float y)
Interpolate the pixel at x,y in image, extend if x,y not in image .
Parameters:
x -  
y -  
image -  
Returns:
the interpolated value at x,y

bilinear

public static float bilinear(float[] image,
                             int width,
                             float x,
                             float y)
Bilinearly interpolate the pixel at x,y. Take care of NaN pixels.
Parameters:
image - the image in which to interpolate
width - the width of the image.
x,y - the position at which to interpolate.
Returns:
the interpolated value at x,y, NaN if any of the involved pixels are NaN.

transform

public static ij.process.ImageProcessor transform(ij.process.ImageProcessor ip,
                                                  float[] p)
Transform the image in fp by translation parameters p
Parameters:
fp - and ImageProcessor
p - the transformation parameters (translation only).
 p[0] translation x-dir
 p[1] translation y-dir
 
Returns:
the transformed ImageProcessor.

quick

public static float[] quick(float[] image,
                            int width,
                            int xshift,
                            int yshift)
Quickly transform an image for whole pixel shifts.
Parameters:
image - a float[] image
width - the width of image
x - the x shift
y - the y-shift.
Returns:
the shifted image.

extract

public static float[] extract(float[] image,
                              int width,
                              int newx,
                              int newy,
                              int newwidth,
                              int newheight)
Extract a new float [] image from an image.
Parameters:
image - the image
width - the original width of the image
newx - the x location of the part to be extracted
newy - the y location of the part to be extracted
newwidth - the the width of the part to be extracted
newheight - the the width of the part to be extracted
Returns:
a float[] of newwidth*newheight pixels.