Since pixels are usually represented as RGB (red, green, blue) values, it's often more useful to convert them to another color space to manipulate them, e.g. HSB (Hue, Saturation, Brightness) - that way you can change those values individually more easily.
If you search for RGB to HSB conversion you should find examples of how to do it (I think I found some useful code on Wikipedia).
Obviously after you've manipulated the pixels (e.g. multiplying the saturations by 0.2) you then have to convert them back to RGB for display.
发布评论
评论(1)
由于像素通常表示为 RGB(红、绿、蓝)值,因此将它们转换为另一个颜色空间来操纵它们通常更有用,例如 HSB(色调、饱和度、亮度) - 这样您就可以单独更改这些值容易地。
如果您搜索 RGB 到 HSB 转换,您应该找到如何进行转换的示例(我想我在维基百科上找到了一些有用的代码)。
显然,在操作像素之后(例如,将饱和度乘以 0.2),您必须将它们转换回 RGB 以进行显示。
Since pixels are usually represented as RGB (red, green, blue) values, it's often more useful to convert them to another color space to manipulate them, e.g. HSB (Hue, Saturation, Brightness) - that way you can change those values individually more easily.
If you search for RGB to HSB conversion you should find examples of how to do it (I think I found some useful code on Wikipedia).
Obviously after you've manipulated the pixels (e.g. multiplying the saturations by 0.2) you then have to convert them back to RGB for display.