Added initial calculation of grayscale magnitude