问题描述
我使用 opencv 随机生成了 100 张不同颜色的图像。每种颜色都有一个 RGB 范围(用于计算阈值)我想在分析 100 张图像后找出具有最多给定颜色的区域的位置。用户输入是 RGB 值和阈值。我可以在读取图像时将 RGB 转换为 HSV,但是当输入是 RGB 值时我不知道该怎么做。我可以为红色、绿色和蓝色嵌套 for 循环,这是一个荒谬的解决方案。
for images in imageList:
#for th in range(a,b):
#RGB_value = (blue+a,green,red) and another loop for green etc.
RGB_value = (blue,red) #User input
ind = np.where(np.all(img == RGB_value,axis=-1))
numpyList.extend(list(zip(ind[1],ind[0]))) #Extend the list for each numpy arrays of image.
getDuplicatesCount(numpyList)
有没有更好的解决方案,而不是使用大量的 for 循环?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)