C API

hikmeans.c File Reference


Detailed Description

Author:
Brian Fulkerson

Andrea Vedaldi

Definition in file hikmeans.c.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "hikmeans.h"

Go to the source code of this file.


Functions

vl_uint8vl_hikm_copy_subset (vl_uint8 const *data, vl_uint *ids, int N, int M, vl_uint id, int *N2)
 Copy a subset of the data to a buffer.
static VlHIKMNodexmeans (VlHIKMTree *tree, vl_uint8 const *data, int N, int K, int height)
 Compute HIKM clustering.
static void xdelete (VlHIKMNode *node)
 Delete node.
VL_EXPORT VlHIKMTreevl_hikm_new (int method)
 New HIKM tree.
VL_EXPORT void vl_hikm_delete (VlHIKMTree *f)
 Delete HIKM tree.
VL_EXPORT void vl_hikm_init (VlHIKMTree *f, int M, int K, int depth)
 Initialize HIKM tree.
VL_EXPORT void vl_hikm_train (VlHIKMTree *f, vl_uint8 const *data, int N)
 Train HIKM tree.
VL_EXPORT void vl_hikm_push (VlHIKMTree *f, vl_uint *asgn, vl_uint8 const *data, int N)
 Project data down HIKM tree.

Function Documentation

vl_uint8* vl_hikm_copy_subset ( vl_uint8 const *  data,
vl_uint ids,
int  N,
int  M,
vl_uint  id,
int *  N2 
)

For internal use only.

Parameters:
data Data
ids Data labels
N Number of indices
M Data dimensionality
id Label of data to copy
N2 Number of data copied (out)
Returns:
a new buffer with a copy of the selected data.

Definition at line 50 of file hikmeans.c.

References vl_malloc().

Referenced by xmeans().

VL_EXPORT void vl_hikm_delete ( VlHIKMTree f  ) 

Parameters:
f HIKM tree.

Definition at line 195 of file hikmeans.c.

References vl_free(), and xdelete().

VL_EXPORT void vl_hikm_init ( VlHIKMTree f,
int  M,
int  K,
int  depth 
)

Parameters:
f HIKM tree.
M Data dimensionality.
K Number of clusters per node.
depth Tree depth.
Remarks:
depth cannot be smaller than 1.
Returns:
a new HIKM tree representing the clustering.

Definition at line 218 of file hikmeans.c.

References xdelete().

VL_EXPORT VlHIKMTree* vl_hikm_new ( int  method  ) 

Parameters:
method clustering method.
Returns:
new HIKM tree.

Definition at line 175 of file hikmeans.c.

References vl_malloc().

VL_EXPORT void vl_hikm_push ( VlHIKMTree f,
vl_uint asgn,
vl_uint8 const *  data,
int  N 
)

Parameters:
f HIKM tree.
asgn Path down the tree (out).
data Data to project.
N Number of data.
The function writes to asgn the path of the data data down the HIKM tree f. The parameter asgn must point to an array of M by N elements, where M is the depth of the HIKM tree and N is the number of data point to process.

Definition at line 262 of file hikmeans.c.

References _VlHIKMNode::children, _VlHIKMNode::filter, _VlHIKMTree::root, vl_hikm_get_depth(), vl_hikm_get_ndims(), and vl_ikm_push().

VL_EXPORT void vl_hikm_train ( VlHIKMTree f,
vl_uint8 const *  data,
int  N 
)

Parameters:
f HIKM tree.
data Data to cluster.
N Number of data.

Definition at line 241 of file hikmeans.c.

References _VlHIKMTree::depth, _VlHIKMTree::K, VL_MIN, and xmeans().

static void xdelete ( VlHIKMNode node  )  [static]

For internal use only.

Parameters:
node to delete.
The function deletes recursively node and all its descendent.

Definition at line 152 of file hikmeans.c.

References _VlHIKMNode::children, _VlHIKMNode::filter, vl_free(), vl_ikm_delete(), and vl_ikm_get_K().

Referenced by vl_hikm_delete(), and vl_hikm_init().

static VlHIKMNode* xmeans ( VlHIKMTree tree,
vl_uint8 const *  data,
int  N,
int  K,
int  height 
) [static]

Parameters:
tree HIKM tree to initialize.
data Data to cluster.
N Number of data points.
K Number of clusters for this node.
height Tree height.
Remarks:
height cannot be smaller than 1.
Returns:
a new HIKM node representing a sub-clustering.

Definition at line 96 of file hikmeans.c.

References _VlHIKMNode::children, _VlHIKMTree::depth, _VlHIKMNode::filter, _VlHIKMTree::M, _VlHIKMTree::max_niters, _VlHIKMTree::verb, vl_free(), vl_hikm_copy_subset(), vl_ikm_init_rand_data(), vl_ikm_new(), vl_ikm_push(), vl_ikm_set_max_niters(), vl_ikm_set_verbosity(), vl_ikm_train(), vl_malloc(), VL_MIN, and VL_PRINTF.

Referenced by vl_hikm_train().