XxaemaethxX:

result = (chan_r + chan_g + chan_b/3)


The division must be outside the parantheses: result = (chan_r + chan_g + chan_b)/3
Furthermore, sometimes different weights are used for converting RGB to gray-scale, like this for example: 0.2989 * R + 0.5870 * G + 0.1140 * B