1-D interpolation of histogram
Afficher commentaires plus anciens
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.
Réponses (1)
Jos (10584)
le 10 Déc 2014
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)
Catégories
En savoir plus sur Histograms dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!