20 "Channels must match histogram dimensionality");
21 if ((!ranges.empty() || !uniform) && ranges.size() != hist_dims)
23 "Ranges must match histogram dimensionality");
28 "Ranges cannot be empty for non-uniform histogram");
35 return ((hist.
dims() > 2) ? hist.
dims() :
36 ((hist.
size(0) == 1 || hist.
size(1) == 1) ? 1 : 2));
42 return ((hist.dims > 2) ? hist.dims :
43 ((hist.rows == 1 || hist.cols == 1) ? 1 : 2));
57 nargchk(nrhs>=3 && (nrhs%2)==1 && nlhs<=1);
73 int total_channels = 0;
77 for (
int i=0; i<total_channels; ++i)
85 ranges_ptr[i] = (!ranges[i].
empty() ? &ranges[i][0] : NULL);
90 for (
int i=3; i<nrhs; i+=2) {
91 string key(rhs[i].toString());
92 if (key ==
"Channels")
94 else if (key ==
"Scale")
95 scale = rhs[i+1].toDouble();
96 else if (key ==
"Uniform")
97 uniform = rhs[i+1].toBool();
100 "Unrecognized option %s", key.
c_str());
105 if (rhs[1].isSparse()) {
110 (ranges_ptr.
empty() ? NULL : &ranges_ptr[0]), scale, uniform);
113 MatND hist(rhs[1].toMatND(
CV_32F));
117 (ranges_ptr.
empty() ? NULL : &ranges_ptr[0]), scale, uniform);
119 plhs[0] =
MxArray(backProject);
void calcBackProject(const Mat *images, int nimages, const int *channels, InputArray hist, OutputArray backProject, const float **ranges, double scale=1, bool uniform=true)
struct mxArray_tag mxArray
Forward declaration for mxArray.
void check_arguments(int hist_dims, bool uniform, const vector< vector< float > > &ranges, const vector< int > &channels)
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.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
Global constant definitions.
int histogram_dims(const MatND &hist)
determine histogram dimensionality: 1-D, 2-D, or N-D