code for computing relative brightness