Click here to Skip to main content
15,880,651 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Experts

I need to build a simple application to match a color with a reference standard. to be more specific i will scan a tagged color palate of 36 colors (will serve as a reference standard) I will scan the test color on the same scanner (to avoid inter-device variations). The application should compare the color to the standard palette and alert if there is a match. I wonder if visual studio has a tool to do the color comparison.

Thanks in advance
Posted
Updated 16-Feb-13 22:38pm
v4

Color comparison can never be very accurate since there are a number of factors like capability of the scanner to capture brightness, the surrounding light etc involved. You also have factors like alpha correction etc, which although calculable, can make the calculations quite complex.

An easy solution, thought not always accurate, is to use hue, saturation and luminosity[^] to compare and contrast pixel colors.

Comparing based on HSL is described here[^] and it forms an interesting read.
Color Difference[^] provides some explanations.
 
Share this answer
 
v2
Comments
MohamedKamalPharm 17-Feb-13 5:09am    
thanks Abhinav S.
To my knowledge there is no built-in component to do that.
You would have to compare the encoding of the colour at a given point in the test image and find the same colour in an array of the colours in the standard.

You might want to look at, Manipulating colors in .NET - Part 1[^], it's not what you want but has some stuff in it that you might find useful.

You may also want to consider doing the matching with a colour space such as CIE XYZ[^] rather than using colour models, like .Net RGB, which is harder since conversions between models and spaces is not necessarily easy, however spaces represent real colours, models are just that, models and what colour a given point is depends on the output device.

Mike
 
Share this answer
 
Comments
MohamedKamalPharm 17-Feb-13 5:39am    
thanks Mike
In an article I wrote [^], there is a section on color difference equations. I think the Delta E 2000 equation may be helpful.
 
Share this answer
 
v2
Comments
MohamedKamalPharm 18-Feb-13 6:02am    
Excellent Sir !
this is ALMOST what I need
I just need to use my own color palette
How can i use my own set of colors ?
gggustafson 18-Feb-13 11:13am    
Note that the delta_e_2000 method expects two CLILab colors for comparison. I am going to assume that your 36 colors are GDI Colors. What I would suggest:

1. Convert your 36 GDI colors into a List of Extended_Color, calling the list, say, reference colors. The definition for Extended_Color is found in the article. You will need to convert a GDI Color into an XYZ color and then convert the XYZ color into a CIELab color.
2. Convert the GDI color of interest into a CIELab Color (the algorithm in the article stores the value in a class global variable).
3. The method nearest_known_color_name in the class Known_Colors_Palette provides the way in which the comparison might work. Simply, a record of the "shortest distance" is kept and at its conclusion, the closest matching color name is returned. You can modify the method to return whatever you want. For your case, assuming that the delta_e_2000 method is chosen, the foreach loop can be made quite simple.

If you have problems, you can contact me through email (gggustafson at gmail dot com).

Please remember to mark one of the answers as the accepted solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900