20 if (!histSize.
empty() && !ranges.empty()) {
21 if (histSize.
size() != ranges.size())
23 "HistSize must match histogram dimensionality");
25 for (
mwIndex i=0; i<ranges.size(); ++i) {
26 if (histSize[i] != (ranges[i].
size() - 1))
28 "HistSize must match non-uniform ranges");
32 else if (!histSize.
empty() && ranges.empty()) {
34 dims = histSize.
size();
38 "Channels must match histogram dimensionality");
53 nargchk(nrhs>=2 && (nrhs%2)==0 && nlhs<=1);
69 int total_channels = 0;
73 for (
int i=0; i<total_channels; ++i)
78 int dims =
static_cast<int>(ranges.
size());
81 ranges_ptr[i] = (!ranges[i].
empty() ? &ranges[i][0] : NULL);
86 histSize[i] = (!ranges[i].
empty() ? ranges[i].
size() - 1 : 0);
91 MxArray hist0(static_cast<mxArray*>(NULL));
94 for (
int i=2; i<nrhs; i+=2) {
95 string key(rhs[i].toString());
96 if (key ==
"Channels")
98 else if (key ==
"Mask")
99 mask = rhs[i+1].toMat(
CV_8U);
100 else if (key ==
"HistSize")
101 histSize = rhs[i+1].toVector<
int>();
102 else if (key ==
"Uniform")
103 uniform = rhs[i+1].toBool();
104 else if (key ==
"Hist") {
108 else if (key ==
"Sparse")
109 sparse = rhs[i+1].toBool();
112 "Unrecognized option %s", key.
c_str());
122 (!histSize.
empty() ? &histSize[0] : NULL),
123 (!ranges_ptr.
empty() ? &ranges_ptr[0] : NULL),
132 (!histSize.
empty() ? &histSize[0] : NULL),
133 (!ranges_ptr.
empty() ? &ranges_ptr[0] : NULL),
struct mxArray_tag mxArray
Forward declaration for mxArray.
int check_arguments(int dims, bool uniform, const vector< vector< float > > &ranges, const vector< int > &channels, const vector< int > &histSize)
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.
cv::SparseMat toSparseMat(int depth=CV_USRTYPE1) const
Convert double sparse MxArray to 2D single-channel cv::SparseMat.
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
Main entry called from Matlab.
cv::MatND toMatND(int depth=CV_USRTYPE1, bool transpose=true) const
Convert MxArray to a single-channel cv::Mat.
Global constant definitions.
void calcHist(const Mat *images, int nimages, const int *channels, InputArray mask, OutputArray hist, int dims, const int *histSize, const float **ranges, bool uniform=true, bool accumulate=false)