RosettaCodeData/Task/Grayscale-image/PicoLisp/grayscale-image-1.l
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

23 lines
548 B
Text

# Convert color image (PPM) to greyscale image (PGM)
(de ppm->pgm (Ppm)
(mapcar
'((Y)
(mapcar
'((C)
(/
(+
(* (car C) 2126) # Red
(* (cadr C) 7152) # Green
(* (caddr C) 722) ) # Blue
10000 ) )
Y ) )
Ppm ) )
# Convert greyscale image (PGM) to color image (PPM)
(de pgm->ppm (Pgm)
(mapcar
'((Y)
(mapcar
'((G) (list G G G))
Y ) )
Pgm ) )