我正在尝试制作一个使用图像映射根据范围更改图像颜色的程序。像这样:
If the sum of the RGB channels for one pixel = 0 to 181 then the color would be (0 51 76)
If the sum = 182 to 363 then the color would be (217 26 33)
If the sum = 364 to 545 then the color would be (112 150 158)
If the sum = 546 to 765 then the color would be (252 227 166)
现在,这是我到目前为止所拥有的:
(define (sum p)
(image-map
(lambda (c)
(+ (color-ref c 'red) (color-ref c 'green) (color-ref c 'blue)))
p))
(define color-range
(lambda (c)
(cond
[(< (sum c) 181) (color 0 51 76)]
[(and (>= (sum c) 182) (<= (sum c) 363)) (color 217 26 33)]
[(and (>= (sum c) 364) (<= (sum c) 545)) (color 112 150 158)]
[(and (>= (sum c) 546) (<= (sum c) 765)) (color 252 227 166)])))
所以,我做了一个辅助函数来计算每个像素的总和。当我运行颜色范围时,我收到一条错误消息:
图像映射中的异常:#[color 255 255 255] 类型不正确,应为图像
帮助?
谢谢!