0

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.

Please let me know if intuition is correct and why it isn't working. 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.53 to be the best possible threshold
    if p >0.53:
        print 'class 1 - colors > 3'
    else:
        print 'class 2 - colors <= 3'

Edit 1:

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

Edit 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.

Nawaf
  • 1
  • 1
  • The number of colors in an image is a fuzzy concept. You need to formalize it. –  Mar 31 '16 at 19:50
  • 40% correct classification?? thats pretty good - your method is crude – gpasch Mar 31 '16 at 22:17
  • Well, 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. – Nawaf Apr 01 '16 at 00:12
  • Lab is fine but I recommend somehow considering lightness for the delta. E.g. the CIEDE2000 formula should get you started and help formalize the "number of colors" concept. – Simon Thum Apr 06 '16 at 14:44
  • @SimonThum, thanks for suggesting this. I've tried to threshold the luminance range before taking the min and max. I'll edit my question to include my trial. I'll check the formula! – Nawaf Apr 06 '16 at 15:20

0 Answers0