edu.jhmi.rad.medic.libraries
Class ImageFunctionsPublic

java.lang.Object
  extended by edu.jhmi.rad.medic.libraries.ImageFunctionsPublic

public class ImageFunctionsPublic
extends java.lang.Object

This class computes various basic image functions, e.g. gradient, convolution, interpolation.

Version:
July 2004
Author:
Pierre-Louis Bazin

Constructor Summary
ImageFunctionsPublic()
           
 
Method Summary
static void computeGradient(float[][][] img, float[][][] dx, float[][][] dy, float[][][] dz, int nx, int ny, int nz)
          simple gradient (central differences)
static void computeGradientHorn(float[][][] img, float[][][] dx, float[][][] dy, float[][][] dz, int nx, int ny, int nz)
          Horn-like derivatives: use a 2x2 forward square as averaging the gradient images are passed from above
static void computeGSTeigenvalues(float[][][] img, float[][][][] values, int nx, int ny, int nz)
          gradient shape tensor: return the eigenvalues at each point
static void computeHessian(float[][][] img, float[][][][] hessian, int nx, int ny, int nz)
          simple Hessian
static void computeHessianEigenvalues(float[][][] img, float[][][][] values, int nx, int ny, int nz)
          simple Hessian
static float[][][] convolution(float[][][] image, int nx, int ny, int nz, float[][][] kernel, int kx, int ky, int kz)
          convolution
static float cubicLagrangianInterpolation3D(float[][][] image, boolean[][][] mask, float[][] wt, float min, float max, float x, float y, float z, int nx, int ny, int nz)
          3D cubic Lagrangian function
static float cubicLagrangianInterpolation3D(float[][][] image, float[][] wt, float min, float max, float x, float y, float z, int nx, int ny, int nz)
          3D cubic Lagrangian function
static boolean exclusiveMaskInterpolation(boolean[][][] image, float x, float y, float z, int nx, int ny, int nz)
          interpolate a computation mask: where there is no data, the mask is set to false (generates a mask that is contained in the transformed image)
static float[][][] gaussianKernel(float sx, float sy, float sz)
          Gaussian kernel
static float[][][] heatDiffusion(float[][][] image, float scale, float ratio, int steps, float dt, int nx, int ny, int nz)
          GVF-style diffusion on scalar images
static float[][][] heatDiffusion(float[][][] image, float ratio, int steps, float dt, int nx, int ny, int nz)
          GVF-style diffusion on scalar images
static boolean inclusiveMaskInterpolation(boolean[][][] image, float x, float y, float z, int nx, int ny, int nz)
          interpolate a computation mask: where there is some data, the mask is set to true (generates a mask that contain the transformed image)
static float linearDistanceInterpolation(float[][][] image, float value, float x, float y, float z, int nx, int ny, int nz)
          linear interpolation, with distance to boundary outside image
static float linearGradientInterpolation(float[][][] image, float value, int dim, float x, float y, float z, int nx, int ny, int nz)
          linear interpolation, with +/- value outside the image useful for interpolating gradients (suppose the gradient is +value away from the image)
static float linearInterpolation(float[][][] image, boolean[][][] mask, float value, float x, float y, float z, int nx, int ny, int nz)
          linear interpolation, with value outside the image and mask
static float linearInterpolation(float[][][] image, float value, float x, float y, float z, int nx, int ny, int nz)
          linear interpolation, with value outside the image
static float linearInterpolation(float[][][] image, float x, float y, float z, int nx, int ny, int nz)
          linear interpolation, with 0 outside the image
static float linearInterpolation(float[] image, float value, float x, float y, float z, int nx, int ny, int nz)
          linear interpolation, with value outside the image
static float linearInterpolationXderivative(float[][][] image, float x, float y, float z, int nx, int ny, int nz)
          exact derivatives of linear interpolation
static float linearInterpolationXderivative(float[] image, float x, float y, float z, int nx, int ny, int nz)
          exact derivatives of linear interpolation
static float linearInterpolationYderivative(float[][][] image, float x, float y, float z, int nx, int ny, int nz)
          exact derivatives of linear interpolation
static float linearInterpolationYderivative(float[] image, float x, float y, float z, int nx, int ny, int nz)
          exact derivatives of linear interpolation
static float linearInterpolationZderivative(float[][][] image, float x, float y, float z, int nx, int ny, int nz)
          exact derivatives of linear interpolation
