- Author
- David Novotny
-
Andrea Vedaldi
vlad.h implements the Vector of Linearly Aggregated Descriptors (VLAD) image representation [11] [2] .
Getting started with VLAD demonstreates how to use the C API to compute the VLAD representation of an image. For further details on the VLAD image representation refer to:
Getting started with VLAD
The VLAD encoding of a set of features is obtained by using the function vl_vlad_encode. The function can be applied to both float
or double
data types.
vl_vlad_encode requires a visual dictionary, for example obtained by using K-means clustering. Furthermore, the assignments of features to dictionary elements must be pre-computed, for example by using KD-trees and forests.
In the following example code, the vocabulary is first created using the KMeans clustering, then the points, that are to be encoded are assigned to its corresponding nearest vocabulary words, after that the original vlad encoding routine without any normalization option takes place. At the end of the process the encoding is stored in the enc
variable.
float * assignments;
float * enc
int i;
data,
dimension,
numData,
numCenters) ;
assignments =
vl_malloc(
sizeof(
float) * numDataToEncode * numCenters);
memset(assignments, 0, sizeof(float) * numDataToEncode * numCenters);
for(i = 0; i < numDataToEncode; i++) {
assignments[i * numCenters + indexes[i]] = 1.;
}
enc =
vl_malloc(
sizeof(TYPE) * dimension * numCenters);
data, numData,
assignments,
0) ;
void * vl_malloc(size_t n)
Allocate a memory block.
Definition: generic.c:1312
#define VL_TYPE_FLOAT
Definition: generic.h:35
int unsigned vl_uint32
Unsigned 32-bit integer.
Definition: host.h:382
void vl_kmeans_quantize(VlKMeans *self, vl_uint32 *assignments, void *distances, void const *data, vl_size numData)
Quantize data.
Definition: kmeans.c:1912
double vl_kmeans_cluster(VlKMeans *self, void const *data, vl_size dimension, vl_size numData, vl_size numCenters)
Cluster data.
Definition: kmeans.c:2028
VlKMeans * vl_kmeans_new(vl_type dataType, VlVectorComparisonType distance)
Create a new KMeans object.
Definition: kmeans.c:406
void const * vl_kmeans_get_centers(VlKMeans const *self)
Get centers.
Definition: kmeans.h:252
void vl_vlad_encode(void *enc, vl_type dataType, void const *means, vl_size dimension, vl_size numClusters, void const *data, vl_size numData, void const *assignments, int flags)
VLAD encoding of a set of vectors.
Definition: vlad.c:293
Various VLAD normalization normalizations can be applied to the VLAD vectors. These are controlled by the parameter flag of vl_vlad_encode.