如何根据图像中的颜色数量对图像进行分类?

时间:2016-03-31 16:35:49

标签: image-processing classification rgb threshold

我遇到的问题是所有图像都有相同的对象;但是,这些对象可以具有number_of_colors< = 3 OR number_of_colors> 3并且图像未被标记。

我的尝试首先将RGB转换为LAB并仅考虑A& B找到该图像的颜色覆盖范围。我认为它是AB空间的一个区域。因此,对于每个图像,我找到了A和B的范围(即max(A)-min(A),max(B)-min(B))并将它们相乘以得到该区域,假设它是一个矩形。然后我使用此功能进行阈值处理。

如果直觉是正确的以及为什么它不起作用,请告诉我。这是混淆矩阵:

  • 目标价:0.41935483871,FN:0.0645161290323
  • FP:0.0967741935484,TN:0.41935483871

这是每个图像应该工作的基本例程

    LAB = rgb_to_lab(data_rgb[...,0],data_rgb[...,1],data_rgb[...,2])
    A = LAB[1]
    B = LAB[2]

    minA,maxA = np.min(A),np.max(A)
    minB,maxB = np.min(B),np.max(B)

    diff_A = maxA - minA
    diff_B = maxB - minB

    area = diff_A * diff_B 
    # p is the normalized area
    p = area/(200*200.)
    # Found 0.53 to be the best possible threshold
    if p >0.53:
        print 'class 1 - colors > 3'
    else:
        print 'class 2 - colors <= 3'

编辑1:

Here is an image to show how the threshold separates positive and negative images

编辑2:

This shows the same plot but only considering A and B values with luminance between 16 and 70 which seems to increase the area of separation reduces the FP by 1.

0 个答案:

没有答案