(define obamicon
(lambda (clr2)
(image-map (lambda (clr1) (image-ref clr1 (+ (color-ref clr1 'red)(color-ref clr1 'green)
(color-ref clr1 'blue))))
(cond
[(<= clr2 181) (color-set! clr2 [0 51 76])]
[(and (>= clr2 182) (<= clr2 363)) (color-set! clr2 [217 26 33])]
[(and (>= clr2 364) (<= clr2 545)) (color-set! clr2 [112 150 158])]
[(and (>= clr2 546) (<= clr2 765)) (color-set! clr2 [252 227 166])]))))
我正在制作一个更改图像以模仿奥巴马竞选海报的程序。图像映射假设获取每个像素并将它们相加以获得总和,并且在 cond 语句中检查该总和以查看假设用什么颜色替换它。截至目前,我得到
Exception in <=: #[color 0 0 0] is not a real number or clr1 is not bound.
有什么想法是错的吗?
谢谢!