views:

271

answers:

2

for example I have a binaryzation image like this alt text

I want get histogram like this! alt text how to do it use opencv.

A: 

While OpenCV does have Histogram functions, I am not sure I would bother using it in this case. It seems like all you do is split the image in a number of sections and then calculate the amount of white in it. Some kind of funky spatial histogram. I am pretty sure that no OpenCV function to do that directly exists.

So I suggest running through every pixel in each section and count the number of white pixels (and, if the regions are of different sizes, count the black pixels as well). Then it is simply a matter of drawing it which can be done easily using the rectangle drawing function. If you read the documentation you'll find it's really quite informative.

kigurai
A: 

I have done it by myself

carl