1
$\begingroup$

I have a problem where all images have the same object; however, these objects can either have number_of_colors<=3 OR number_of_colors>3 and images are not labeled.

My attempt starts by converting RGB to LAB and Consider only the A & B to find the color coverage of that image. I was thinking of it as an area on the AB space. So for every image, I found the range of A and B (i.e max(A)-min(A), max(B)-min(B)) and multiplied them together to get the area, assuming it's a rectangle. Then I threshold using this feature.

Here is the confusion matrix:

  • TP: 0.41935483871, FN: 0.0645161290323
  • FP: 0.0967741935484, TN: 0.41935483871

Here is the basic routine the should work per image

    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.5 to be the best possible threshold
    if p >0.53:
        print 'class 1 - colors > 3'
    else:
        print 'class 2 - colors <= 3'

enter image description here

Please let me know if my intuition is correct and why it isn't working. I have no experience in image processing. I would love to know what is the standard way to do this. I could manually find the range of each color in Hue after converting to HSV but it seems too specific which might not handle all the colors in the test set.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.