VLFeat - Documentation > C API

# VLFeat.org

Documentation> C API

- Main Page
- Related Pages
- Data Structures
- Files

- File List
- Globals

Functions
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

VlIKMFilt * | vl_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

void vl_ikm_delete | ( | VlIKMFilt * | f | ) |

Parameters

  f | IKM quantizer.

vl_ikmacc_t const* vl_ikm_get_centers | ( | VlIKMFilt const * | f | ) |

Parameters

  f | IKM filter.

Returns
  maximum number of iterations.

vl_size vl_ikm_get_K | ( | VlIKMFilt const * | f | ) |

Parameters

  f | IKM filter.

Returns
  number of centers K.

vl_size vl_ikm_get_max_niters | ( | VlIKMFilt const * | f | ) |

Parameters

  f | IKM filter.

Returns
  maximum number of iterations.

vl_size vl_ikm_get_ndims | ( | VlIKMFilt const * | f | ) |

Parameters

  f | IKM filter.

Returns
  data dimensionality.

int vl_ikm_get_verbosity | ( | VlIKMFilt const * | f | ) |

Parameters

  f | IKM filter.

Returns
  verbosity level.

VlIKMFilt* vl_ikm_new | ( | int | method | ) |

Parameters

  method | Clustering 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.

void vl_ikm_push | ( | VlIKMFilt * | f,
|  | vl_uint32 * | asgn,
|  | vl_uint8 const * | data,
|  | vl_size | N
| ) |  |

Parameters

  f | IKM quantizer.
  asgn | Assignments (out).
  data | data.
  N | number 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_uint32 vl_ikm_push_one | ( | vl_ikmacc_t const * | centers,
|  | vl_uint8 const * | data,
|  | vl_size | M,
|  | vl_size | K
| ) |  |

Parameters

  centers | centers.
  data | datum to project.
  K | number of centers.
  M | dimensionality of the datum.

Returns
  the cluster index.

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

void vl_ikm_set_max_niters | ( | VlIKMFilt * | f,
|  | vl_size | max_niters
| ) |  |

Parameters

  f | IKM filter.
  max_niters | maximum number of iterations.

void vl_ikm_set_verbosity | ( | VlIKMFilt * | f,
|  | int | verb
| ) |  |

Parameters

  f | IKM filter.
  verb | verbosity level.

int vl_ikm_train | ( | VlIKMFilt * | f,
|  | vl_uint8 const * | data,
|  | vl_size | N
| ) |  |

Parameters

  f | IKM quantizer.
  data | data.
  N | number of data (N `>=` 1).

Returns
  -1 if an overflow may have occurred.