static float linearInterpolationZderivative(float[] image, float x, float y, float z, int nx, int ny, int nz)
          exact derivatives of linear interpolation
static boolean linearMaskInterpolation(boolean[][][] mask, float x, float y, float z, int nx, int ny, int nz)
          interpolate a computation mask: the mask is true if the linear interpolant is above 0.5
static float linearMaskInterpolationValue(boolean[][][] mask, float x, float y, float z, int nx, int ny, int nz)
          interpolate a computation mask: returns the linearly interpolated value in [0,1]
static boolean maskInterpolation(boolean[][][] image, float x, float y, float z, int nx, int ny, int nz)
          interpolate a computation mask: where there is some data, the mask is set to true
static byte maximum(byte[][][] img, int nx, int ny, int nz)
          maximum value of the image
static float maximum(float[][][] img, int nx, int ny, int nz)
          maximum value of the image
static int maximum(int[][][] img, int nx, int ny, int nz)
          maximum value of the image
static float[][][] meanCurvature(float[][][] image, int nx, int ny, int nz)
          curvature estimation on a smooth distance function with no additionnal smoothing.
static byte minimum(byte[][][] img, int nx, int ny, int nz)
          minimum value of the image
static float minimum(float[][][] img, int nx, int ny, int nz)
          minimum value of the image
static int minimum(int[][][] img, int nx, int ny, int nz)
          minimum value of the image
static byte nearestNeighborInterpolation(byte[][][] image, byte zero, float x, float y, float z, int nx, int ny, int nz)
          linear interpolation, with given value outside the image
static byte nearestNeighborInterpolation(byte[][][] image, float x, float y, float z, int nx, int ny, int nz)
          linear interpolation, with 0 outside the image
static byte nearestNeighborInterpolation(byte[] image, byte zero, float x, float y, float z, int nx, int ny, int nz)
          linear interpolation, with given value outside the image
static float nearestNeighborInterpolation(float[][][] image, float x, float y, float z, int nx, int ny, int nz)
          linear interpolation, with 0 outside the image
static float[] nearestNeighborInterpolation(float[][] image, float x, float y, float z, int nx, int ny, int nz, int nd)
          linear interpolation, with given value outside the image
static int nearestNeighborInterpolation(int[][][] image, int zero, float x, float y, float z, int nx, int ny, int nz)
          linear interpolation, with given value outside the image
static float robustMaximum(float[][][] image, float ratio, int scales, int nx, int ny, int nz)
          Robust maximum estimation
static float robustMaximum(ImageData image, float ratio, int scales, int nx, int ny, int nz)
          Robust maximum estimation
static float robustMinimum(float[][][] image, float ratio, int scales, int nx, int ny, int nz)
          Robust maximum estimation
static float robustMinimum(ImageData image, float ratio, int scales, int nx, int ny, int nz)
          Robust maximum estimation
static float[][][] separableConvolution(float[][][] image, int nx, int ny, int nz, float[][] kernel, int kx, int ky, int kz)
          convolution with a separable kernel (the kernel is 3x{kx,ky,kz})
static float[][] separableGaussianKernel(float sx, float sy, float sz)
          Gaussian kernel for separable convolution
static float[][] setup3DCubicLagrangianInterpolation()
          Setup 3D cubic Lagrangian
static float[][][][] subsample(float[][][][] image, int nx, int ny, int nz, int nv, int factor)
          scale down a vector image by a factor
static float[][][] subsample(float[][][] image, int nx, int ny, int nz, int factor)
          scale down by a factor
static float[][] subsample(float[][] image, int nx, int ny, int nz, int nv, int factor)
          scale down a vector image by a factor
static float[] subsample(float[] image, int nx, int ny, int nz, int factor)
          scale down by a factor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageFunctionsPublic

public ImageFunctionsPublic()
Method Detail

minimum

public static float minimum(float[][][] img,
                            int nx,
                            int ny,
                            int nz)
minimum value of the image


maximum

public static float maximum(float[][][] img,
                            int nx,
                            int ny,
                            int nz)
maximum value of the image


minimum

public static int minimum(int[][][] img,
                          int nx,
                          int ny,
                          int nz)
minimum value of the image


maximum

public static int maximum(int[][][] img,
                          int nx,
                          int ny,
                          int nz)
maximum value of the image


minimum

public static byte minimum(byte[][][] img,
                           int nx,
                           int ny,
                           int nz)
