29 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=3);
39 for (
int i=2; i<nrhs; i+=2) {
40 string key(rhs[i].toString());
41 if (key ==
"InitialLabels") {
42 bestLabels = rhs[i+1].toMat(
CV_32S);
45 else if (key ==
"Criteria")
46 criteria = rhs[i+1].toTermCriteria();
47 else if (key ==
"Attempts")
48 attempts = rhs[i+1].toInt();
49 else if (key ==
"Initialization")
53 "Unrecognized option %s", key.
c_str());
58 int K = rhs[1].toInt();
59 double compactness =
kmeans(data, K, bestLabels, criteria, attempts,
60 flags, (nlhs>1 ? centers :
noArray()));
KMEANS_USE_INITIAL_LABELS
double kmeans(InputArray data, int K, InputOutputArray bestLabels, TermCriteria criteria, int attempts, int flags, OutputArray centers=noArray())
const ConstMap< string, int > Initialization
KMeans initalization types for option processing.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
struct mxArray_tag mxArray
Forward declaration for mxArray.
InputOutputArray noArray()
LIBMWMEX_API_EXTERN_C void mexErrMsgIdAndTxt(const char *identifier, const char *err_msg,...)
Issue formatted error message with corresponding error identifier and return to MATLAB prompt...
mxArray object wrapper for data conversion and manipulation.
void nargchk(bool cond)
Alias for input/output arguments number check.
Global constant definitions.
std::map wrapper with one-line initialization and lookup method.