Documentation>C API
ikmeans.c File Reference

Integer K-Means clustering - Definition. More...

#include "ikmeans.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "assert.h"
#include "ikmeans_init.tc"
#include "ikmeans_lloyd.tc"
#include "ikmeans_elkan.tc"

Functions

VlIKMFiltvl_ikm_new (int method)
 Create a new IKM quantizer. More...
 
void vl_ikm_delete (VlIKMFilt *f)
 Delete IKM quantizer. More...
 
int vl_ikm_train (VlIKMFilt *f, vl_uint8 const *data, vl_size N)
 Train clusters. More...
 
void vl_ikm_push (VlIKMFilt *f, vl_uint32 *asgn, vl_uint8 const *data, vl_size N)
 Project data to clusters. More...
 
vl_uint32 vl_ikm_push_one (vl_ikmacc_t const *centers, vl_uint8 const *data, vl_size M, vl_size K)
 Project one datum to clusters. More...
 
vl_size vl_ikm_get_ndims (VlIKMFilt const *f)
 Get data dimensionality. More...
 
vl_size vl_ikm_get_K (VlIKMFilt const *f)
 Get the number of centers K. More...
 
int vl_ikm_get_verbosity (VlIKMFilt const *f)
 Get verbosity level. More...
 
vl_size vl_ikm_get_max_niters (VlIKMFilt const *f)
 Get maximum number of iterations. More...
 
vl_ikmacc_t const * vl_ikm_get_centers (VlIKMFilt const *f)
 Get maximum number of iterations. More...
 
void vl_ikm_set_verbosity (VlIKMFilt *f, int verb)
 Set verbosity level. More...
 
void vl_ikm_set_max_niters (VlIKMFilt *f, vl_size max_niters)
 Set maximum number of iterations. More...
 

Detailed Description

Author
Brian Fulkerson
Andrea Vedaldi

Function Documentation

◆ vl_ikm_delete()

void vl_ikm_delete ( VlIKMFilt f)
Parameters
fIKM quantizer.

◆ vl_ikm_get_centers()

vl_ikmacc_t const* vl_ikm_get_centers ( VlIKMFilt const *  f)
Parameters
fIKM filter.
Returns
maximum number of iterations.

◆ vl_ikm_get_K()

vl_size vl_ikm_get_K ( VlIKMFilt const *  f)
Parameters
fIKM filter.
Returns
number of centers K.

◆ vl_ikm_get_max_niters()

vl_size vl_ikm_get_max_niters ( VlIKMFilt const *  f)
Parameters
fIKM filter.
Returns
maximum number of iterations.

◆ vl_ikm_get_ndims()

vl_size vl_ikm_get_ndims ( VlIKMFilt const *  f)
Parameters
fIKM filter.
Returns
data dimensionality.

◆ vl_ikm_get_verbosity()

int vl_ikm_get_verbosity ( VlIKMFilt const *  f)
Parameters
fIKM filter.
Returns
verbosity level.

◆ vl_ikm_new()

VlIKMFilt* vl_ikm_new ( int  method)
Parameters
methodClustering algorithm.
Returns
new IKM quantizer.

The function allocates initializes a new IKM quantizer to operate based algorithm method.

method has values in the enumerations VlIKMAlgorithms.

◆ vl_ikm_push()

void vl_ikm_push ( VlIKMFilt f,
vl_uint32 asgn,
vl_uint8 const *  data,
vl_size  N 
)
Parameters
fIKM quantizer.
asgnAssignments (out).
datadata.
Nnumber of data (N >= 1).

The function projects the data data on the integer K-means clusters specified by the IKM quantizer f. Notice that the quantizer must be initialized.

◆ vl_ikm_push_one()

vl_uint32 vl_ikm_push_one ( vl_ikmacc_t const *  centers,
vl_uint8 const *  data,
vl_size  M,
vl_size  K 
)
Parameters
centerscenters.
datadatum to project.
Knumber of centers.
Mdimensionality of the datum.
Returns
the cluster index.

The function projects the specified datum data on the clusters specified by the centers centers.

◆ vl_ikm_set_max_niters()

void vl_ikm_set_max_niters ( VlIKMFilt f,
vl_size  max_niters 
)
Parameters
fIKM filter.
max_nitersmaximum number of iterations.

◆ vl_ikm_set_verbosity()

void vl_ikm_set_verbosity ( VlIKMFilt f,
int  verb 
)
Parameters
fIKM filter.
verbverbosity level.

◆ vl_ikm_train()

int vl_ikm_train ( VlIKMFilt f,
vl_uint8 const *  data,
vl_size  N 
)
Parameters
fIKM quantizer.
datadata.
Nnumber of data (N >= 1).
Returns
-1 if an overflow may have occurred.