minimum value of the image


maximum

public static byte maximum(byte[][][] img,
                           int nx,
                           int ny,
                           int nz)
maximum value of the image


computeGradientHorn

public static void computeGradientHorn(float[][][] img,
                                       float[][][] dx,
                                       float[][][] dy,
                                       float[][][] dz,
                                       int nx,
                                       int ny,
                                       int nz)
Horn-like derivatives: use a 2x2 forward square as averaging the gradient images are passed from above


computeGradient

public static void computeGradient(float[][][] img,
                                   float[][][] dx,
                                   float[][][] dy,
                                   float[][][] dz,
                                   int nx,
                                   int ny,
                                   int nz)
simple gradient (central differences)


computeHessian

public static void computeHessian(float[][][] img,
                                  float[][][][] hessian,
                                  int nx,
                                  int ny,
                                  int nz)
simple Hessian


computeHessianEigenvalues

public static void computeHessianEigenvalues(float[][][] img,
                                             float[][][][] values,
                                             int nx,
                                             int ny,
                                             int nz)
simple Hessian


computeGSTeigenvalues

public static void computeGSTeigenvalues(float[][][] img,
                                         float[][][][] values,
                                         int nx,
                                         int ny,
                                         int nz)
gradient shape tensor: return the eigenvalues at each point


convolution

public static float[][][] convolution(float[][][] image,
                                      int nx,
                                      int ny,
                                      int nz,
                                      float[][][] kernel,
                                      int kx,
                                      int ky,
                                      int kz)
convolution


separableConvolution

public static float[][][] separableConvolution(float[][][] image,
                                               int nx,
                                               int ny,
                                               int nz,
                                               float[][] kernel,
                                               int kx,
                                               int ky,
                                               int kz)
convolution with a separable kernel (the kernel is 3x{kx,ky,kz})


gaussianKernel

public static float[][][] gaussianKernel(float sx,
                                         float sy,
                                         float sz)
Gaussian kernel


separableGaussianKernel

public static float[][] separableGaussianKernel(float sx,
                                                float sy,
                                                float sz)
Gaussian kernel for separable convolution


nearestNeighborInterpolation

public static float nearestNeighborInterpolation(float[][][] image,
                                                 float x,
                                                 float y,
                                                 float z,
                                                 int nx,
                                                 int ny,
                                                 int nz)
linear interpolation, with 0 outside the image


nearestNeighborInterpolation

public static byte nearestNeighborInterpolation(byte[][][] image,
                                                float x,
                                                float y,
                                                float z,
                                                int nx,
                                                int ny,
                                                int nz)
linear interpolation, with 0 outside the image


nearestNeighborInterpolation

public static byte nearestNeighborInterpolation(byte[][][] image,
                                                byte zero,
                                                float x,
                                                float y,
                                                float z,
                                                int nx,
                                                int ny,
                                                int nz)
linear interpolation, with given value outside the image


nearestNeighborInterpolation

public static byte nearestNeighborInterpolation(byte[] image,
                                                byte zero,
                                                float x,
                                                float y,
                                                float z,
                                                int nx,
                                                int ny,
                                                int nz)
linear interpolation, with given value outside the image


nearestNeighborInterpolation

public static float[] nearestNeighborInterpolation(float[][] image,
                                                   float x,
                                                   float y,
                                                   float z,
                                                   int nx,
                                                   int ny,
                                                   int nz,
                                                   int nd)
linear interpolation, with given value outside the image


nearestNeighborInterpolation

public static int nearestNeighborInterpolation(int[][][] image,
                                               int zero,
                                               float x,
                                               float y,
                                               float z,
                                               int nx,
                                               int ny,
                                               int nz)
linear interpolation, with given value outside the image


linearInterpolation

public static float linearInterpolation(float[][][] image,
                                        float x,
                                        float y,
                                        float z,
                                        int nx,
                                        int ny,
                                        int nz)
linear interpolation, with 0 outside the image


linearInterpolation

public static float linearInterpolation(float[][][] image,
                                        float value,
                                        float x,
                                        float y,
                                        float z,
                                        int nx,
                                        int ny,
                                        int nz)
linear interpolation, with value outside the image


linearInterpolation

public static float linearInterpolation(float[] image,
                                        float value,
                                        float x,
                                        float y,
                                        float z,
                                        int nx,
                                        int ny,
                                        int nz)
linear interpolation, with value outside the image


linearInterpolation

public static float linearInterpolation(float[][][] image,
                                        boolean[][][] mask,
                                        float value,
                                        float x,
                                        float y,
                                        float z,
                                        int nx,
                                        int ny,
                                        int nz)
linear interpolation, with value outside the image and mask


linearGradientInterpolation

public static float linearGradientInterpolation(float[][][] image,
                                                float value,
                                                int dim,
                                                float x,
                                                float y,
                                                float z,
                                                int nx,
                                                int ny,
                                                int nz)
linear interpolation, with +/- value outside the image useful for interpolating gradients (suppose the gradient is +value away from the image)


linearDistanceInterpolation

public static float linearDistanceInterpolation(float[][][] image,
                                                float value,
                                                float x,
                                                float y,
                                                float z,
                                                int nx,
                                                int ny,
                                                int nz)
linear interpolation, with distance to boundary outside image


maskInterpolation

public static boolean maskInterpolation(boolean[][][] image,
                                        float x,
                                        float y,
                                        float z,
                                        int nx,
                                        int ny,
                                        int nz)
interpolate a computation mask: where there is some data, the mask is set to true


linearMaskInterpolation

public static boolean linearMaskInterpolation(boolean[][][] mask,
                                              float x,
                                              float y,
                                              float z,
                                              int nx,
                                              int ny,
                                              int nz)
interpolate a computation mask: the mask is true if the linear interpolant is above 0.5


linearMaskInterpolationValue

public static float linearMaskInterpolationValue(boolean[][][] mask,
                                                 float x,
                                                 float y,
                                                 float z,
                                                 int nx,
                                                 int ny,
                                                 int nz)
interpolate a computation mask: returns the linearly interpolated value in [0,1]


inclusiveMaskInterpolation

public static boolean inclusiveMaskInterpolation(boolean[][][] image,
                                                 float x,
                                                 float y,
                                                 float z,
                                                 int nx,
                                                 int ny,
                                                 int nz)
interpolate a computation mask: where there is some data, the mask is set to true (generates a mask that contain the transformed image)


exclusiveMaskInterpolation

public static boolean exclusiveMaskInterpolation(boolean[][][] image,
                                                 float x,
                                                 float y,
                                                 float z,
                                                 int nx,
                                                 int ny,
                                                 int nz)
interpolate a computation mask: where there is no data, the mask is set to false (generates a mask that is contained in the transformed image)


linearInterpolationXderivative

public static float linearInterpolationXderivative(float[][][] image,
                                                   float x,
                                                   float y,
                                                   float z,
                                                   int nx,
                                                   int ny,
                                                   int nz)
exact derivatives of linear interpolation


linearInterpolationYderivative

public static float linearInterpolationYderivative(float[][][] image,
                                                   float x,
                                                   float y,
                                                   float z,
                                                   int nx,
                                                   int ny,
                                                   int nz)
exact derivatives of linear interpolation


linearInterpolationZderivative

public static float linearInterpolationZderivative(float[][][] image,
                                                   float x,
                                                   float y,
                                                   float z,
                                                   int nx,
                                                   int ny,
                                                   int nz)
exact derivatives of linear interpolation


linearInterpolationXderivative

public static float linearInterpolationXderivative(float[] image,
                                                   float x,
                                                   float y,
                                                   float z,
                                                   int nx,
                                                   int ny,
                                                   int nz)
exact derivatives of linear interpolation


linearInterpolationYderivative

public static float linearInterpolationYderivative(float[] image,
                                                   float x,
                                                   float y,
                                                   float z,
                                                   int nx,
                                                   int ny,
                                                   int nz)
exact derivatives of linear interpolation


linearInterpolationZderivative

public static float linearInterpolationZderivative(float[] image,
                                                   float x,
                                                   float y,
                                                   float z,
                                                   int nx,
                                                   int ny,
                                                   int nz)
exact derivatives of linear interpolation


setup3DCubicLagrangianInterpolation

public static float[][] setup3DCubicLagrangianInterpolation()
Setup 3D cubic Lagrangian

Returns:
the cubic Lagrangian interpolation polynomial kernel

cubicLagrangianInterpolation3D

public static final float cubicLagrangianInterpolation3D(float[][][] image,
                                                         float[][] wt,
                                                         float min,
                                                         float max,
                                                         float x,
                                                         float y,
                                                         float z,
                                                         int nx,
                                                         int ny,
                                                         int nz)
