3

Question : How to compare two colors, probably taken with two different cameras?

Scenario :

I have a reference image, which has different colored squares. It may be taken with a IPhone Camera or copied from PDF file. Below is a sample reference image copied from PDF :

enter image description here

Now other people take images of similar images (colored squares) with their own cameras. A sample test image is given below:

enter image description here

For each square in test image, I need to check which is the most closest square in reference image.

My Understanding :

There are several similar questions related to it in SOF. Below are points I got:

1 - Find the RGB values the squares and find euclidean distance between all squares, and select the one with minimum.

But several people say it is RGB is not a good color representation

2 - Do above method with HSV or Lab.

3 - DeltaE method ( I don't know much about it)

Here, in my problem, images are taken with two different cameras. So will the above methods work for this kind of problems ?

If not, can anyone share a good method to compare the colors taken from two different cameras ?

Abid Rahman K
  • 51,886
  • 31
  • 146
  • 157
  • Might be useful: http://stackoverflow.com/questions/10640995/color-detection-algorithm –  Dec 30 '12 at 20:13
  • I have tried it. It is about color extraction, not about color comparison. I need to compare how two colors are similar. – Abid Rahman K Dec 30 '12 at 20:16
  • Not even close to on-topic here. This takes a fair amount of color science to do well. –  Dec 30 '12 at 21:19
  • 1
    I don't understand why it is downvoted and why not on-topic. Check this similar question : http://stackoverflow.com/questions/9018016/how-to-compare-two-colors. My question is different from that, since images are taken with two different cameras. I asked this question after checking lots of similar question here in SOF. And if people think it is on-topic, I believe they should also recommend where it is suitable to ask. – Abid Rahman K Dec 31 '12 at 03:31
  • @AbidRahmanK The question in general is on topic, but the contents of it need to be adjusted. I would start by showing the results of some attempts, and how it doesn't produce the result you want. As it stands, it contains several other questions inside it, restrict your question to a single one of them. Nevertheless, I wouldn't use any of the answers posted here and also none of the mentions included in your own question (euclidean distance, white balance, etc). The approach needs to be a different one to have chance to work more reliably, look into colour histogram adaptation. – mmgp Jan 05 '13 at 15:38
  • Also, calibrate against a known pattern. – mmgp Jan 05 '13 at 15:42

2 Answers2

1

RGB euclidean distance is not good for matching different colors. Imagine you start with black (0,0,0) then pure blue, pure red and pure green are all equally for away and so identical in your scheme.

Converting to an HSV/HSL type color space helps you separate overall brightness from the color and identifies similar colors with different saturations.

If you need this to be at all accurate you might need to also find an area of white in the image and use that to correct for the color of the background light

Martin Beckett
  • 94,801
  • 28
  • 188
  • 263
  • hi, should i find white region in both images? Also, what should i do after finding white region? can you expand last part of your answer,please? – Abid Rahman K Dec 30 '12 at 20:28
  • 1
    You can look for the largest number of pixels of the same color and assume they are a white background then scale the other colors to that white. Try some experiments – Martin Beckett Dec 30 '12 at 22:08
1

I would use a color space that was designed to be (approximately) perceptually uniform. From my memory-guided short search on Wikipedia I would personally choose CIE L*u*v* and use Euclidean norm. That is very similar to the simplest \delta E which does the same with L*a*b* instead of L*u*v*. I believe eiter (or any of the more complicated \delta E) should do very well.

As noted by Martin, white balance might also play some role if not balanced by the cameras...