Python 3.x 当用户输入为RGB值时,如何定义图像的阈值?

Python 3.x 当用户输入为RGB值时,如何定义图像的阈值?,python-3.x,opencv,image-thresholding,Python 3.x,Opencv,Image Thresholding,我用opencv随机生成了100幅不同颜色的图像。每种颜色都有一个RGB范围(用于计算阈值),在分析100幅图像后,我想找出给定颜色最多的区域。用户输入是RGB值和阈值。当我读取图像时,我可以将RGB转换为HSV,但当输入是RGB值时,我不知道如何进行转换。我可以有一个红色、绿色和蓝色的嵌套for循环,这是一个荒谬的解决方案 for images in imageList: #for th in range(a,b): #RGB_value = (blue+a, green, r

我用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, green, 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循环