3D cubic Lagrangian function

Parameters:
wt - the interpolation kernel
min - minimum threshold for interpolated image
max - maximum threshold for interpolated image
x - float point index
y - float point index
z - float point index
Returns:
the cubicLagrangian3D interpolated data point

cubicLagrangianInterpolation3D

public static final float cubicLagrangianInterpolation3D(float[][][] image,
                                                         boolean[][][] mask,
                                                         float[][] wt,
                                                         float min,
                                                         float max,
                                                         float x,
                                                         float y,
                                                         float z,
                                                         int nx,
                                                         int ny,
                                                         int nz)
3D cubic Lagrangian function

Parameters:
wt - the interpolation kernel
min - minimum threshold for interpolated image
max - maximum threshold for interpolated image
mask - boolean mask: true if the image data is to be used in the interpolation
x - float point index
y - float point index
z - float point index
Returns:
the cubicLagrangian3D interpolated data point

robustMinimum

public static final float robustMinimum(float[][][] image,
                                        float ratio,
                                        int scales,
                                        int nx,
                                        int ny,
                                        int nz)
Robust maximum estimation

Parameters:
ratio - float fraction in [0,1]: the minimum number of points below or equal to the minimum over the total volume
scales - int: the number of times the scale is refined for finding the robust minimum
Returns:
the robust minimum value

robustMinimum

public static final float robustMinimum(ImageData image,
                                        float ratio,
                                        int scales,
                                        int nx,
                                        int ny,
                                        int nz)
Robust maximum estimation

Parameters:
ratio - float fraction in [0,1]: the minimum number of points below or equal to the minimum over the total volume
scales - int: the number of times the scale is refined for finding the robust minimum
Returns:
the robust minimum value

robustMaximum

public static final float robustMaximum(float[][][] image,
                                        float ratio,
                                        int scales,
                                        int nx,
                                        int ny,
                                        int nz)
Robust maximum estimation

Parameters:
ratio - float fraction in [0,1]: the minimum number of points above or equal to the maximum over the total volume
scales - int: the number of times the scale is refined for finding the robust maximum
nx,ny,nz - image dimensions
Returns:
the robust maximum value

robustMaximum

public static final float robustMaximum(ImageData image,
                                        float ratio,
                                        int scales,
                                        int nx,
                                        int ny,
                                        int nz)
Robust maximum estimation

Parameters:
ratio - float fraction in [0,1]: the minimum number of points above or equal to the maximum over the total volume
scales - int: the number of times the scale is refined for finding the robust maximum
nx,ny,nz - image dimensions
Returns:
the robust maximum value

heatDiffusion

public static final float[][][] heatDiffusion(float[][][] image,
                                              float ratio,
                                              int steps,
                                              float dt,
                                              int nx,
                                              int ny,
                                              int nz)
GVF-style diffusion on scalar images

Parameters:
image - the original image, assumed to be in [0,1]
ratio - amount of diffusion
steps - number of diffusion steps
dt - time interval
Returns:
the diffused image

heatDiffusion

public static final float[][][] heatDiffusion(float[][][] image,
                                              float scale,
                                              float ratio,
                                              int steps,
                                              float dt,
                                              int nx,
                                              int ny,
                                              int nz)
GVF-style diffusion on scalar images

Parameters:
image - the original image
scale - maximum image value
ratio - amount of diffusion
steps - number of diffusion steps
dt - time interval
Returns:
the diffused image

meanCurvature

public static final float[][][] meanCurvature(float[][][] image,
                                              int nx,
                                              int ny,
                                              int nz)
curvature estimation on a smooth distance function with no additionnal smoothing.

Parameters:
image - the original distance image
Returns:
the diffused image

subsample

public static float[][][] subsample(float[][][] image,
                                    int nx,
                                    int ny,
                                    int nz,
                                    int factor)
scale down by a factor


subsample

public static float[] subsample(float[] image,
                                int nx,
                                int ny,
                                int nz,
                                int factor)
scale down by a factor


subsample

public static float[][][][] subsample(float[][][][] image,
                                      int nx,
                                      int ny,
                                      int nz,
                                      int nv,
                                      int factor)
scale down a vector image by a factor


subsample

public static float[][] subsample(float[][] image,
                                  int nx,
                                  int ny,
                                  int nz,
                                  int nv,
                                  int factor)
scale down a vector image by a factor