Ask Your Question
1

Printing a Histogram

asked 2013-04-03 19:39:14 -0600

Pedro gravatar image

updated 2013-04-03 19:41:11 -0600

Hello. I´m trying to print a histogram using opencv in Java. I already calculated the histogram using this function calcHist(List<mat> images, MatOfInt channels, Mat mask, Mat hist, MatOfInt histSize, MatOfFloat ranges) , but I don´t know how to print the histogram(like a graphic).I readed a tutorial in C++ , but this didn´t help me in Java.

Thank you.

Tutorial that I readed in C++ : http://docs.opencv.org/doc/tutorials/imgproc/histograms/histogram_calculation/histogram_calculation.html

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted
1

answered 2013-04-04 02:25:03 -0600

Basically you need to think about how a histogram is built up. You can see it as towers of pixels indicating the amount in each bin.

So what I would do is, create an image with heigth larger than the largest bin height. As width you assign amountofbins10 + amountofbin2. This gives you the ability to create vertical rows of 10 bits wide and leave 2 bits between each row.

Than simply create a binary mask simulating your data. Add 1's for the elements that need to be coloured, add 0 for items that need to be background.

It would look something like this:

image description

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-04-03 19:39:14 -0600

Seen: 650 times

Last updated: Apr 04 '13