C++ HSB vs HSL vs HSV
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15668623/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HSB vs HSL vs HSV
提问by Giwrgos Tsopanoglou
I am making a Color class as a part of a very basic graphics API in c++. So I decided to take a look at Microsoft's .NET framework and noticed that their Color class has functions for HSB.
我正在将 Color 类作为 C++ 中非常基本的图形 API 的一部分。所以我决定看看微软的 .NET 框架,并注意到他们的 Color 类有 HSB 的功能。
Then I started a research to determine whether I should provide HSB, HSL or HSV or ALL of them in my class.
然后我开始了一项研究,以确定我是否应该在我的班级中提供 HSB、HSL 或 HSV 或所有这些。
So, I have 3 questions on HSB, HSL, HSV:
所以,我有 3 个关于 HSB、HSL、HSV 的问题:
Is HSB same as HSL?
If not, why isn't there an HSBL or even HSBLV?
I find many different methods of calculating these values, can someone show me the FASTEST ones?
HSB和HSL一样吗?
如果没有,为什么没有 HSBL 甚至 HSBLV?
我找到了许多不同的计算这些值的方法,有人可以告诉我最快的方法吗?
采纳答案by JoseV
Is HSB same as HSL?
HSB和HSL一样吗?
No, HSB is the same as HSV but HSL is different. All these are used as a friendly way to represent RGB colors. The Wikipedia article on HSL an HSV explains the differences using color cilinders: HSL and HSVBasically, Hue is the same for HSB and HSL but the Saturation takes different values and Brightness and Lightness are also different.
不,HSB 与 HSV 相同,但 HSL 不同。所有这些都被用作表示 RGB 颜色的友好方式。维基百科上关于 HSL 和 HSV 的文章解释了使用 color cilinders 的差异:HSL 和 HSV基本上,HSB 和 HSL 的色调相同,但饱和度采用不同的值,亮度和亮度也不同。
If not, why isn't there an HSBL or even HSBLV?
如果没有,为什么没有 HSBL 甚至 HSBLV?
I don't get the point. Both HSB/HSV and HSL can represent any RGB color. Having B and L independently is not possible because of the way they are defined. A given HSB Brightness and Saturation is associated to a fixed Lightness. In fact converting between them is very easy.
我不明白重点。HSB/HSV 和 HSL 都可以表示任何 RGB 颜色。由于 B 和 L 的定义方式不同,它们不可能独立存在。给定的 HSB 亮度和饱和度与固定的亮度相关联。事实上,它们之间的转换非常容易。
I find many different methods of calculating these values, can someone show me the FASTEST ones?
我找到了许多不同的计算这些值的方法,有人可以告诉我最快的方法吗?
There's a similar question here for calculating HSB from RGB: Fast, optimized and accurate RGB <-> HSB conversion code in CThere's a Java implementation there that might help. For converting between HSB/HSV and HSL see HSL vs HSB vs HSV
这里有一个类似的问题,用于从 RGB 计算 HSB:快速、优化和准确的 RGB <-> C 中的 HSB 转换代码那里有一个 Java 实现可能会有所帮助。要在 HSB/HSV 和 HSL 之间转换,请参阅HSL vs HSB vs HSV
回答by aziz
Originally the difference between Brightness And Lightness Is. "Brightness" is used for Subtractive colors and "Lightness" for Additive colors. Now if your program is dealing with Subtractive colors like the CMYK system it is better to use HSB otherwise it is better HSL.
原来亮度和亮度之间的区别是。“亮度”用于减色,“亮度”用于加色。现在,如果您的程序正在处理像 CMYK 系统这样的减色法,那么最好使用 HSB,否则使用 HSL 会更好。
回答by Kamil Kie?czewski
- HSB!=HSL && HSB==HSV
- HSBL and HSBLV not exists because Lightness and Brightness(Value) are substitutes
- Here are conversion methods (more on wiki HSL2RGBand HSV2RGB)
- HSB!=HSL && HSB==HSV
- HSBL 和 HSBLV 不存在,因为 Lightness 和 Brightness(Value) 是替代品
- 这是转换方法(更多关于 wiki HSL2RGB和HSV2RGB)
HSV -> RGB(implementation in js here)
HSV - > RGB(在JS实现这里)
RGB -> HSV(implementation in js here)
RGB - > HSV(在JS实现这里)