Pre-convert your divisions into a multiplicable constant:
a / 3 / 255
is the same as
a * (1 / (3 * 255))
so pre-compute:
const float AVERAGE_SCALE_FACTOR = 1.f / (3.f * 255.f)
then just do
float mean = (r + g + b) * AVERAGE_SCALE_FACTOR;
since multiplying is generally a lot faster than dividing.