Boost logo

Boost Users :

Subject: [Boost-users] Boost.accumulators : weighted_median
From: Maximilian Matthe (Maxi.Matthe_at_[hidden])
Date: 2010-09-01 05:19:25


Hi!

I want to calculate the median color (along some other data) of the
pixels of an image from its histogram:

std::vector<int> m_Hist;
// m_Hist[i] contains number of pixels with color i.

using namespace boost::accumulators;
accumulator_set<double,
        features<tag::weighted_mean,
                tag::weighted_median(with_p_square_quantile),
                tag::weighted_variance(lazy),
                tag::weighted_skewness
>,
        double> acc;

for(int i = 0; i < 256; i++)
        acc(i, weight = m_Hist[i]);

float mm = weighted_mean(acc);
float stdD = sqrtf(weighted_variance(acc));
float med = weighted_median(acc);
float sk = weighted_skewness(acc);

mean und stdD work correctly, but the median is too large. It gives me
about 200, but the real value should be around 75 (I checked that
manually). The skewness is around 11000 (which also seems quite large to
me).

So, what am I doing wrong with accumulators?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net