math
Class Mat2

java.lang.Object
  extended by math.Mat2
Direct Known Subclasses:
MatFloat

public abstract class Mat2
extends java.lang.Object


Constructor Summary
Mat2()
           
 
Method Summary
static void add(float[][] c, int i)
           
static void add(short[][] c, int i)
          c = c + i
static short[][] cat(short[][] a, short[][] b)
          Concatenate a and b to obtain a new matrix.
static short clip(short i)
           
static short[][] clip(short[][] i)
           
static int[][] copy(int[][] r)
           
static short[][] copy(short[][] r)
           
static short[][] copyArray(short[][] a)
           
static boolean equal(short[][] a, short[][] b)
           
static float[] get1d(float[][] f)
          Convert a 2D array into a 1D array
static float[][] get2d(float[] f, int width, int height)
          Convert a 1D array into a 2D array
static double getAverage(double[][] a)
          Compute the avg value of the array.
static double[] getAverage(double[] a, double[] b, double[] c)
           
static double getAverage(float[][] a)
          Compute the avg value of the array.
static double getAverage(short[][] a)
          Compute the avg value of the array.
static float[][] getAverageFloat(int r, int c)
           
static double getGeometricMean(short[][] a)
           
static short[][] getIdentity(int r, int c)
           
static double[][] getIdentityDouble(int r, int c)
           
static float[][] getIdentityFloat(int r, int c)
           
static int[][] getInt2(int[] pels, int width, int height)
           
static float[][] getLocalImage(float[][] r, int uu, int vv, int w, int h)
           
static float getMax(float[][] array)
           
static float getMax(float[][] rcorr, float[][] gcorr, float[][] bcorr)
           
static short getMax(short[][] a)
           
static short getMin(short[][] k)
           
static short[][] getSampleSquareMatrix(int n)
           
static short[][] getShort(byte[][] a)
           
static short[][] getShort(short[][] a)
           
static double getStandardDeviation(float[][] a)
           
static double getStandardDeviation(short[][] a)
          Compute the Standard Deviation of the array.
static double getSum(double[][] a)
           
static double getSum(float[][] a)
           
static double getSum(short[][] a)
           
static double getVariance(float[][] a)
           
static double getVariance(short[][] a)
           
static short[][] grow(short[][] in, java.awt.Dimension dimension, int borderType)
           
static void main(java.lang.String[] args)
           
static double mean(short[][] a)
           
static short median(java.util.Vector v)
           
static float[][] multiply(float[][] f, float r1)
           
static void multiply(short[][] r, short[][] r1)
          r = r * r1; This is a 4x4X4x4 giving a 4x4.
static void normalize(double[][] a)
           
static void normalize(float[][] a)
           
static float[][] normalize(short[][] a)
           
static int numberOfNonZeros(short[][] k)
           
static void print(double[][] a)
           
static void print(float[][] a)
           
static void print(int[][] a)
           
static void print(short[][] a)
           
static void printArray(double[][] k, java.lang.String name)
           
static void printKernel(double[][] k, java.lang.String name)
           
static void printKernel(float[][] k, java.lang.String name)
           
static void printKernel(short[][] k, java.lang.String name)
           
static void printMaple(float[][] a)
           
static void printMaple(short[][] a)
           
static void printMedian(int[][] k, java.lang.String name)
           
static void printMedian(short[][] k, java.lang.String name)
           
static void printStats(float[][] a)
           
static void printStats(java.lang.String title, float[][] a)
           
static short[][] quadSwap(short[][] r)
          Centers the image by translating the image to the center.
static void removeTheDcComponent(float[][] r)
          Compute the average and remove it from the input 2D mat.
static void removeTheDcComponent(short[][] r)
          Compute the average and remove it from the input 2D mat.
static short[][] resample(short[][] a, int ratio)
           
static void scale(double[][] a, double k)
           
static void scale(float[][] a, double k)
           
static void scale(float[][] a, float k)
           
static float[][] scale(short[][] a, float k)
           
static short[][] scale(short[][] a, short k)
           
static float[][] shortMatrixToFloat(short[][] sm)
           
static float[][] shortToFloat(short[][] a)
           
static short[][] subtract(short[][] a, short[][] b)
          c = a - b
static float[][] subtractMean(float[][] r, int uu, int vv, int w, int h)
           
static void testQuickSort()
           
static void threshold(short[][] a)
           
static void threshold(short[][] a, short thresh)
           
static boolean[][] transpose(boolean[][] src)
           
static byte[][] transpose(byte[][] src)
          returns the Transposition of a 2-D byte matrix of any size.
static char[][] transpose(char[][] src)
          returns the Transposition of a 2-D char matrix of any size.
static double[][] transpose(double[][] src)
          returns the Transposition of a 2-D double matrix of any size.
static float[][] transpose(float[][] src)
          returns the Transposition of a 2-D float matrix of any size.
static int[][] transpose(int[][] src)
          returns the Transposition of a 2-D int matrix of any size.
static long[][] transpose(long[][] src)
          returns the Transposition of a 2-D long matrix of any size.
static java.lang.Object[][] transpose(java.lang.Object[][] src)
          returns the Transposition of a 2-D Object matrix of any size.
static short[][] transpose(short[][] src)
          returns the Transposition of a 2-D short matrix of any size.
static java.lang.String[][] transpose(java.lang.String[][] src)
          returns the Transposition of a 2-D String matrix of any size.
static double variance(short[][] a)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mat2

public Mat2()
Method Detail

equal

public static boolean equal(short[][] a,
                            short[][] b)
Parameters:
a - must be the same size as b
b - must be the same size as a
Returns:
true if equal

getSampleSquareMatrix

public static short[][] getSampleSquareMatrix(int n)

getGeometricMean

public static double getGeometricMean(short[][] a)

print

public static void print(double[][] a)

printStats

public static void printStats(java.lang.String title,
                              float[][] a)

printStats

public static void printStats(float[][] a)

print

public static void print(float[][] a)

print

public static void print(int[][] a)

getMin

public static short getMin(short[][] k)

getMax

public static short getMax(short[][] a)

print

public static void print(short[][] a)

getSum

public static double getSum(double[][] a)

getSum

public static double getSum(float[][] a)
Parameters:
a - 2D array of float
Returns:
a sum of all the values in a.

getSum

public static double getSum(short[][] a)
Parameters:
a - two dim array of shorts
Returns:
the sum of all the values in a.

getShort

public static short[][] getShort(byte[][] a)

getShort

public static short[][] getShort(short[][] a)

clip

public static short clip(short i)

clip

public static short[][] clip(short[][] i)

normalize

public static void normalize(double[][] a)

normalize

public static float[][] normalize(short[][] a)

normalize

public static void normalize(float[][] a)

getAverage

public static double getAverage(double[][] a)
Compute the avg value of the array.

Parameters:
a - rectangular array
Returns:
the average.

getAverage

public static double getAverage(float[][] a)
Compute the avg value of the array.

Parameters:
a - rectangular array
Returns:
the average.

getAverage

public static double getAverage(short[][] a)
Compute the avg value of the array.

Parameters:
a - rectangular array
Returns:
the average.

getStandardDeviation

public static double getStandardDeviation(short[][] a)
Compute the Standard Deviation of the array.

Parameters:
a - rectangular array
Returns:
the average.

threshold

public static void threshold(short[][] a,
                             short thresh)

threshold

public static void threshold(short[][] a)

printKernel

public static void printKernel(float[][] k,
                               java.lang.String name)

printArray

public static void printArray(double[][] k,
                              java.lang.String name)

printKernel

public static void printKernel(double[][] k,
                               java.lang.String name)

printKernel

public static void printKernel(short[][] k,
                               java.lang.String name)

transpose

public static double[][] transpose(double[][] src)
returns the Transposition of a 2-D double matrix of any size. If you supply a matrix of size AxB, the return's size will be BxA.

Parameters:
src - : the source array
Returns:
a 2-D double array

scale

public static float[][] scale(short[][] a,
                              float k)

scale

public static short[][] scale(short[][] a,
                              short k)

scale

public static void scale(double[][] a,
                         double k)

scale

public static void scale(float[][] a,
                         float k)

scale

public static void scale(float[][] a,
                         double k)

shortToFloat

public static float[][] shortToFloat(short[][] a)

copyArray

public static short[][] copyArray(short[][] a)

getStandardDeviation

public static double getStandardDeviation(float[][] a)

getVariance

public static double getVariance(float[][] a)

getVariance

public static double getVariance(short[][] a)

getAverage

public static double[] getAverage(double[] a,
                                  double[] b,
                                  double[] c)

copy

public static short[][] copy(short[][] r)

median

public static short median(java.util.Vector v)

testQuickSort

public static void testQuickSort()

numberOfNonZeros

public static int numberOfNonZeros(short[][] k)

printMedian

public static void printMedian(short[][] k,
                               java.lang.String name)

printMaple

public static void printMaple(short[][] a)

printMaple

public static void printMaple(float[][] a)

subtract

public static short[][] subtract(short[][] a,
                                 short[][] b)
c = a - b

Parameters:
a - a 2d array of short, possibly from a shortImageBean
b - another 2d array of short
Returns:
new 2d array of short

resample

public static short[][] resample(short[][] a,
                                 int ratio)

transpose

public static boolean[][] transpose(boolean[][] src)

transpose

public static byte[][] transpose(byte[][] src)
returns the Transposition of a 2-D byte matrix of any size. If you supply a matrix of size AxB, the return's size will be BxA.

Parameters:
src - : the source array
Returns:
a 2-D byte array
See Also:
transpose(Object[][])

transpose

public static short[][] transpose(short[][] src)
returns the Transposition of a 2-D short matrix of any size. If you supply a matrix of size AxB, the return's size will be BxA.

Parameters:
src - : the source array
Returns:
a 2-D short array
See Also:
transpose(Object[][])

transpose

public static int[][] transpose(int[][] src)
returns the Transposition of a 2-D int matrix of any size. If you supply a matrix of size AxB, the return's size will be BxA.

