更改位图的色调,同时保留整体亮度
我正在尝试编写一个函数,让我可以对位图进行红移或蓝移,同时保留图像的整体亮度。基本上,完全红移的位图将具有与原始图像相同的亮度,但完全呈红色(即所有像素的 G 和 B 值都相等)。蓝色着色相同(但 R 和 G 相等)。频谱偏移程度需要从 0 到 1 变化。
提前致谢。
I'm trying to write a function that will let me red-shift or blue-shift a bitmap while preserving the overall brightness of the image. Basically, a fully red-shifted bitmap would have the same brightness as the original but be thoroughly red-tinted (i.e. the G and B values would be equal for all pixels). Same for blue-tinting (but with R and G equal). The degree of spectrum shifting needs to vary from 0 to 1.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我正在寻找的效果(糟糕的 JPEG,抱歉):
alt text http://www .freeimagehosting.net/uploads/d15ff241ca.jpg
中间的图像是原始图像,侧面图像分别是完全红移、部分红移、部分蓝移和完全蓝移。
这是产生这种效果的函数:
Here is the effect I was looking for (crappy JPEG, sorry):
alt text http://www.freeimagehosting.net/uploads/d15ff241ca.jpg
The image in the middle is the original, and the side images are fully red-shifted, partially red-shifted, partially blue-shifted and fully blue-shifted, respectively.
And here is the function that produces this effect:
为此,您可以使用 ColorMatrix 类。 此项目中有一个很好的教程。
You'd use the ColorMatrix class for this. There's a good tutorial available in this project.