Implemented grayscale transformation