\ Convert 24 bit true color image to grayscale

include lib/graphics.4th

: convert2gray ( -- )
  pic_height @  0  do
    pic_width @  0  do
       to_color  j i pixel@
       color>n
       to_gray  j i pixel!
    loop
  loop ;

: convert ( -- )
  argn 3 < abort" Usage: col2gray  infile outfile"
  1 args get_image
  convert2gray
  to_gray
  2 args save_image ;

convert

