How to Calculate Grayscale?

for w () in width
  for h () in height
    image[w(), h()] -->
    grey () = * red * green * blue