# What is the most Accurate way of Determining an Object's Color? [closed]

I have written a computer program that can detect coins in a static image (.jpeg, .png, etc.) using some standard techniques for computer vision (Gaussian Blur, thresholding, Hough-Transform etc.). Using the ratios of the coins picked up from a given image, I can establish with good certainty which coins are which. However, I wish to add to my confidence levels and also determine if a coin that I deduce to be of type-A (from radius ratios) is also of the correct colo[u]r. The problem is that for British coins et al. (copper, silver, gold), the respective colors (esp. of copper to gold) are very similar.

I have a routine that extracts the mean color of a given coin in terms of the RedGreenBlue (RGB) 'color-space' and routines to convert this color into HueSaturationBrightness (HSB or HSV) 'color-space'.

RGB is not very nice to work with in attempting to differentiating between the three coin colors (see attached [basic] image for an example). I have the following ranges and typical values for the colours of the different coin types:

Note: the typical value here is one selected using a 'pixel-wise' mean of a real image.

Copper RGB/HSB: typicalRGB = (153, 117, 89)/(26, 0.42, 0.60).

Silver RGB: typicalRGB = (174, 176, 180)/(220, 0.03, 0.71).

Gold RGB: typicalRGB = (220, 205, 160)/(45, 0.27, 0.86)

I first tried to use the 'Euclidian distance' between a given mean coin color (using RGB) and the typical values for each coin type given above treating the RGB values as a vector; for copper we would have:

$$D_{copper} = \sqrt((R_{type} - R_{copper})^{2} + (G_{type} - G_{copper})^{2} + (B_{type} - B_{copper})^{2})$$

where the smallest value of the difference ($D$) 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.

• Welcome to cstheory, a Q&A site for research-level questions in theoretical computer science (TCS). Your question does not appear to be a research-level question in TCS. Please see the FAQ for more information on what is meant by this and suggestions for sites that might welcome your question. Finally, if your question is closed for being out of scope, and you believe you can edit the question to make it a research-level question, please feel free to do so. Closing is not permanent and questions can be reopened, check the FAQ for more information. – Kaveh Feb 20 '12 at 23:22
• Both the definitions of research-level and theoretical computer science are very hard to circumscribe in terms of what is and what isn't. This is why I find your response quite surprising. Sure this question isn't as esoteric as others asked on this site, but none-the-less, other members of the site do think this is worthy of both up votes and answers and it is also clear that the answer to this question will involve a theoretical basis based upon some algorithmic/mathematical foundation (see the basic answer provided below). Also, I must thank you for the down vote. – MoonKnight Feb 21 '12 at 10:11
• @Killercam: I would say this question is research-level, but it's clearly not theoretical computer science; it's a computer vision question. The eye and brain use some complicated algorithm which adjusts perceived color depending on the ambient lighting. I don't know what computer vision people do to simulate this, but it's not a topic generally considered to in theoretical computer science. If the lighting in your pictures doesn't change, standard machine learning techniques would probably be very useful. If it does change, then it may become very difficult. – Peter Shor Feb 21 '12 at 11:41
• The stackexchange serving the statistics and machine-learning community is stats.stackexchange.com; this question is may be on-topic for them. – Peter Shor Feb 21 '12 at 11:56
• @Killercam, I haven't down-votes the question. The fact that some off-topic questions are up-voted by some users doesn't make them on-topic. Theoretical question in computer vision can be on-topic on cstheory, that is the reason for the existence of the tag. You may want to check the other AI Q&A site linked from the FAQ. – Kaveh Feb 21 '12 at 16:41