vector_aggregation
Class AbstractFeatureAggregator

java.lang.Object
  extended by vector_aggregation.AbstractFeatureAggregator
Direct Known Subclasses:
BowAggregator, VladAggregator, VladAggregatorMean, VladAggregatorWithFiltering

public abstract class AbstractFeatureAggregator
extends java.lang.Object

All methods which aggregate a set of local image descriptors should extend this abstract class.

Author:
Eleftherios Spyromitros-Xioufis

Field Summary
protected  double[][] codebook
          The codebook (centroids) used to aggregate the vectors.
protected  int descriptorLength
          The dimensionality of the local descriptors ( should be equal to the dimensionality of each centroid).
protected  int numCentroids
          The number of centroids in the codebook.
protected  int vectorLength
          The length of the generated vectors.
 
Constructor Summary
protected AbstractFeatureAggregator()
           
protected AbstractFeatureAggregator(double[][] codebook)
          The constructor.
 
Method Summary
 double[] aggregate(java.util.ArrayList<double[]> descriptors)
          This method performs some general checks before calling the aggregateInternal method which is implemented by each aggregator.
 double[] aggregate(double[][] descriptors)
          This method performs some general checks before calling the aggregateInternal method which is implemented by each aggregator.
protected abstract  double[] aggregateInternal(java.util.ArrayList<double[]> descriptors)
          This method should be overridden by all aggregators.
protected abstract  double[] aggregateInternal(double[][] descriptors)
          This method should be overridden by all aggregators.
protected  int[] computeKNearestCentroids(double[] descriptor, int k)
          Returns the indices of the k centroids which are closer to the given descriptor.
protected  int computeNearestCentroid(double[] descriptor)
          Returns the index of the centroid which is closer to the given descriptor.
protected  double[] computeNearestCentroidIndexAndDistance(double[] descriptor)
          Returns a double array which has the nearest centroid's index as the first element and the distance from this centroid as the second element.
 int getDescriptorLength()
           
 int getNumCentroids()
           
abstract  int getVectorLength()
          Should compute and return the length of the generated vector.
static double[][] readCodebookFile(java.lang.String codebookFileName, int numCentroids, int centroidLength)
          Reads the codebook from the given file and returns it as two-dimensional double array.
 void setDescriptorLength(int descriptorLength)
           
 void setNumCentroids(int numCentroids)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

codebook

protected double[][] codebook
The codebook (centroids) used to aggregate the vectors. Each centroid is stored in a different row.


numCentroids

protected int numCentroids
The number of centroids in the codebook.


vectorLength

protected int vectorLength
The length of the generated vectors.


descriptorLength

protected int descriptorLength
The dimensionality of the local descriptors ( should be equal to the dimensionality of each centroid).

Constructor Detail

AbstractFeatureAggregator

protected AbstractFeatureAggregator()

AbstractFeatureAggregator

protected AbstractFeatureAggregator(double[][] codebook)
The constructor.

Parameters:
codebook -
Method Detail

getVectorLength

public abstract int getVectorLength()
Should compute and return the length of the generated vector.

Returns:

getNumCentroids

public int getNumCentroids()

setNumCentroids

public void setNumCentroids(int numCentroids)

getDescriptorLength

public int getDescriptorLength()

setDescriptorLength

public void setDescriptorLength(int descriptorLength)

aggregate

public double[] aggregate(double[][] descriptors)
                   throws java.lang.Exception
This method performs some general checks before calling the aggregateInternal method which is implemented by each aggregator.

Parameters:
descriptors - a set of local descriptors
Returns:
a vector which aggregates the local descriptors
Throws:
java.lang.Exception

aggregateInternal

protected abstract double[] aggregateInternal(java.util.ArrayList<double[]> descriptors)
                                       throws java.lang.Exception
This method should be overridden by all aggregators.

Parameters:
descriptors -
Returns:
Throws:
java.lang.Exception

aggregate

public double[] aggregate(java.util.ArrayList<double[]> descriptors)
                   throws java.lang.Exception
This method performs some general checks before calling the aggregateInternal method which is implemented by each aggregator.

Parameters:
descriptors - a set of local descriptors
Returns:
a vector which aggregates the local descriptors
Throws:
java.lang.Exception

aggregateInternal

protected abstract double[] aggregateInternal(double[][] descriptors)
                                       throws java.lang.Exception
This method should be overridden by all aggregators.

Parameters:
descriptors -
Returns:
Throws:
java.lang.Exception

computeNearestCentroid

protected int computeNearestCentroid(double[] descriptor)
Returns the index of the centroid which is closer to the given descriptor.

Parameters:
descriptor -
Returns:

computeNearestCentroidIndexAndDistance

protected double[] computeNearestCentroidIndexAndDistance(double[] descriptor)
Returns a double array which has the nearest centroid's index as the first element and the distance from this centroid as the second element.

Parameters:
descriptor -
Returns:

computeKNearestCentroids

protected int[] computeKNearestCentroids(double[] descriptor,
                                         int k)
Returns the indices of the k centroids which are closer to the given descriptor. Can be used for soft quantization. Fast implementation with a bounded priority queue. TO DO: early stopping!

Parameters:
descriptor -
k -
Returns:

readCodebookFile

public static double[][] readCodebookFile(java.lang.String codebookFileName,
                                          int numCentroids,
                                          int centroidLength)
                                   throws java.io.IOException
Reads the codebook from the given file and returns it as two-dimensional double array.

Parameters:
codebookFileName - the name of the file containing the codebook
Throws:
java.io.IOException