How to access 3D histogram data - OpenCV Java
I am writing a java program to calculate a 3-Dimensional histogram of R,G,B channels. I am unable to find out how to access the resulting 3 dimensional histogram (the Mat object which represents the histogram). My code is like below -
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat sourceMat = Highgui.imread(args[0]);
List<Mat> sourceImages = new Vector<Mat>();
sourceImages.add(sourceMat);
Mat histogram = new Mat();
MatOfInt histSizes = new MatOfInt(10,10,10);
MatOfFloat histRanges = new MatOfFloat(0,256,0,256,0,256);
MatOfInt channels = new MatOfInt(0,1,2);
Imgproc.calcHist(sourceImages,channels,new Mat(), histogram, histSizes, histRanges);
the above calcHist method runs and returns the histogram (which is basically a Mat object) which has 3 dimensions and 1000 (10x10x10) total values.
The question is how to access this histogram? Rows and Colums return -1 (as expected for a 3D Mat). Can someone help?