如何检测YCRCB中的颜色白色?
我想在Python中使用开放式简历检测白对象,但是我有问题以定义YCBCR中的下白色和上部白色。我尝试制作程序,但该程序无法获得正确的结果来检测对象。这是我的代码:
ycrcb = cv.cvtColor(rgb, cv.COLOR_BGR2YCrCb)
lower_white = np.array([205, 128, 128], dtype=np.uint8)
upper_white = np.array([235, 128, 128], dtype=np.uint8)
img = cv.inRange(ycrcb, lower_white, upper_white)
我尝试检测使用结构元素并将其发送到形态:
se_3 = cv.getStructuringElement(cv.MORPH_RECT,(3,3))
dst_dilate = cv.dilate(img, se_3, iterations = 1)
并使用位置将其放在一起:
res = cv.bitwise_and(rgb,rgb, mask= dst_dilate)
我尽力而为,但结果是不正确的,我需要您的意见来改变哪一部分并获得更好的结果。
i want to detect white object using open cv in python, but i have problem to define lower white and upper white in ycbcr. i try to make program but the program doesn't get right result to detect an object. this my code:
ycrcb = cv.cvtColor(rgb, cv.COLOR_BGR2YCrCb)
lower_white = np.array([205, 128, 128], dtype=np.uint8)
upper_white = np.array([235, 128, 128], dtype=np.uint8)
img = cv.inRange(ycrcb, lower_white, upper_white)
and i try to detect using structuring element and send to morphology :
se_3 = cv.getStructuringElement(cv.MORPH_RECT,(3,3))
dst_dilate = cv.dilate(img, se_3, iterations = 1)
and put it together using bitwise and:
res = cv.bitwise_and(rgb,rgb, mask= dst_dilate)
i try my best but the result is incorrect, i need your opinion which part to change and get better result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是加载图像,将其转换为所需的颜色空间,然后将通道分开,并并排放置。然后,使用系统的“ colour-dropper工具” (“数字颜色仪表” 在macOS上)查看您感兴趣的区域中各个渠道的值:
< a href =“ https://i.sstatic.net/ivr2b.png” rel =“ nofollow noreferrer”>
您应该看到您大致需要以下范围:
y
60..255cr
120..136cb
120 .. 136如果您没有“彩色滴管” 工具,请转到 imagej 在线工具此处并在下面上传我的输出图像,然后鼠标在其上看到这样的值:
如果您在Linux上,您可以得到一个彩色滴管机称为
gpick
with:The easiest way to do this is to load your image, convert it to your desired colourspace and split the channels, laying them out side-by-side. Then use your system's "colour-dropper tool" ("Digital Color Meter" on macOS) to look at the values of the individual channels in the areas that interest you:
You should see you need roughly the following ranges:
Y
60..255Cr
120..136Cb
120..136If you don't have a "Color Dropper" tool, just go to ImageJ online tool here and upload my output image below and mouse over it to see the values like this:
If you are on Linux, you can get a colour dropper called
gpick
with: