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)

Variable Index

 o MAX_ITERATION
Maximum iterations in k-means clustering algorithm (to avoid dead loop)
Default value is 100

Constructor Index

 o PubFunc()

Method Index

 o add(float[], float[])
Add the second float vector to the first one
 o divide(float[], float)
divide float vector f1 by v
 o kmeans(float[][], int, float[], float[][], int)
k-means clustering algorithm (using weighted Euclidean distance)
The function returns k central vectors
 o mean(float[][])
Compute the mean of vectors The function returns mean vector
 o mean(Vector)
Compute the mean of vectors The function returns mean vector
 o median(float[])
Return the median value of a float array, i.e.
 o nearest(float[][], float[], float[])
Return index of the nearest vector in an array to the query one Using weighted Euclidean distance
 o quicksort(float[])
Quick sort algorithm for float array
 o quicksort(int[])
Quick sort algorithm for integer array
 o quicksort(Sortable[])
Quick sort algorithm for Sortable object array
 o randomSelect(float[][], int)
Randomly select k vectors from a data set The function returns k vectors
 o sqdist(float[], float[], float[])
Compute the squared Euclidean distance (weighted) between two float vectors
 o sqdist(float[], float[], float[], float)
Compute the squared Euclidean distance (weighted) between two float vectors

Variables

 o MAX_ITERATION
 public static int MAX_ITERATION
Maximum iterations in k-means clustering algorithm (to avoid dead loop)
Default value is 100

Constructors

 o PubFunc
 public PubFunc()

Methods

 o 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)
 o 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
 o 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
 o 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
 o 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)
 o 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)
 o 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)
 o 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
 o divide
 public static final void divide(float f1[],
                                 float v)
divide float vector f1 by v

Parameters:
f1 - the float vector
v - the divider
 o 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

 o quicksort
 public static final void quicksort(int a[])
Quick sort algorithm for integer array

 o quicksort
 public static final void quicksort(float a[])
Quick sort algorithm for float array

 o quicksort
 public static final void quicksort(Sortable a[])
Quick sort algorithm for Sortable object array


All Packages  Class Hierarchy  This Package  Previous  Next  Index