Eu escrevi um programa de computador que pode detectar moedas em uma imagem estática (.jpeg, .png, etc.) usando algumas técnicas padrão de visão computacional (Gaussian Blur, limiar, Hough-Transform etc.). Usando as proporções das moedas retiradas de uma determinada imagem, posso estabelecer com certeza quais são as moedas. No entanto, desejo aumentar meus níveis de confiança e também determinar se uma moeda que deduzi ser do tipo A (a partir da razão do raio) também é da cor correta. O problema é que, para as moedas britânicas et al. (cobre, prata, ouro), as cores respectivas (especialmente de cobre para ouro) são muito semelhantes.
Eu tenho uma rotina que extrai a cor média de uma determinada moeda em termos do 'espaço de cores' RedGreenBlue (RGB) e rotinas para converter essa cor no 'espaço de cores' HueSaturationBrightness (HSB ou HSV).
Não é muito agradável trabalhar com RGB na tentativa de diferenciar as três cores das moedas (veja a imagem [básica] em anexo). Eu tenho os seguintes intervalos e valores típicos para as cores dos diferentes tipos de moedas:
Nota: o valor típico aqui é aquele selecionado usando a média "pixel" de uma imagem real.
**Copper RGB/HSB:** typicalRGB = (153, 117, 89)/(26, 0.42, 0.60).
**Silver RGB/HSB:** typicalRGB = (174, 176, 180)/(220, 0.03, 0.71).
**Gold RGB/HSB:** typicalRGB = (220, 205, 160)/(45, 0.27, 0.86)
Primeiro tentei usar a 'distância euclidiana' entre uma determinada cor média da moeda (usando RGB) e os valores típicos para cada tipo de moeda acima, tratando os valores RGB como um vetor; para o cobre teríamos:
where the smallest value of the difference () would tell us which type the given coin is most likely to be. This method has shown itself to be very inaccurate.
I have also tried just comparing the hue of the coins with the typical values of the types provided above. Although theoretically this provides a much better 'color-space' to deal with varying brightness and saturation levels of the images, it too was not accurate enough.
Question: What is the best method to determine a coins type based on color (from a static image)?
Thanks very much for your time.
Edit 1
Note: I have tried all of the ideas discussed below and have achieved next to nothing. Variance in lighting conditions (even within the same image) make this problem very tough and should be taken into consideration.
Edit 2 (Summery of Outcome)
Thank you for your answers. Further research of my own (including your answers and comments) has highlighted just how tough this problem is to deal with in the generic case of arbitrary lighting, arbitrary camera (mobile device), fluctuation in coin colour (even for same species/type) etc. I first looked at skin colour recognition (a very active field of research) as a starting point and there are still numerous problems even with the recognition of skin colour for Caucasians alone (see this paper for a review of the current techniques), and the fact that this problem contains three distinct colour objects all of which can have continuous and varying chromacities make this topic of computer vision a very hard one to classify and deal with accordingly (in fact you could do a good Ph.D. on it!).
I looked into the Gamut Constraint Method from the very helpful post by D.W. below. This was at first sight very promising as a pre-processing step to transform the image and the separate coin objects to colours that are independent of lighting conditions. However, even this technique does not work perfectly (and involves a library of images/histograms for mappings – which I don’t want to get into) and neither does the much more complex Neural Network Architecture methodologies. In fact this paper states in the abstract that:
"current machine colour constancy algorithms are not good enough for colour-based
object recognition.".
That is not to say that there aren’t much more up-to-date papers on this subject out there, but I can't find them and it does not seem to be a very active research area at this time.
The answer by AVB was also helpful and I have looked into LAB* briefly.
"The nonlinear relations for L*, a*, and b* are intended to mimic the nonlinear
response of the eye. Furthermore, uniform changes of components in the L*a*b* colour
space aim to correspond to uniform changes in perceived colour, so the relative
perceptual differences between any two colours in L*a*b* can be approximated by
treating each colour as a point in a three dimensional space."
From what I have read, the transformation to this colour space for my device dependent images will be tricky - but I will look into this in detail (with a view to some sort of implementation) when I have a bit more time.
I am not holding my breath for a concrete solution to this problem and after the attempt with LAB* I shall be neglecting coin colour and looking to sure-up my current geometric detection algorithms (accurate Elliptic Hough Transform etc.).
Thanks you all. And as a end note to this question, here is the same image with a new geometric detection algorithm, which has no colour recognition: