RGB值等于CMYK百分比吗?

发布于 2024-10-04 04:18:39 字数 252 浏览 2 评论 0原文

RGB数值等于CMYK百分比吗?

详细信息:

我有一些 rgb 值,例如 r-212 g-231 b-211,在 Photoshop 中,其显示 cmyk 为 40% 34% 80% 0%。我想知道我们能否通过给出 cmyk 百分比来获得相同的 rgb 值?因为我必须在某些特定应用程序中以百分比形式使用 rgb,但我没有在 Photoshop 的帮助下得到它...请帮助简而言之告诉我, 是否可以在 Photoshop 的帮助下获得百分比的 RGB 值?

is rgb numeric values equals to cmyk percentage?

for detail :

i have some rgb values for example r-212 g-231 b-211 and in Photoshop its showing cmyk as 40% 34% 80% 0%.i want to know can we get the same rgb values by giving cmyk percentage? because i have to use rgb in percentage in some particular application but i am not getting it with the help of photoshop...Please help in short tell me,
is it possible to get rgb values in percentage with the help of photoshop?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

や莫失莫忘 2024-10-11 04:18:39

你的问题不太清楚,但是:不,rgb 和 cmyk 不一样,看看这张图片,看看它们可以表示的不同颜色空间(并且,显然,rgb 由 3 个值组成,cmyk 由 4 个值组成) ):

rgb 与 cmyk

your question isn't realy clear, but: no, rgb and cmyk are not the same, take a look at this picture to see the different color space they can represent (and, obviously, rgb consists of 3 values, cmyk consists of 4):

rgb vs cmyk

吖咩 2024-10-11 04:18:39

您可以近似计算 RGBCMYK 色彩空间,但它不会完全准确或双向。 这两种色彩空间之间存在许多差异此处相关,包括它们各自的色域(参见 oezi 答案中的图表)、加法与减法模型以及 CMYK 空间中黑色(关键)的存在。

以下代码(任意使用 C# 编写;随意转换为您选择的语言):

public CmykColor RgbToCmyk(int R, int G, int B)
{
    if ((R < 0) || (R > 255) || (G < 0) || (G > 255) || (B < 0) || (B > 255)) {
        throw new ArgumentException("RGB values must be in the range of 0 to 255");
    }

    if ((R == 0) && (G == 0) && (B == 0)) {
        return new CmykColor(0, 0, 0, 1);
    } else {
        double calcR = 1 - (R / 255);
        double calcG = 1 - (G / 255);
        double calcB = 1 - (B / 255);

        double K = Math.Min(calcR, Math.Min(calcG, calcB));
        double C = (calcR - K) / (1 - K);
        double M = (calcG - K) / (1 - K);
        double Y = (calcB - K) / (1 - K);

        return new CmykColor(Convert.ToInt32(C), Convert.ToInt32(M), Convert.ToInt32(Y), Convert.ToInt32(K));
    }
}

如果您只是对将颜色从 RGB 表示转换为 CMYK 表示的简单方法感兴趣,则可以使用 决定这个简单的近似是否会产生“足够接近”满足您的需求的结果。 要认识到的最重要的一点是,真正的转换完全取决于物理设备/过程,并且需要为每个设备(显示 RGB 的显示器、打印 CMYK 的打印机以及承印物)精确校准颜色配置文件。 这有助于解释为什么上述算法

(或您可能自己实现的任何其他算法)永远不会与 Photoshop 返回的结果相匹配,Photoshop 使用颜色配置文件和一些其他专有算法来处理它的转换。如果这种准确度确实很重要,您可以考虑使用类似 Windows 颜色管理 API 为您处理转换,这将自动应用当前的颜色配置文件,但您可能会发现这些结果也不完全匹配 Photoshop 的结果。

底线是颜色是主观的。正如我在开始时提到的,即使您克服了准确性障碍,您仍然不会有双向的转换过程。即使在 Photoshop 中,您也无法在不丢失或更改某些颜色信息的情况下将图像从 RGB 转换为 CMYK,然后再转换回来。


编辑:您在评论中多次提到您只需要“以百分比表示的 RGB 值”。我认为这意味着 CMYK 百分比,但我认为如果您只想将 RGB 分量的标准 0-255 值转换为 RGB 百分比,那么值得指出,您可以将每个值除以 255(最大值),然后乘以 100。例如:

红色 = RGB(255, 0, 0) = 100% 红色,0% 绿色,0% 蓝色

深海绿 = RGB(143, 188, 143) = 56% 红色,74% 绿色,56% 蓝色

You can approximate a conversion between the RGB and CMYK color spaces, but it's not going to be completely accurate or bidirectional. There are numerous differences between the two color spaces that become relevant here, including their respective gamuts (see the diagram in oezi's answer), the additive vs. subtractive models, and the presence of black (key) in the CMYK space.

If you're merely interested in a simple way to convert a color from its RGB to CMYK representation, you can use the following code (arbitrarily in C#; feel free to convert to the language of your choice):

public CmykColor RgbToCmyk(int R, int G, int B)
{
    if ((R < 0) || (R > 255) || (G < 0) || (G > 255) || (B < 0) || (B > 255)) {
        throw new ArgumentException("RGB values must be in the range of 0 to 255");
    }

    if ((R == 0) && (G == 0) && (B == 0)) {
        return new CmykColor(0, 0, 0, 1);
    } else {
        double calcR = 1 - (R / 255);
        double calcG = 1 - (G / 255);
        double calcB = 1 - (B / 255);

        double K = Math.Min(calcR, Math.Min(calcG, calcB));
        double C = (calcR - K) / (1 - K);
        double M = (calcG - K) / (1 - K);
        double Y = (calcB - K) / (1 - K);

        return new CmykColor(Convert.ToInt32(C), Convert.ToInt32(M), Convert.ToInt32(Y), Convert.ToInt32(K));
    }
}

But you'll have to decide if this simple approximation will produce results that are "close enough" for your needs. The most important thing to realize is that a true conversion is entirely dependent upon the physical device/process and requires accurately calibrated color profiles for each of your devices (the monitor displaying the RGB, the printer printing the CMYK, and the substrate receiving the CMYK).

This helps to explain why the above algorithm (or any other that you might implement on your own) is never going to match the results returned by Photoshop, which uses color profiles and some additional proprietary algorithms to handle its conversion. If this degree of accuracy is truly important, you could consider using something like the Windows Color Management APIs to handle the conversion for you, which will automatically apply the current color profile, but you'll likely find that those results don't exactly match Photoshop's either.

The bottom line is that color is subjective. As I mentioned in the beginning, even if you overcome the accuracy hurdle, you will still not have a conversion process that is bidirectional. Even in Photoshop, you can't convert an image from RGB to CMYK and then back again without losing or altering some of the color information.


EDIT: You mention a couple of times in your comments that you just want "RGB values in percentage." I assume that this means CMYK percentages, but I suppose that it's worth pointing out if you just want to convert the standard 0-255 values for RGB components to an RGB percentage, you can just divide each value by 255 (the max), and then multiply by 100. So, for example:

Red = RGB(255, 0, 0) = 100% Red, 0% Green, 0% Blue

DarkSeaGreen = RGB(143, 188, 143) = 56% Red, 74% Green, 56% Blue

慕巷 2024-10-11 04:18:39

不完全是。 公式 比这更复杂一些,因为 CMYK 的成分比 RGB 更多。

Not entirely. The formula is a little more complex than that, since CMYK has more components than RGB.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文