在其中显示单个通道的颜色(不是灰度)
我可以成功将BGR映像转换为CMYK,并且我得到了大小的数组(高度,宽度,4)
,4
是C,M,M,Y和K频道,范围从0到1。
在我拆分该cmyk
数组之后,我有4个大小的数组(高度,宽度)
表明我的量每个像素的k。
如果我只想显示c
(青色)频道的频道,我不能使用cv.imshow('cyan',c)
,因为它给了我一个灰度图像,正如预期的。
因此,我如何在青色中显示c
频道/数组,其基于c
array的“饱和度”的正确量? < br> 或者,我如何获得灰度图像以显示青色的,每个像素的青色中的“饱和”?
编辑:
我的目标是将BGR图像拆分为4个通道(C,M,Y和K),我应该使用每个像素来给我颜色的量(青色,洋红色,黄色或黑色),以全颜色表示图像,在白色背景上 /strong>(正如打印机一样)。
示例:
此图像:
>
那些4'Channel's堆叠/在白色背景上的堆叠/涂漆将提供完整的彩色图像。
因此,我希望能够生成这4张图像,并有一种方法来了解每个像素所需的每种颜色(青色,洋红色,黄色,黑色)的数量(用于白色表面上的添加色)
I can successfully convert a BGR image to CMYK and I get a array of size (height, width, 4)
, the 4
being the C, M, Y and K channels, ranging from 0 to 1.
After I split that CMYK
array, I have 4 arrays of size (height, width)
that indicates me the amount of C, M, Y and K for each pixel.
If I want to show only the C
(cyan) channel for exemple, I cannot use cv.imshow('Cyan', C)
because it gives me a grayscale image, as expected.
So, how can I show the C
channel/array in cyan, with the correct amount of "saturation" based on the C
array ?
Or, how can I get that grayscale image to show cyan, with the same "saturations" in cyan for each pixel ?
EDIT:
My goal is to split an BGR image into 4 channels (C, M, Y and K) that give me the amount of color (cyan, magenta, yellow or black) I should use for each pixel to represent the image, in full colours, on a white background (as a printer would do it).
Exemple:
This image:
Would be split like this:
Those 4 'channels' stacked/painted on a white background would give the full colour image.
So I would like to be able to generate those 4 images and to have a way to know the quantity of each color (cyan, magenta, yellow, black) needed for each pixel (for additive coloring on white surface)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
进入CMYK后,您将没有饱和。为此,您需要HSV并分开S通道。然后,如果需要在Python OpenCV中,可以通过将蓝色和绿色通道设置为诸如255的固定值。
输入:
结果:
如果通过“饱和”,您只是指“强度”,则可以通过将青色与CMYK图像分开并进行相同的蓝色=绿色= 255在将单个通道图像转换为3个相等的通道后,使CMYK CYAN通道着色。
Once you go to CMYK, you do not have saturation. For that you need HSV and separate the S channel. You can then colorize the S channel with cyan if you want in Python OpenCV by setting the blue and green channels to some fixed values such as 255.
Input:
Result:
If by "saturations" you just mean "intensities", then you can colorize the CMYK cyan channel, by separating cyan from your CMYK image and do the same colorization of setting blue = green = 255 after converting the single channel image to 3 equal channels.
这是两种用蓝色颜色在Python/OpenCV中(灰度)青色通道着色的方法。
方法1:从CMYK Colorspace获取青色通道。将灰度通道转换为3个通道,并设置为255
方法2的蓝色和绿色通道:从CMY Colorspace获取CYAN通道作为浮点。创建相同维度和类型的“红色”图像。然后将两者乘以255,然后将结果转换为UINT8。请注意,红色是青色的补充,而反相则可以补充它。我使用了来自CMY的青色,因为它会产生更接近您显示的结果。请参阅CMY和CMYK在 https://en.wikipedia.org/wikipedia/cmykimekcy_cmmy_cmmy_model < /a>
输入(cmmyk):
通过方法1:
input(cmmy):
:
的结果,这是从CMYK着色的结果。
为了完整性,这是使用方法2:
Here are two ways to colorize the (grayscale) cyan channel in Python/OpenCV with a cyan color.
Method 1: Get cyan channel from CMYK colorspace. Convert grayscale channel to 3 channels and set the blue and green channels with value of 255
Method 2: Get the cyan channel from CMY colorspace as float. Create a "red" image of the same dimensions and type. Then multiply the two and divide by 255, invert and convert the result to uint8. Note that red is the complement of cyan and inverting complements it back. I used cyan from CMY, since it produces a result closer to what you show. See the difference of cyan from CMY and CMYK at https://en.wikipedia.org/wiki/CMYK_color_model
Input (C from CMYK):
Colorized by method 1:
Input (C from CMY):
Colorized by method 2:
For completeness, here is the result of colorizing cyan from CMYK using method 2: