Ask Your Question

Revision history [back]

You could use [calcHist](http://docs.opencv.org/modules/imgproc/doc/histograms.html?highlight=calchist#void calcHist(const Mat* images, int nimages, const int* channels, InputArray mask, OutputArray hist, int dims, const int* histSize, const float** ranges, bool uniform, bool accumulate) or you could just count how many 0, 1 and 2 you have in each image. You will have a 3D vector, that you should probably normalize by the size of elements. I'm not a Java specialist, but in C++ I will do it with std::count. Or, if you want to make it in one image process, create a vector of size 3, initialize all elements to 0, and for each element of your mat, add 1 to the right vector cell (and normalize at the end).