Pietro Beraldini
Pietro Beraldini

Reputation: 11

Histogram of image with opencv in java

I need to compare histogram of video's frame to detect scene changes. I have tried to use the method calcHist of the library Imgproc of opencv 3.1.0 with these parameters as suggested in another question (I'm working in Eclipse with Java):

Imgproc.calcHist(matList,new MatOfInt(0),new Mat(),histogram,new MatOfInt(25),ranges);

Someone can explain me the meaning of all parameters? It compile but I don't understand the meaning of the output, for example:

Histogram frame 0=[684213;291263;126683;78313;50989;30860;93541;76835;154938;55532;38304;93131;479949345;34612;34889;39014;25014;13223;14521;9534;5310;3310;2650;19581]

what's the meaning of this? how can I plot the histogram? thank you very much

Upvotes: 1

Views: 5804

Answers (1)

Piglet
Piglet

Reputation: 28940

For a detailed parameter description please refer to: http://docs.opencv.org/3.1.0/d6/dc7/group__imgproc__hist.html#ga4b2b5fd75503ff9e6844cc4dcdaed35d You can apply the C++ description to Java (just look at the names, translate types and such to Java. I'm sure a parameter int number will make sense in Java as well :)

Your function call

Imgproc.calcHist(matList,new MatOfInt(0),new Mat(),histogram,new MatOfInt(25),ranges);

Will calculate a Histogram for images in matList. No pixels will be ignored (empty mask). We will only consider channel 0. The Histogram has 25 bins. Your range input I don't know.

The result you get is a Histogram with 25 bins. The values are the histogram values for each bin.

I assume you have no idea what a histogram is. So I recommend reading something about it. (At least wikipedia)

And please read this: http://docs.opencv.org/3.1.0/d1/db7/tutorial_py_histogram_begins.html#gsc.tab=0

Please also see this website: www.google.com

Here you can enter key words and they will find information to it. Give it a try. Enter: Plot Histogram OpenCV

Upvotes: 4

Related Questions