英文:
Image Processing: Separate Yellow and Blue Channels in Lab Color Space
问题
我是新手对图像处理不太了解,我被分配了一个任务,需要从只包含蓝色和黄色的图像中,通过白色边缘分离黄色(正值)和蓝色(负值)颜色。
不幸的是,我不知道应该如何分离这两种颜色。
而且,我在得到的图像像素中看不到任何负值。
不幸的是,我不能使用高级库,如OpenCv
,而且大部分与图像处理相关的互联网教程都使用它。
我将图像从RGB
转换为Lab
颜色空间。我在Python中进行操作,使用scikit-image
库和其他有用的包。
如果有人能给我一些提示,我将不胜感激!谢谢。
英文:
I'm new to image processing, and I was given a task to separate the yellow (+ve values) and blue (-ve values) colors by a white edge from an image that contains only blue and yellow colors.
Unfortunately, I don't know how should I separate both colors.
Also, I cannot see any negative values in the pixels of the image which I got.
Unfortunately, I cannot use an advanced libraries such as OpenCv
and most of the tutorials related to image processing on the Internet uses it.
I converted the image from RGB
to Lab
color space. I'm using Python for this and scikit-image
library and other useful packages.
I'll be glad if anyone could help by giving me any hints!
Thanks
答案1
得分: 2
你需要找到一个颜色空间,其中黄色和蓝色能够很好地分开。在RGB
颜色空间中(R在左边,G在中间,B在右边),分割通道并将它们分配到页面上:
RGB无边缘检测:
RGB带有边缘检测:
这并不是很好 - 材料捕捉到光线的明亮黄色部分被视为边缘。
让我们尝试使用Lab
而不是RGB
,L
在左边,a
在中间,b
在右边:
Lab无边缘检测:
Lab带有边缘检测:
依然不太好。现在让我们尝试HSV
颜色空间,H
在左边,S
在中间,V
在右边:
HSV无边缘检测:
HSV带有边缘检测:
希望你能看到H
在左边是最好的。这是因为黄色在此图表中是60度,而蓝色是240度,因此这两种颜色是对立的 - 或者说是六边形中的圆直径。
然后,你需要进行边缘检测和加粗,然后可以通过选择“变亮”混合模式来将白色边缘叠加到黄色和蓝色的旗帜上,以便在图像的每个位置选择较亮的像素,以使白色边缘透过蓝色和黄色。
英文:
You need to find a colourspace where the yellows and the blues are well separated. Splitting the channels, and assigning them across the page, in RGB
colourspace (with R on the left, G in the centre and B on the right):
RGB without edge detection:
RGB with edge detection:
that's not very good - the brighter tones of yellow where the material is catching the light are being treated like edges.
Let's try Lab
instead of RGB
with L
on the left, a
in the centre and b
on the right:
Lab without edge detection:
Lab with edge detection:
Still not so good. Now let's try HSV
colourspace, H
on the left, S
in the centre and V
on the right:
HSV without edge detection:
HSV with edge detection:
And hopefully you can see that H
on the left nails it. That's because yellow is 60 degrees and blue is 240 degrees in this diagram so your two colours are diametrically opposed - or whatever hexagons have in place of a circle's diameter.
Then you need to do edge detection, and fattening, then you can composite the white edge over the top of the yellow and blue flag by choosing a "lighten" blend mode where you choose the lighter pixel at each location in the images so that the white edges filter through the blue and yellow.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论