OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Wed, 14 Nov 2012 07:08:27 -0600Calculate histogram along linehttp://answers.opencv.org/question/4173/calculate-histogram-along-line/Hi,
I have a binary image and I would like to determine the amount of white pixels along different angles. Let`s say the starting Point (F) is at the middle of the bottom row. Based on this 0° means all white pixels to the right of F and 180° means all white pixels to the left of F in the bottom row. So at the end I would like to have a histogram with x-axis holding the angle (from 0 to 180) and y-axis the number of white pixels.
Is this possible with the OpenCV calcHistogram function? Or do you have any idea how to do this efficiently?
Hope you understand the problem since I`m not allowed(?) to attach images here.
Thank you.
Wed, 14 Nov 2012 06:07:21 -0600http://answers.opencv.org/question/4173/calculate-histogram-along-line/Answer by Michael Burdinov for <p>Hi,</p>
<p>I have a binary image and I would like to determine the amount of white pixels along different angles. Let`s say the starting Point (F) is at the middle of the bottom row. Based on this 0° means all white pixels to the right of F and 180° means all white pixels to the left of F in the bottom row. So at the end I would like to have a histogram with x-axis holding the angle (from 0 to 180) and y-axis the number of white pixels.</p>
<p>Is this possible with the OpenCV calcHistogram function? Or do you have any idea how to do this efficiently?</p>
<p>Hope you understand the problem since I`m not allowed(?) to attach images here.</p>
<p>Thank you.</p>
http://answers.opencv.org/question/4173/calculate-histogram-along-line/?answer=4179#post-id-4179calcHistogram won't help you to collect histograms at angles different from 0 and 180, so I guess you will have to write your own loop to collect those histograms. I think use of [LineIterator](http://docs.opencv.org/modules/core/doc/drawing_functions.html?highlight=lineiterat#LineIterator) will help you to implement those loops.Wed, 14 Nov 2012 07:08:27 -0600http://answers.opencv.org/question/4173/calculate-histogram-along-line/?answer=4179#post-id-4179