<p>You can fit a model to estimate a posterior probability of a color space point to belong to a certain coin type. Take a look at Gaussian mixture model. Another (somewhat arbitrary, but simpler) approach is to use nearest-neighbour interpolation.</p>

CC BY-SA 3.0
2012-02-20T23:45:22.030Z
2012-02-20T23:45:22.030Z
Dmytro Korduban
<p>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.</p>

<p>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'. </p>

<p>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:</p>

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

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

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

<p><strong>Gold RGB:</strong> typicalRGB = (220, 205, 160)/(45, 0.27, 0.86) </p>

<p>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: </p>

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

<p>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.</p>

<p>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.</p>

<p><strong>Question:</strong> What is the best method to determine a coins type based on color (from a static image)?</p>

<p>Thanks very much for your time.</p>

<p><img src="https://i.sstatic.net/GpZHm.jpg" alt="Typical Coin Colors"></p>

CC BY-SA 3.0
2012-02-20T23:22:16.357Z
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
CC BY-SA 3.0
2012-02-21T10:11:12.633Z
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
CC BY-SA 3.0
2012-02-21T11:41:48.997Z
@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 
CC BY-SA 3.0
2012-02-21T11:56:34.717Z
The stackexchange serving the statistics and machine-learning community is http://stats.stackexchange.com/; this question is may be on-topic for them.
Peter Shor 
CC BY-SA 3.0
2012-02-21T13:34:20.603Z
Thanks for your response. Much appreciated, I will try the exchange site you suggest.
MoonKnight
CC BY-SA 3.0
2012-02-21T13:43:49.967Z
It also seems then, that most of the questions under the *cv.computervision* tag are also 'off-topic'.
MoonKnight
CC BY-SA 3.0
2012-02-21T16:41:48.347Z
@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
<ai.artificial-intel><cv.computer-vision>
What is the most Accurate way of Determining an Object's Color?
MoonKnight
# What is the most Accurate way of Determining an Object's Color?

(Asked by: username_0 on 2012-02-20)

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.

![Typical Coin Colors](https://i.sstatic.net/GpZHm.jpg)

**Tags:** ai.artificial-intel, cv.computer-vision

> **Comments:**
> **username_1**: 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.  
> **username_0**: 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.  
> **username_2**: @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.  
> **username_2**: The stackexchange serving the statistics and machine-learning community is http://stats.stackexchange.com/; this question is may be on-topic for them.  
> **username_0**: Thanks for your response. Much appreciated, I will try the exchange site you suggest.  
> **username_0**: It also seems then, that most of the questions under the *cv.computervision* tag are also 'off-topic'.  
> **username_1**: @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].  

---

## 1 answers

### Answer by username_3 on 2012-02-20. Score: 0 | Accepted answer

You can fit a model to estimate a posterior probability of a color space point to belong to a certain coin type. Take a look at Gaussian mixture model. Another (somewhat arbitrary, but simpler) approach is to use nearest-neighbour interpolation.


---

