1-D interpolation of histogram
이전 댓글 표시
Suppose I have a vector O with some data and a corresponding weight vector G. I would like to perform a weighted binning of the data in O into N bins. For example, if O(1) falls into bin x, the value in bin x is incremented by G(1).
In addition, I would also like the binned values to be linearly interpolated between 2 bins.
In case context helps, O is a vector of image gradient orientations, G is the vector of corresponding gradient magnitudes. The values in O lie between 0 and 180 degrees. The number of bins I wish to use is 4.
For the interpolation, I wish to have circular wrap-around as well, i.e. values falling in last bin are linearly interpolated into first bin and vice-versa.
I can write a loop which runs over O,G and accomplish this, but I was wondering if there are better ways/built-ins to accomplish the same.
답변 (1개)
Jos (10584)
2014년 12월 10일
help histc
help interp1
With HISTC you can count the number of occurrences in a bins. Afterwards you can simply multiply these numbers with the weight.
To wrap interpolation use something like:
yi = interp1([x x(1)], [y y(1)], xi)
카테고리
도움말 센터 및 File Exchange에서 Interpolation에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!