I have a data set of paired values like (x,y). For example: x ranges from -40 to 60 and y from 0 to 100. Initially they are stored in a std::vector<std::pair<float,float>> but in a loop I convert them to a 2 channel cv::Mat to be able to pass it to OpenCV's cv::calcHist function. I'd like to achieve a 1D histogram like so: here. Since I actually have two data ranges, I always end up with a 2D Histogram as a result cv::Mat from cv::calcHist, but I basically would like to calculate based on a given bin_size x_bin for the x-axis the average of values in y.
Take as an example: x ranges from -40 to 60, desired bins = 10, bin_size = 10, data points (x,y): (-35, 10), (-39, 20) The 1D histogram would then need to calculate the average of y = (10+20)/2 for the bin range from -40 to -30.
So the sum of each bin shouldn't be a simple count of values falling in that specific bin range but rather the average of values.
I hope I could state the problem in an understandable way. Any help is appreciated.