Parameters:
src - : the source array
Returns:
a 2-D int array
See Also:
transpose(Object[][])

transpose

public static long[][] transpose(long[][] src)
returns the Transposition of a 2-D long matrix of any size. If you supply a matrix of size AxB, the return's size will be BxA.

Parameters:
src - : the source array
Returns:
a 2-D long array
See Also:
transpose(Object[][])

transpose

public static float[][] transpose(float[][] src)
returns the Transposition of a 2-D float matrix of any size. If you supply a matrix of size AxB, the return's size will be BxA.

Parameters:
src - : the source array
Returns:
a 2-D float array
See Also:
transpose(Object[][])

transpose

public static char[][] transpose(char[][] src)
returns the Transposition of a 2-D char matrix of any size. If you supply a matrix of size AxB, the return's size will be BxA.

Parameters:
src - : the source array
Returns:
a 2-D char array
See Also:
transpose(Object[][]), transpose(String[][])

transpose

public static java.lang.String[][] transpose(java.lang.String[][] src)
returns the Transposition of a 2-D String matrix of any size. If you supply a matrix of size AxB, the return's size will be BxA.

Parameters:
src - : the source array
Returns:
a 2-D String array
See Also:
transpose(Object[][]), transpose(char[][])

transpose

public static java.lang.Object[][] transpose(java.lang.Object[][] src)
returns the Transposition of a 2-D Object matrix of any size. You can use this for any descendants of the Object class, like data sets and GUI-Components You can also use this if you enclosed your primitive datatypes in Wrapper-classes like Integer and Double, but i think using the generic types will be faster (not only for this, but any math operation, like what you probably do when you transpose number matrixes) If you supply a matrix of size AxB, the return's size will be BxA.

Parameters:
src - : the source array
Returns:
a 2-D Object array. use cast to get back your original Class type.

grow

public static short[][] grow(short[][] in,
                             java.awt.Dimension dimension,
                             int borderType)

getIdentity

public static short[][] getIdentity(int r,
                                    int c)

getIdentityDouble

public static double[][] getIdentityDouble(int r,
                                           int c)

getIdentityFloat

public static float[][] getIdentityFloat(int r,
                                         int c)

getAverageFloat

public static float[][] getAverageFloat(int r,
                                        int c)

getInt2

public static int[][] getInt2(int[] pels,
                              int width,
                              int height)

quadSwap

public static short[][] quadSwap(short[][] r)
Centers the image by translating the image to the center. This can be done via a phase shift in the frequency domain, but I think this is pretty fast (using JAI, etc.).
q1 q2 q3 q4 becomes: q4 q3 q2 q1 QuadSwap destroys its argument.

Parameters:
r - 2D array of short, perhaps the output of an fft needing a quad swap
Returns:
new 2D array of short with the quads swaped

removeTheDcComponent

public static void removeTheDcComponent(short[][] r)
Compute the average and remove it from the input 2D mat.

Parameters:
r - non-negative array of shorts.

removeTheDcComponent

public static void removeTheDcComponent(float[][] r)
Compute the average and remove it from the input 2D mat.

Parameters:
r - non-negative array of shorts.

multiply

public static void multiply(short[][] r,
                            short[][] r1)
r = r * r1; This is a 4x4X4x4 giving a 4x4. IT IS NOT a general matrix multiple

Parameters:
r - 2d short array, changed as a side effect of the invocation
r1 - 2d short array, used as the object of the multiply.

add

public static void add(float[][] c,
                       int i)

add

public static void add(short[][] c,
                       int i)
c = c + i

Parameters:
c - is altered as a side effect
i - is the offset

mean

public static double mean(short[][] a)

variance

public static double variance(short[][] a)

copy

public static int[][] copy(int[][] r)

printMedian

public static void printMedian(int[][] k,
                               java.lang.String name)

shortMatrixToFloat

public static float[][] shortMatrixToFloat(short[][] sm)

getMax

public static float getMax(float[][] array)

getMax

public static float getMax(float[][] rcorr,
                           float[][] gcorr,
                           float[][] bcorr)

subtractMean

public static float[][] subtractMean(float[][] r,
                                     int uu,
                                     int vv,
                                     int w,
                                     int h)

getLocalImage

public static float[][] getLocalImage(float[][] r,
                                      int uu,
                                      int vv,
                                      int w,
                                      int h)

multiply

public static float[][] multiply(float[][] f,
                                 float r1)

get1d

public static float[] get1d(float[][] f)
Convert a 2D array into a 1D array

Parameters:
f - an array of width and height dimension
Returns:
a new array of width*height in length.

get2d

public static float[][] get2d(float[] f,
                              int width,
                              int height)
Convert a 1D array into a 2D array

Parameters:
f - the input 1D array
width - width of the output array
height - height of the output array
Returns:
new array of width and height dimension

cat

public static short[][] cat(short[][] a,
                            short[][] b)
Concatenate a and b to obtain a new matrix. Matrix a and b have the same number of rows.

Parameters:
a - is the same number of rows in each column
b - is the same number of rows in each column
Returns:
c so that it is [a|b]

main

public static void main(java.lang.String[] args)