RGB到CMYK转换算法(RGB to CMYK Conversion Algorithm)

编程入门 行业动态 更新时间:2024-10-22 18:25:22
RGB到CMYK转换算法(RGB to CMYK Conversion Algorithm)

我需要将RGB值转换为CMYK,如Adobe Photoshop / Mac ColorPicker。 RGB中的所有颜色都不能在CMYK中实现。 但是我发现的算法如rgbtocmyk并不会产生我期待的结果。 对于Ex:rgb(0,0,255),CMYK不支持最纯净的蓝色。 在这种情况下,我需要找到CMYK色域支持的最近的蓝色。 你可以给我任何参考或使用的算法?

I need to convert RGB value to CMYK as in Adobe Photoshop/ Mac ColorPicker. All the colors in RGB cannot be achieved in CMYK. But the algorithms I have found such as rgbtocmyk does'nt produce the result I am expecting. For Ex: rgb(0,0,255) which is the purest blue is not supported in CMYK. In this case, I need to find the nearest blue supported by CMYK gamut. Can you give me any reference to it or the algorithm used?

最满意答案

那明显是错的。 所有RGB颜色可以表示为CMYK,但不是相反。 您发送的链接有效,但看起来R,G,B三个分量的范围是[0,255],而四个C,M,Y,K分量的范围是[0,1]。 通常情况下,RGB坐标用整数表示,CMYK用浮点数表示。 几乎所有可以在网络上找到的算法都可以像这样工作。

PS:这里是该算法的示例实现, http://www.javascripter.net/faq/rgb2cmyk.htm 。

编辑

恐怕详细解释可能会很长,但我们现在就去。 一方面,你有每种颜色的组成部分。 另一方面,您在设备上显示某种颜色。 由于每种颜色在物理上都是波长上的函数,因此RGB表示是该函数的粗略近似。

当您需要匹配设备上的某种颜色时,会出现问题。 例如,对于相同的RGB颜色,两个屏幕可以显示略微不同的颜色。 为了克服将颜色与给定设备上的显示值感知匹配的困难,存在所谓的颜色配置文件,其指定设备如何匹配RGB(或CMYK,或LAB,或者您使用的任何颜色系统)坐标与实际显示的颜色。

根据我的理解,您要执行的转换涉及色彩配置文件。 而且,当我们说RGB时,我们通常会谈论屏幕,当我们说CMYK时,我们通常会谈论打印机(CMYK组件通常会指定打印机用来表示颜色的墨水颜料的数量)。 维基百科条目可以为您提供更多信息: https : //en.wikipedia.org/wiki/Color_space

让我最后指出,你想要执行的转换涉及探索与相关设备相关的颜色配置文件,并不是微不足道的。 但是,RGB-> CMYK转换的第一步是使用我们首先讨论的简单算法进行直接转换。 然后,如果需要,应用颜色校正。

That is simply not true. All RGB colors can be represented as CMYK, but not the opposite. The link you sent works, but it seems the range of the three R, G, B components is [0,255], while the range of the four C, M, Y, K components is [0,1]. This is usual, the RGB coordinates expressed as integers and the CMYK as floating-point numbers. Almost all the algorithms you can find on the web will work like this.

PS: here is a sample implementation of the algorithm, http://www.javascripter.net/faq/rgb2cmyk.htm .

EDIT:

I'm afraid it can be long to explain in detail, but here we go. On one hand, you have the components of each color. On the other hand, you have the display of a certain color on a device. Since each color is physically a function on the wavelength, the RGB representation is a rough approximation of that function.

The problem with that arises when you need to match a certain color on a device. For instance, two screens can show slightly different colors for the same RGB color. To overcome the difficulty of perceptually matching a color with the displayed value on a given device, there exist the so-called color profiles, which specify how the device matches the RGB (or CMYK, or LAB, or whatever color system you use) coordinates with the actual displayed color.

As I understand the situation, the conversion you want to perform involves color profiles. Moreover, when we say RGB we are usually talking about screens, and when we say CMYK we are usually talking about printers (the CMYK components usually specify the amount of ink pigments the printer uses to represent the color). The Wikipedia entry can give you more information on this: https://en.wikipedia.org/wiki/Color_space

Let me finally point out that the conversion you want to perform involves exploring the color profiles associated to the involved devices and is not trivial. However, the first step in RGB->CMYK conversion would be to do a straight conversion with the simple algorithm we discussed first. Then, apply if needed a color correction.

更多推荐

本文发布于:2023-08-07 02:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1458830.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:算法   CMYK   RGB   Conversion   Algorithm

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!