All Packages Class Hierarchy This Package Previous Next Index
Class image.PubFunc
java.lang.Object
|
+----image.PubFunc
- public class PubFunc
- extends Object
Some common image processing, clustering, sorting functions
- Author:
- Di Zhong (Columbia University)
-
MAX_ITERATION
- Maximum iterations in k-means clustering algorithm (to avoid dead loop)
Default value is 100
-
PubFunc()
-
-
add(float[], float[])
- Add the second float vector to the first one
-
divide(float[], float)
- divide float vector f1 by v
-
kmeans(float[][], int, float[], float[][], int)
- k-means clustering algorithm (using weighted Euclidean distance)
The function returns k central vectors
-
mean(float[][])
- Compute the mean of vectors
The function returns mean vector
-
mean(Vector)
- Compute the mean of vectors
The function returns mean vector
-
median(float[])
- Return the median value of a float array,
i.e.
-
nearest(float[][], float[], float[])
- Return index of the nearest vector in an array to the query one
Using weighted Euclidean distance
-
quicksort(float[])
- Quick sort algorithm for float array
-
quicksort(int[])
- Quick sort algorithm for integer array
-
quicksort(Sortable[])
- Quick sort algorithm for Sortable object array
-
randomSelect(float[][], int)
- Randomly select k vectors from a data set
The function returns k vectors
-
sqdist(float[], float[], float[])
- Compute the squared Euclidean distance (weighted) between two float vectors
-
sqdist(float[], float[], float[], float)
- Compute the squared Euclidean distance (weighted) between two float vectors
MAX_ITERATION
public static int MAX_ITERATION
- Maximum iterations in k-means clustering algorithm (to avoid dead loop)
Default value is 100
PubFunc
public PubFunc()
kmeans
public static float[][] kmeans(float data[][],
int k,
float w[],
float seed[][],
int nsamples)
- k-means clustering algorithm (using weighted Euclidean distance)
The function returns k central vectors
- Parameters:
- data - an array of feature vectors: number=data.length; dimension=data[0].length
- k - number of desired classes
- w - wighting vector (null for no-weighting)
- seed - initial k seed (central) vectors (null for random selection)
- nsamples - number of samples to be classified at each iteration (0: classify all vectors)
mean
public static final float[] mean(float data[][])
- Compute the mean of vectors
The function returns mean vector
- Parameters:
- data - an array of feature vectors: number=data.length; dimension=data[0].length
mean
public static final float[] mean(Vector data)
- Compute the mean of vectors
The function returns mean vector
- Parameters:
- data - an array of feature vectors: number=data.size(); dimension=data[0].length
randomSelect
public static final float[][] randomSelect(float data[][],
int k)
- Randomly select k vectors from a data set
The function returns k vectors
- Parameters:
- data - an array of feature vectors: number=data.length; dimension=data[0].length
- k - number of desired vectors
nearest
public static final int nearest(float data[][],
float v[],
float w[])
- Return index of the nearest vector in an array to the query one
Using weighted Euclidean distance
- Parameters:
- data - an array of feature vectors: number=data.length; dimension=data[0].length
- v - query vector
- w - weighting vector (null for no-weighting)
sqdist
public static final float sqdist(float f1[],
float f2[],
float w[])
- Compute the squared Euclidean distance (weighted) between two float vectors
- Parameters:
- f1 - the first float vector
- f2 - the second float vector
- w - the wighting vector (null for no-weighting)
sqdist
public static final float sqdist(float f1[],
float f2[],
float w[],
float th)
- Compute the squared Euclidean distance (weighted) between two float vectors
- Parameters:
- f1 - the first float vector
- f2 - the second float vector
- w - the wighting vector (null for no-weighting)
- th - if distance (squared) between f1 and f2 is larger or equal th, return 1e+20; otherwise return distance. (To speed up searhing, esp for high dimensio vector)
add
public static final void add(float f1[],
float f2[])
- Add the second float vector to the first one
- Parameters:
- f1 - the first float vector
- f2 - the second float vector
divide
public static final void divide(float f1[],
float v)
- divide float vector f1 by v
- Parameters:
- f1 - the float vector
- v - the divider
median
public static final float median(float a[])
- Return the median value of a float array,
i.e. return (a.length/2)th element after sorting
Note: original array is modified
quicksort
public static final void quicksort(int a[])
- Quick sort algorithm for integer array
quicksort
public static final void quicksort(float a[])
- Quick sort algorithm for float array
quicksort
public static final void quicksort(Sortable a[])
- Quick sort algorithm for Sortable object array
All Packages Class Hierarchy This Package Previous Next Index