function "vgray" for weigthed rgb average