Added function to get gray value.